@atlaspack/transformer-js 7.0.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/JSTransformer.js +11 -4
- package/package.json +7 -7
- package/src/JSTransformer.ts +18 -4
package/lib/JSTransformer.js
CHANGED
|
@@ -168,7 +168,8 @@ const SCRIPT_ERRORS = {
|
|
|
168
168
|
var _default = exports.default = new (_plugin().Transformer)({
|
|
169
169
|
async loadConfig({
|
|
170
170
|
config,
|
|
171
|
-
options
|
|
171
|
+
options,
|
|
172
|
+
logger
|
|
172
173
|
}) {
|
|
173
174
|
let packageJson = await config.getPackage();
|
|
174
175
|
let isJSX, pragma, pragmaFrag, jsxImportSource, automaticJSXRuntime, reactRefresh, decorators, useDefineForClassFields;
|
|
@@ -242,12 +243,13 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
242
243
|
let inlineConstants = false;
|
|
243
244
|
let magicComments = false;
|
|
244
245
|
let addReactDisplayName = false;
|
|
246
|
+
let enableGlobalThisAliaser = Boolean(options.env.NATIVE_GLOBAL_THIS_ALIASER);
|
|
247
|
+
let enableLazyLoadingTransformer = Boolean(options.env.NATIVE_LAZY_LOADING_TRANSFORMER);
|
|
245
248
|
if (conf && conf.contents) {
|
|
246
249
|
var _conf$contents, _conf$contents2, _conf$contents3, _conf$contents4, _conf$contents5;
|
|
247
250
|
_utils().validateSchema.diagnostic(CONFIG_SCHEMA, {
|
|
248
251
|
data: conf.contents,
|
|
249
|
-
|
|
250
|
-
source: await options.inputFS.readFile(conf.filePath, 'utf8'),
|
|
252
|
+
source: (0, _featureFlags().getFeatureFlag)('schemaValidationDeferSourceLoading') ? () => options.inputFS.readFileSync(conf.filePath, 'utf8') : await options.inputFS.readFile(conf.filePath, 'utf8'),
|
|
251
253
|
filePath: conf.filePath,
|
|
252
254
|
prependKey: `/${(0, _diagnostic().encodeJSONKeyComponent)('@atlaspack/transformer-js')}`
|
|
253
255
|
},
|
|
@@ -279,7 +281,9 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
279
281
|
reactRefresh,
|
|
280
282
|
decorators,
|
|
281
283
|
useDefineForClassFields,
|
|
282
|
-
magicComments
|
|
284
|
+
magicComments,
|
|
285
|
+
enableGlobalThisAliaser,
|
|
286
|
+
enableLazyLoadingTransformer
|
|
283
287
|
};
|
|
284
288
|
},
|
|
285
289
|
async transform({
|
|
@@ -430,6 +434,9 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
430
434
|
add_display_name: Boolean(config.addReactDisplayName),
|
|
431
435
|
exports_rebinding_optimisation: options.featureFlags.exportsRebindingOptimisation,
|
|
432
436
|
magic_comments: Boolean(config === null || config === void 0 ? void 0 : config.magicComments) || (0, _featureFlags().getFeatureFlag)('supportWebpackChunkName'),
|
|
437
|
+
is_source: asset.isSource,
|
|
438
|
+
enable_global_this_aliaser: Boolean(config.enableGlobalThisAliaser),
|
|
439
|
+
enable_lazy_loading_transformer: Boolean(config.enableLazyLoadingTransformer),
|
|
433
440
|
callMacro: asset.isSource ? async (err, src, exportName, args, loc) => {
|
|
434
441
|
let mod;
|
|
435
442
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/transformer-js",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@atlaspack/diagnostic": "2.14.4",
|
|
28
|
-
"@atlaspack/feature-flags": "2.
|
|
29
|
-
"@atlaspack/plugin": "2.14.
|
|
30
|
-
"@atlaspack/rust": "3.
|
|
28
|
+
"@atlaspack/feature-flags": "2.26.0",
|
|
29
|
+
"@atlaspack/plugin": "2.14.36",
|
|
30
|
+
"@atlaspack/rust": "3.9.0",
|
|
31
31
|
"@parcel/source-map": "^2.1.1",
|
|
32
|
-
"@atlaspack/utils": "3.0
|
|
33
|
-
"@atlaspack/workers": "2.14.
|
|
32
|
+
"@atlaspack/utils": "3.1.0",
|
|
33
|
+
"@atlaspack/workers": "2.14.36",
|
|
34
34
|
"@swc/helpers": "^0.5.15",
|
|
35
35
|
"browserslist": "^4.6.6",
|
|
36
36
|
"nullthrows": "^1.1.1",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"semver": "^7.5.2"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@atlaspack/core": "2.26.
|
|
41
|
+
"@atlaspack/core": "2.26.1"
|
|
42
42
|
},
|
|
43
43
|
"type": "commonjs"
|
|
44
44
|
}
|
package/src/JSTransformer.ts
CHANGED
|
@@ -4,7 +4,6 @@ import type {
|
|
|
4
4
|
SourceLocation,
|
|
5
5
|
FilePath,
|
|
6
6
|
FileCreateInvalidation,
|
|
7
|
-
ConditionMeta,
|
|
8
7
|
} from '@atlaspack/types';
|
|
9
8
|
import type {SchemaEntity} from '@atlaspack/utils';
|
|
10
9
|
import type {Diagnostic} from '@atlaspack/diagnostic';
|
|
@@ -173,7 +172,7 @@ type MacroContext = {
|
|
|
173
172
|
};
|
|
174
173
|
|
|
175
174
|
export default new Transformer({
|
|
176
|
-
async loadConfig({config, options}) {
|
|
175
|
+
async loadConfig({config, options, logger}) {
|
|
177
176
|
let packageJson = await config.getPackage();
|
|
178
177
|
let isJSX,
|
|
179
178
|
pragma,
|
|
@@ -303,13 +302,21 @@ export default new Transformer({
|
|
|
303
302
|
let magicComments = false;
|
|
304
303
|
let addReactDisplayName = false;
|
|
305
304
|
|
|
305
|
+
let enableGlobalThisAliaser = Boolean(
|
|
306
|
+
options.env.NATIVE_GLOBAL_THIS_ALIASER,
|
|
307
|
+
);
|
|
308
|
+
let enableLazyLoadingTransformer = Boolean(
|
|
309
|
+
options.env.NATIVE_LAZY_LOADING_TRANSFORMER,
|
|
310
|
+
);
|
|
311
|
+
|
|
306
312
|
if (conf && conf.contents) {
|
|
307
313
|
validateSchema.diagnostic(
|
|
308
314
|
CONFIG_SCHEMA,
|
|
309
315
|
{
|
|
310
316
|
data: conf.contents,
|
|
311
|
-
|
|
312
|
-
|
|
317
|
+
source: getFeatureFlag('schemaValidationDeferSourceLoading')
|
|
318
|
+
? () => options.inputFS.readFileSync(conf.filePath, 'utf8')
|
|
319
|
+
: await options.inputFS.readFile(conf.filePath, 'utf8'),
|
|
313
320
|
filePath: conf.filePath,
|
|
314
321
|
prependKey: `/${encodeJSONKeyComponent('@atlaspack/transformer-js')}`,
|
|
315
322
|
},
|
|
@@ -346,6 +353,8 @@ export default new Transformer({
|
|
|
346
353
|
decorators,
|
|
347
354
|
useDefineForClassFields,
|
|
348
355
|
magicComments,
|
|
356
|
+
enableGlobalThisAliaser,
|
|
357
|
+
enableLazyLoadingTransformer,
|
|
349
358
|
};
|
|
350
359
|
},
|
|
351
360
|
async transform({asset, config, options, logger}) {
|
|
@@ -524,6 +533,11 @@ export default new Transformer({
|
|
|
524
533
|
magic_comments:
|
|
525
534
|
Boolean(config?.magicComments) ||
|
|
526
535
|
getFeatureFlag('supportWebpackChunkName'),
|
|
536
|
+
is_source: asset.isSource,
|
|
537
|
+
enable_global_this_aliaser: Boolean(config.enableGlobalThisAliaser),
|
|
538
|
+
enable_lazy_loading_transformer: Boolean(
|
|
539
|
+
config.enableLazyLoadingTransformer,
|
|
540
|
+
),
|
|
527
541
|
callMacro: asset.isSource
|
|
528
542
|
? async (err: any, src: any, exportName: any, args: any, loc: any) => {
|
|
529
543
|
let mod;
|