@atlaspack/runtime-js 2.12.1-dev.3502 → 2.12.1-dev.3520
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/JSRuntime.js +4 -6
- package/package.json +7 -7
- package/src/JSRuntime.js +8 -14
package/lib/JSRuntime.js
CHANGED
|
@@ -192,7 +192,7 @@ var _default = exports.default = new (_plugin().Runtime)({
|
|
|
192
192
|
// For any conditions that are used in this bundle, we want to produce a runtime asset that is used to
|
|
193
193
|
// select the correct dependency that condition maps to at runtime - the conditions in the bundle will then be
|
|
194
194
|
// replaced with a reference to this asset to implement the selection.
|
|
195
|
-
const conditions = bundleGraph.getConditionsForDependencies(conditionalDependencies);
|
|
195
|
+
const conditions = bundleGraph.getConditionsForDependencies(conditionalDependencies, bundle);
|
|
196
196
|
for (const cond of conditions) {
|
|
197
197
|
const requireName = bundle.env.shouldScopeHoist ? 'parcelRequire' : '__parcel__require__';
|
|
198
198
|
const assetCode = `module.exports = require('../helpers/conditional-loader${options.mode === 'development' ? '-dev' : ''}')('${cond.key}', function (){return ${requireName}('${cond.ifTrueAssetId}')}, function (){return ${requireName}('${cond.ifFalseAssetId}')})`;
|
|
@@ -404,13 +404,11 @@ function getLoaderRuntime({
|
|
|
404
404
|
}
|
|
405
405
|
if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi')) {
|
|
406
406
|
let conditionalDependencies = externalBundles.flatMap(to => getDependencies(to).conditionalDependencies);
|
|
407
|
-
for (const cond of bundleGraph.getConditionsForDependencies(conditionalDependencies)) {
|
|
408
|
-
// This bundle has a conditional dependency, we need to load
|
|
409
|
-
let ifTrueBundle = (0, _nullthrows().default)(bundleGraph.getReferencedBundle(cond.ifTrueDependency, bundle), 'ifTrueBundle was null');
|
|
410
|
-
let ifFalseBundle = (0, _nullthrows().default)(bundleGraph.getReferencedBundle(cond.ifFalseDependency, bundle), 'ifFalseBundle was null');
|
|
407
|
+
for (const cond of bundleGraph.getConditionsForDependencies(conditionalDependencies, bundle)) {
|
|
408
|
+
// This bundle has a conditional dependency, we need to load the bundle group
|
|
411
409
|
|
|
412
410
|
// Load conditional bundles with helper (and a dev mode with additional hints)
|
|
413
|
-
loaderModules.push(`require('./helpers/conditional-loader${options.mode === 'development' ? '-dev' : ''}')('${cond.key}', function (){return ${getLoaderForBundle(bundle,
|
|
411
|
+
loaderModules.push(`require('./helpers/conditional-loader${options.mode === 'development' ? '-dev' : ''}')('${cond.key}', function (){return Promise.all([${cond.ifTrueBundles.map(targetBundle => getLoaderForBundle(bundle, targetBundle)).join(',')}]);}, function (){return Promise.all([${cond.ifFalseBundles.map(targetBundle => getLoaderForBundle(bundle, targetBundle)).join(',')}]);})`);
|
|
414
412
|
}
|
|
415
413
|
}
|
|
416
414
|
for (let to of externalBundles) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/runtime-js",
|
|
3
|
-
"version": "2.12.1-dev.
|
|
3
|
+
"version": "2.12.1-dev.3520+8a5346e28",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"source": "src/JSRuntime.js",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">= 16.0.0",
|
|
16
|
-
"parcel": "^2.12.1-dev.
|
|
16
|
+
"parcel": "^2.12.1-dev.3520+8a5346e28"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlaspack/diagnostic": "2.12.1-dev.
|
|
20
|
-
"@atlaspack/feature-flags": "2.12.1-dev.
|
|
21
|
-
"@atlaspack/plugin": "2.12.1-dev.
|
|
22
|
-
"@atlaspack/utils": "2.12.1-dev.
|
|
19
|
+
"@atlaspack/diagnostic": "2.12.1-dev.3520+8a5346e28",
|
|
20
|
+
"@atlaspack/feature-flags": "2.12.1-dev.3520+8a5346e28",
|
|
21
|
+
"@atlaspack/plugin": "2.12.1-dev.3520+8a5346e28",
|
|
22
|
+
"@atlaspack/utils": "2.12.1-dev.3520+8a5346e28",
|
|
23
23
|
"nullthrows": "^1.1.1"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "8a5346e28c1bb3b9cd40f1c4e77c66dd6666f1e4"
|
|
26
26
|
}
|
package/src/JSRuntime.js
CHANGED
|
@@ -195,6 +195,7 @@ export default (new Runtime({
|
|
|
195
195
|
// replaced with a reference to this asset to implement the selection.
|
|
196
196
|
const conditions = bundleGraph.getConditionsForDependencies(
|
|
197
197
|
conditionalDependencies,
|
|
198
|
+
bundle,
|
|
198
199
|
);
|
|
199
200
|
for (const cond of conditions) {
|
|
200
201
|
const requireName = bundle.env.shouldScopeHoist
|
|
@@ -479,26 +480,19 @@ function getLoaderRuntime({
|
|
|
479
480
|
);
|
|
480
481
|
for (const cond of bundleGraph.getConditionsForDependencies(
|
|
481
482
|
conditionalDependencies,
|
|
483
|
+
bundle,
|
|
482
484
|
)) {
|
|
483
|
-
// This bundle has a conditional dependency, we need to load
|
|
484
|
-
let ifTrueBundle = nullthrows(
|
|
485
|
-
bundleGraph.getReferencedBundle(cond.ifTrueDependency, bundle),
|
|
486
|
-
'ifTrueBundle was null',
|
|
487
|
-
);
|
|
488
|
-
let ifFalseBundle = nullthrows(
|
|
489
|
-
bundleGraph.getReferencedBundle(cond.ifFalseDependency, bundle),
|
|
490
|
-
'ifFalseBundle was null',
|
|
491
|
-
);
|
|
485
|
+
// This bundle has a conditional dependency, we need to load the bundle group
|
|
492
486
|
|
|
493
487
|
// Load conditional bundles with helper (and a dev mode with additional hints)
|
|
494
488
|
loaderModules.push(
|
|
495
489
|
`require('./helpers/conditional-loader${
|
|
496
490
|
options.mode === 'development' ? '-dev' : ''
|
|
497
|
-
}')('${cond.key}', function (){return ${
|
|
498
|
-
getLoaderForBundle(bundle,
|
|
499
|
-
|
|
500
|
-
getLoaderForBundle(bundle,
|
|
501
|
-
|
|
491
|
+
}')('${cond.key}', function (){return Promise.all([${cond.ifTrueBundles
|
|
492
|
+
.map((targetBundle) => getLoaderForBundle(bundle, targetBundle))
|
|
493
|
+
.join(',')}]);}, function (){return Promise.all([${cond.ifFalseBundles
|
|
494
|
+
.map((targetBundle) => getLoaderForBundle(bundle, targetBundle))
|
|
495
|
+
.join(',')}]);})`,
|
|
502
496
|
);
|
|
503
497
|
}
|
|
504
498
|
}
|