@atlaspack/transformer-js 10.0.0 → 10.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 +32 -14
- package/package.json +8 -8
- package/src/JSTransformer.ts +43 -21
package/lib/JSTransformer.js
CHANGED
|
@@ -251,6 +251,16 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
251
251
|
let inlineConstants = false;
|
|
252
252
|
let magicComments = false;
|
|
253
253
|
let addReactDisplayName = false;
|
|
254
|
+
let enableSsrTypeofReplacement = options.env.NATIVE_SSR_TYPEOF_REPLACEMENT === 'true';
|
|
255
|
+
let globalAliasingConfig = options.env.NATIVE_GLOBAL_ALIASING && JSON.parse(options.env.NATIVE_GLOBAL_ALIASING);
|
|
256
|
+
let enableLazyLoading = options.env.NATIVE_LAZY_LOADING === 'true';
|
|
257
|
+
let enableReactHooksRemoval = options.env.NATIVE_REACT_HOOKS_REMOVAL === 'true';
|
|
258
|
+
let enableReactAsyncImportLift = options.env.NATIVE_REACT_ASYNC_IMPORT_LIFT === 'true';
|
|
259
|
+
let reactAsyncLiftByDefault = options.env.REACT_ASYNC_IMPORT_LIFTING_BY_DEFAULT === 'true';
|
|
260
|
+
let reactAsyncLiftReportLevel = options.env.REACT_ASYNC_LIFT_REPORT_LEVEL || 'none';
|
|
261
|
+
let enableStaticPrevaluation = options.env.NATIVE_PREVALUATION === 'true';
|
|
262
|
+
let enableDeadReturnsRemoval = options.env.NATIVE_DEAD_RETURNS_REMOVAL === 'true';
|
|
263
|
+
let enableUnusedBindingsRemoval = options.env.NATIVE_UNUSED_BINDINGS_REMOVAL === 'true';
|
|
254
264
|
let syncDynamicImportConfig;
|
|
255
265
|
if (config.env.isTesseract() && options.env.SYNC_DYNAMIC_IMPORT_CONFIG) {
|
|
256
266
|
try {
|
|
@@ -277,10 +287,6 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
277
287
|
}
|
|
278
288
|
}
|
|
279
289
|
config.invalidateOnEnvChange('SYNC_DYNAMIC_IMPORT_CONFIG');
|
|
280
|
-
let enableGlobalThisAliaser = options.env.NATIVE_GLOBAL_THIS_ALIASER === 'true';
|
|
281
|
-
let enableLazyLoadingTransformer = options.env.NATIVE_LAZY_LOADING_TRANSFORMER === 'true';
|
|
282
|
-
let enableDeadReturnsRemover = options.env.NATIVE_DEAD_RETURNS_REMOVER === 'true';
|
|
283
|
-
let enableUnusedBindingsRemover = options.env.NATIVE_UNUSED_BINDINGS_REMOVER === 'true';
|
|
284
290
|
if (conf && conf.contents) {
|
|
285
291
|
var _conf$contents, _conf$contents2, _conf$contents3, _conf$contents4, _conf$contents5;
|
|
286
292
|
_utils().validateSchema.diagnostic(CONFIG_SCHEMA, {
|
|
@@ -318,11 +324,17 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
318
324
|
decorators,
|
|
319
325
|
useDefineForClassFields,
|
|
320
326
|
magicComments,
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
327
|
+
globalAliasingConfig,
|
|
328
|
+
enableSsrTypeofReplacement,
|
|
329
|
+
enableLazyLoading,
|
|
330
|
+
enableDeadReturnsRemoval,
|
|
331
|
+
enableUnusedBindingsRemoval,
|
|
332
|
+
enableStaticPrevaluation,
|
|
333
|
+
enableReactHooksRemoval,
|
|
334
|
+
syncDynamicImportConfig,
|
|
335
|
+
enableReactAsyncImportLift,
|
|
336
|
+
reactAsyncLiftByDefault,
|
|
337
|
+
reactAsyncLiftReportLevel
|
|
326
338
|
};
|
|
327
339
|
},
|
|
328
340
|
async transform({
|
|
@@ -474,12 +486,18 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
474
486
|
exports_rebinding_optimisation: options.featureFlags.exportsRebindingOptimisation,
|
|
475
487
|
magic_comments: Boolean(config === null || config === void 0 ? void 0 : config.magicComments) || (0, _featureFlags().getFeatureFlag)('supportWebpackChunkName'),
|
|
476
488
|
is_source: asset.isSource,
|
|
477
|
-
enable_global_this_aliaser: Boolean(config.enableGlobalThisAliaser),
|
|
478
|
-
enable_lazy_loading_transformer: Boolean(config.enableLazyLoadingTransformer),
|
|
479
|
-
sync_dynamic_import_config: config.syncDynamicImportConfig,
|
|
480
489
|
nested_promise_import_fix: options.featureFlags.nestedPromiseImportFix,
|
|
481
|
-
|
|
482
|
-
|
|
490
|
+
global_aliasing_config: config.globalAliasingConfig,
|
|
491
|
+
enable_ssr_typeof_replacement: Boolean(config.enableSsrTypeofReplacement),
|
|
492
|
+
enable_lazy_loading: Boolean(config.enableLazyLoading),
|
|
493
|
+
enable_dead_returns_removal: Boolean(config.enableDeadReturnsRemoval),
|
|
494
|
+
enable_unused_bindings_removal: Boolean(config.enableUnusedBindingsRemoval),
|
|
495
|
+
enable_static_prevaluation: Boolean(config.enableStaticPrevaluation),
|
|
496
|
+
enable_react_hooks_removal: Boolean(config.enableReactHooksRemoval),
|
|
497
|
+
enable_react_async_import_lift: Boolean(config.enableReactAsyncImportLift),
|
|
498
|
+
react_async_lift_by_default: Boolean(config.reactAsyncLiftByDefault),
|
|
499
|
+
react_async_lift_report_level: String(config.reactAsyncLiftReportLevel),
|
|
500
|
+
sync_dynamic_import_config: config.syncDynamicImportConfig,
|
|
483
501
|
callMacro: asset.isSource ? async (err, src, exportName, args, loc) => {
|
|
484
502
|
let mod;
|
|
485
503
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/transformer-js",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.1.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@atlaspack/build-cache": "2.13.6",
|
|
28
28
|
"@atlaspack/diagnostic": "2.14.4",
|
|
29
|
-
"@atlaspack/feature-flags": "2.27.
|
|
30
|
-
"@atlaspack/plugin": "2.14.
|
|
31
|
-
"@atlaspack/rust": "3.
|
|
32
|
-
"@atlaspack/source-map": "3.1.
|
|
33
|
-
"@atlaspack/utils": "3.2.
|
|
34
|
-
"@atlaspack/workers": "2.14.
|
|
29
|
+
"@atlaspack/feature-flags": "2.27.2",
|
|
30
|
+
"@atlaspack/plugin": "2.14.41",
|
|
31
|
+
"@atlaspack/rust": "3.13.0",
|
|
32
|
+
"@atlaspack/source-map": "3.1.2",
|
|
33
|
+
"@atlaspack/utils": "3.2.2",
|
|
34
|
+
"@atlaspack/workers": "2.14.41",
|
|
35
35
|
"@swc/helpers": "^0.5.15",
|
|
36
36
|
"browserslist": "^4.6.6",
|
|
37
37
|
"nullthrows": "^1.1.1",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"semver": "^7.5.2"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@atlaspack/core": "2.29.
|
|
42
|
+
"@atlaspack/core": "2.29.1"
|
|
43
43
|
},
|
|
44
44
|
"type": "commonjs"
|
|
45
45
|
}
|
package/src/JSTransformer.ts
CHANGED
|
@@ -305,6 +305,25 @@ export default new Transformer({
|
|
|
305
305
|
let magicComments = false;
|
|
306
306
|
let addReactDisplayName = false;
|
|
307
307
|
|
|
308
|
+
let enableSsrTypeofReplacement =
|
|
309
|
+
options.env.NATIVE_SSR_TYPEOF_REPLACEMENT === 'true';
|
|
310
|
+
let globalAliasingConfig =
|
|
311
|
+
options.env.NATIVE_GLOBAL_ALIASING &&
|
|
312
|
+
JSON.parse(options.env.NATIVE_GLOBAL_ALIASING);
|
|
313
|
+
let enableLazyLoading = options.env.NATIVE_LAZY_LOADING === 'true';
|
|
314
|
+
let enableReactHooksRemoval =
|
|
315
|
+
options.env.NATIVE_REACT_HOOKS_REMOVAL === 'true';
|
|
316
|
+
let enableReactAsyncImportLift =
|
|
317
|
+
options.env.NATIVE_REACT_ASYNC_IMPORT_LIFT === 'true';
|
|
318
|
+
let reactAsyncLiftByDefault =
|
|
319
|
+
options.env.REACT_ASYNC_IMPORT_LIFTING_BY_DEFAULT === 'true';
|
|
320
|
+
let reactAsyncLiftReportLevel =
|
|
321
|
+
options.env.REACT_ASYNC_LIFT_REPORT_LEVEL || 'none';
|
|
322
|
+
let enableStaticPrevaluation = options.env.NATIVE_PREVALUATION === 'true';
|
|
323
|
+
let enableDeadReturnsRemoval =
|
|
324
|
+
options.env.NATIVE_DEAD_RETURNS_REMOVAL === 'true';
|
|
325
|
+
let enableUnusedBindingsRemoval =
|
|
326
|
+
options.env.NATIVE_UNUSED_BINDINGS_REMOVAL === 'true';
|
|
308
327
|
let syncDynamicImportConfig:
|
|
309
328
|
| {
|
|
310
329
|
entrypoint_filepath_suffix: string;
|
|
@@ -347,15 +366,6 @@ export default new Transformer({
|
|
|
347
366
|
|
|
348
367
|
config.invalidateOnEnvChange('SYNC_DYNAMIC_IMPORT_CONFIG');
|
|
349
368
|
|
|
350
|
-
let enableGlobalThisAliaser =
|
|
351
|
-
options.env.NATIVE_GLOBAL_THIS_ALIASER === 'true';
|
|
352
|
-
let enableLazyLoadingTransformer =
|
|
353
|
-
options.env.NATIVE_LAZY_LOADING_TRANSFORMER === 'true';
|
|
354
|
-
let enableDeadReturnsRemover =
|
|
355
|
-
options.env.NATIVE_DEAD_RETURNS_REMOVER === 'true';
|
|
356
|
-
let enableUnusedBindingsRemover =
|
|
357
|
-
options.env.NATIVE_UNUSED_BINDINGS_REMOVER === 'true';
|
|
358
|
-
|
|
359
369
|
if (conf && conf.contents) {
|
|
360
370
|
validateSchema.diagnostic(
|
|
361
371
|
CONFIG_SCHEMA,
|
|
@@ -398,11 +408,17 @@ export default new Transformer({
|
|
|
398
408
|
decorators,
|
|
399
409
|
useDefineForClassFields,
|
|
400
410
|
magicComments,
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
411
|
+
globalAliasingConfig,
|
|
412
|
+
enableSsrTypeofReplacement,
|
|
413
|
+
enableLazyLoading,
|
|
414
|
+
enableDeadReturnsRemoval,
|
|
415
|
+
enableUnusedBindingsRemoval,
|
|
416
|
+
enableStaticPrevaluation,
|
|
417
|
+
enableReactHooksRemoval,
|
|
405
418
|
syncDynamicImportConfig,
|
|
419
|
+
enableReactAsyncImportLift,
|
|
420
|
+
reactAsyncLiftByDefault,
|
|
421
|
+
reactAsyncLiftReportLevel,
|
|
406
422
|
};
|
|
407
423
|
},
|
|
408
424
|
async transform({asset, config, options, logger}) {
|
|
@@ -582,16 +598,22 @@ export default new Transformer({
|
|
|
582
598
|
Boolean(config?.magicComments) ||
|
|
583
599
|
getFeatureFlag('supportWebpackChunkName'),
|
|
584
600
|
is_source: asset.isSource,
|
|
585
|
-
enable_global_this_aliaser: Boolean(config.enableGlobalThisAliaser),
|
|
586
|
-
enable_lazy_loading_transformer: Boolean(
|
|
587
|
-
config.enableLazyLoadingTransformer,
|
|
588
|
-
),
|
|
589
|
-
sync_dynamic_import_config: config.syncDynamicImportConfig,
|
|
590
601
|
nested_promise_import_fix: options.featureFlags.nestedPromiseImportFix,
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
602
|
+
global_aliasing_config: config.globalAliasingConfig,
|
|
603
|
+
enable_ssr_typeof_replacement: Boolean(config.enableSsrTypeofReplacement),
|
|
604
|
+
enable_lazy_loading: Boolean(config.enableLazyLoading),
|
|
605
|
+
enable_dead_returns_removal: Boolean(config.enableDeadReturnsRemoval),
|
|
606
|
+
enable_unused_bindings_removal: Boolean(
|
|
607
|
+
config.enableUnusedBindingsRemoval,
|
|
594
608
|
),
|
|
609
|
+
enable_static_prevaluation: Boolean(config.enableStaticPrevaluation),
|
|
610
|
+
enable_react_hooks_removal: Boolean(config.enableReactHooksRemoval),
|
|
611
|
+
enable_react_async_import_lift: Boolean(
|
|
612
|
+
config.enableReactAsyncImportLift,
|
|
613
|
+
),
|
|
614
|
+
react_async_lift_by_default: Boolean(config.reactAsyncLiftByDefault),
|
|
615
|
+
react_async_lift_report_level: String(config.reactAsyncLiftReportLevel),
|
|
616
|
+
sync_dynamic_import_config: config.syncDynamicImportConfig,
|
|
595
617
|
callMacro: asset.isSource
|
|
596
618
|
? async (err: any, src: any, exportName: any, args: any, loc: any) => {
|
|
597
619
|
let mod;
|