@atlaspack/transformer-js 2.12.1-dev.3401 → 2.12.1-dev.3443
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 +18 -2
- package/package.json +11 -10
- package/src/JSTransformer.js +18 -1
package/lib/JSTransformer.js
CHANGED
|
@@ -61,6 +61,13 @@ function _utils() {
|
|
|
61
61
|
return data;
|
|
62
62
|
}
|
|
63
63
|
var _package = _interopRequireDefault(require("../package.json"));
|
|
64
|
+
function _featureFlags() {
|
|
65
|
+
const data = require("@atlaspack/feature-flags");
|
|
66
|
+
_featureFlags = function () {
|
|
67
|
+
return data;
|
|
68
|
+
};
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
64
71
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
65
72
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
66
73
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -324,7 +331,8 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
324
331
|
diagnostics,
|
|
325
332
|
used_env,
|
|
326
333
|
has_node_replacements,
|
|
327
|
-
is_constant_module
|
|
334
|
+
is_constant_module,
|
|
335
|
+
conditions
|
|
328
336
|
} = await (_rust().transformAsync || _rust().transform)({
|
|
329
337
|
filename: asset.filePath,
|
|
330
338
|
code,
|
|
@@ -358,6 +366,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
358
366
|
is_swc_helpers: /@swc[/\\]helpers/.test(asset.filePath),
|
|
359
367
|
standalone: asset.query.has('standalone'),
|
|
360
368
|
inline_constants: config.inlineConstants,
|
|
369
|
+
conditional_bundling: options.featureFlags.conditionalBundlingApi,
|
|
361
370
|
callMacro: asset.isSource ? async (err, src, exportName, args, loc) => {
|
|
362
371
|
let mod;
|
|
363
372
|
try {
|
|
@@ -462,6 +471,13 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
462
471
|
}
|
|
463
472
|
} : null
|
|
464
473
|
});
|
|
474
|
+
if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi')) {
|
|
475
|
+
asset.meta.conditions = conditions.map(c => ({
|
|
476
|
+
key: c.key,
|
|
477
|
+
ifTruePlaceholder: c.if_true_placeholder,
|
|
478
|
+
ifFalsePlaceholder: c.if_false_placeholder
|
|
479
|
+
}));
|
|
480
|
+
}
|
|
465
481
|
if (is_constant_module) {
|
|
466
482
|
asset.meta.isConstantModule = true;
|
|
467
483
|
}
|
|
@@ -678,7 +694,7 @@ var _default = exports.default = new (_plugin().Transformer)({
|
|
|
678
694
|
specifier: dep.specifier,
|
|
679
695
|
specifierType: dep.kind === 'Require' ? 'commonjs' : 'esm',
|
|
680
696
|
loc: convertLoc(dep.loc),
|
|
681
|
-
priority: dep.kind === 'DynamicImport' ? 'lazy' : 'sync',
|
|
697
|
+
priority: dep.kind === 'DynamicImport' ? 'lazy' : dep.kind === 'ConditionalImport' ? 'conditional' : 'sync',
|
|
682
698
|
isOptional: dep.is_optional,
|
|
683
699
|
meta,
|
|
684
700
|
resolveFrom: isHelper ? __filename : undefined,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/transformer-js",
|
|
3
|
-
"version": "2.12.1-dev.
|
|
4
|
-
"license": "MIT",
|
|
3
|
+
"version": "2.12.1-dev.3443+d1170cfc7",
|
|
4
|
+
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"test": "mocha"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
|
-
"parcel": "^2.12.1-dev.
|
|
18
|
+
"parcel": "^2.12.1-dev.3443+d1170cfc7",
|
|
19
19
|
"node": ">= 16.0.0"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
@@ -23,11 +23,12 @@
|
|
|
23
23
|
"src"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@atlaspack/diagnostic": "2.12.1-dev.
|
|
27
|
-
"@atlaspack/
|
|
28
|
-
"@atlaspack/
|
|
29
|
-
"@atlaspack/
|
|
30
|
-
"@atlaspack/
|
|
26
|
+
"@atlaspack/diagnostic": "2.12.1-dev.3443+d1170cfc7",
|
|
27
|
+
"@atlaspack/feature-flags": "2.12.1-dev.3443+d1170cfc7",
|
|
28
|
+
"@atlaspack/plugin": "2.12.1-dev.3443+d1170cfc7",
|
|
29
|
+
"@atlaspack/rust": "2.12.1-dev.3443+d1170cfc7",
|
|
30
|
+
"@atlaspack/utils": "2.12.1-dev.3443+d1170cfc7",
|
|
31
|
+
"@atlaspack/workers": "2.12.1-dev.3443+d1170cfc7",
|
|
31
32
|
"@parcel/source-map": "^2.1.1",
|
|
32
33
|
"@swc/helpers": "^0.5.0",
|
|
33
34
|
"browserslist": "^4.6.6",
|
|
@@ -36,7 +37,7 @@
|
|
|
36
37
|
"semver": "^7.5.2"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
|
-
"@atlaspack/core": "^2.12.1-dev.
|
|
40
|
+
"@atlaspack/core": "^2.12.1-dev.3443+d1170cfc7"
|
|
40
41
|
},
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "d1170cfc79beb290b2a066f472f68f71f7d7cb23"
|
|
42
43
|
}
|
package/src/JSTransformer.js
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
SourceLocation,
|
|
6
6
|
FilePath,
|
|
7
7
|
FileCreateInvalidation,
|
|
8
|
+
ConditionMeta,
|
|
8
9
|
} from '@atlaspack/types';
|
|
9
10
|
import type {SchemaEntity} from '@atlaspack/utils';
|
|
10
11
|
import type {Diagnostic} from '@atlaspack/diagnostic';
|
|
@@ -20,6 +21,7 @@ import ThrowableDiagnostic, {
|
|
|
20
21
|
} from '@atlaspack/diagnostic';
|
|
21
22
|
import {validateSchema, remapSourceLocation, globMatch} from '@atlaspack/utils';
|
|
22
23
|
import pkg from '../package.json';
|
|
24
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
23
25
|
|
|
24
26
|
const JSX_EXTENSIONS = {
|
|
25
27
|
jsx: true,
|
|
@@ -419,6 +421,7 @@ export default (new Transformer({
|
|
|
419
421
|
used_env,
|
|
420
422
|
has_node_replacements,
|
|
421
423
|
is_constant_module,
|
|
424
|
+
conditions,
|
|
422
425
|
} = await (transformAsync || transform)({
|
|
423
426
|
filename: asset.filePath,
|
|
424
427
|
code,
|
|
@@ -459,6 +462,7 @@ export default (new Transformer({
|
|
|
459
462
|
is_swc_helpers: /@swc[/\\]helpers/.test(asset.filePath),
|
|
460
463
|
standalone: asset.query.has('standalone'),
|
|
461
464
|
inline_constants: config.inlineConstants,
|
|
465
|
+
conditional_bundling: options.featureFlags.conditionalBundlingApi,
|
|
462
466
|
callMacro: asset.isSource
|
|
463
467
|
? async (err, src, exportName, args, loc) => {
|
|
464
468
|
let mod;
|
|
@@ -576,6 +580,14 @@ export default (new Transformer({
|
|
|
576
580
|
: null,
|
|
577
581
|
});
|
|
578
582
|
|
|
583
|
+
if (getFeatureFlag('conditionalBundlingApi')) {
|
|
584
|
+
asset.meta.conditions = conditions.map((c): ConditionMeta => ({
|
|
585
|
+
key: c.key,
|
|
586
|
+
ifTruePlaceholder: c.if_true_placeholder,
|
|
587
|
+
ifFalsePlaceholder: c.if_false_placeholder,
|
|
588
|
+
}));
|
|
589
|
+
}
|
|
590
|
+
|
|
579
591
|
if (is_constant_module) {
|
|
580
592
|
asset.meta.isConstantModule = true;
|
|
581
593
|
}
|
|
@@ -850,7 +862,12 @@ export default (new Transformer({
|
|
|
850
862
|
specifier: dep.specifier,
|
|
851
863
|
specifierType: dep.kind === 'Require' ? 'commonjs' : 'esm',
|
|
852
864
|
loc: convertLoc(dep.loc),
|
|
853
|
-
priority:
|
|
865
|
+
priority:
|
|
866
|
+
dep.kind === 'DynamicImport'
|
|
867
|
+
? 'lazy'
|
|
868
|
+
: dep.kind === 'ConditionalImport'
|
|
869
|
+
? 'conditional'
|
|
870
|
+
: 'sync',
|
|
854
871
|
isOptional: dep.is_optional,
|
|
855
872
|
meta,
|
|
856
873
|
resolveFrom: isHelper ? __filename : undefined,
|