@atlaspack/packager-js 2.14.1-dev.53 → 2.14.1-dev.58
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/CHANGELOG.md +27 -0
- package/lib/ScopeHoistingPackager.js +23 -17
- package/package.json +8 -8
- package/src/ScopeHoistingPackager.js +47 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @atlaspack/packager-js
|
|
2
2
|
|
|
3
|
+
## 2.14.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`9b85d3e`](https://github.com/atlassian-labs/atlaspack/commit/9b85d3e645b10bd027eed2304afc970a5ba40062), [`a891d65`](https://github.com/atlassian-labs/atlaspack/commit/a891d652bc4eb3d757d381adf65c5083f706effc), [`d02eab9`](https://github.com/atlassian-labs/atlaspack/commit/d02eab95eb60bf7457e0869af0b773608592c0e6), [`fb87a90`](https://github.com/atlassian-labs/atlaspack/commit/fb87a901973776b33ca4ce530e9d71669a9bd36d), [`7b9e8cf`](https://github.com/atlassian-labs/atlaspack/commit/7b9e8cf29e01a98e72e46b2b2fb74ccc514f4463), [`17b9579`](https://github.com/atlassian-labs/atlaspack/commit/17b9579484eced0ed8f23e2aba6d23b3c7238c39), [`8f4e6c1`](https://github.com/atlassian-labs/atlaspack/commit/8f4e6c1b0e7c1fd48624afda48c1dcc599f1460f)]:
|
|
8
|
+
- @atlaspack/feature-flags@2.14.2
|
|
9
|
+
- @atlaspack/rust@3.1.0
|
|
10
|
+
- @atlaspack/utils@2.14.2
|
|
11
|
+
- @atlaspack/types@2.14.2
|
|
12
|
+
- @atlaspack/plugin@2.14.2
|
|
13
|
+
|
|
14
|
+
## 2.14.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#450](https://github.com/atlassian-labs/atlaspack/pull/450) [`b9d41b1`](https://github.com/atlassian-labs/atlaspack/commit/b9d41b175ad5771651a5b0278a5a0147e669234a) Thanks [@benjervis](https://github.com/benjervis)! - Remove the Atlaspack engines compatibility check
|
|
19
|
+
|
|
20
|
+
- [#478](https://github.com/atlassian-labs/atlaspack/pull/478) [`570493b`](https://github.com/atlassian-labs/atlaspack/commit/570493beaf754e7985aebc7daaaf6dfcfa8fe56b) Thanks [@yamadapc](https://github.com/yamadapc)! - The first attempt at Version Packages didn't include the built artifacts.
|
|
21
|
+
This has hopefully been fixed, so this change will force those packages to re-release.
|
|
22
|
+
- Updated dependencies [[`80bd57b`](https://github.com/atlassian-labs/atlaspack/commit/80bd57b9f9e966563957dee0780d956a682eb2d4), [`ae70b81`](https://github.com/atlassian-labs/atlaspack/commit/ae70b810384cf58f9c57d341ab4c925c7bb2060c), [`ce13d5e`](https://github.com/atlassian-labs/atlaspack/commit/ce13d5e885d55518ee6318e7a72e3a6e4e5126f2), [`4aab060`](https://github.com/atlassian-labs/atlaspack/commit/4aab0605c0d4ee8e0dcc3ffa1162eae5b360b677), [`c0a61a9`](https://github.com/atlassian-labs/atlaspack/commit/c0a61a92405b6830fe39cc17622cc2e97bf02dd7), [`cb35e7d`](https://github.com/atlassian-labs/atlaspack/commit/cb35e7d2b90b372de8401792915f12f410508d24), [`e1422ad`](https://github.com/atlassian-labs/atlaspack/commit/e1422ad0a801faaa4bc4f1023bed042ffe236e9b), [`6ec11f1`](https://github.com/atlassian-labs/atlaspack/commit/6ec11f10a9366fb8a9fc0475c7678235056bd80e), [`570493b`](https://github.com/atlassian-labs/atlaspack/commit/570493beaf754e7985aebc7daaaf6dfcfa8fe56b)]:
|
|
23
|
+
- @atlaspack/rust@3.0.1
|
|
24
|
+
- @atlaspack/utils@2.14.1
|
|
25
|
+
- @atlaspack/feature-flags@2.14.1
|
|
26
|
+
- @atlaspack/diagnostic@2.14.1
|
|
27
|
+
- @atlaspack/plugin@2.14.1
|
|
28
|
+
- @atlaspack/types@2.14.1
|
|
29
|
+
|
|
3
30
|
## 2.14.0
|
|
4
31
|
|
|
5
32
|
### Minor Changes
|
|
@@ -127,12 +127,6 @@ class ScopeHoistingPackager {
|
|
|
127
127
|
for (let b of this.bundleGraph.getReferencedBundles(this.bundle, {
|
|
128
128
|
recursive: false
|
|
129
129
|
})) {
|
|
130
|
-
// If the referenced bundle is a native node bundle then don't require it as
|
|
131
|
-
// an external as we don't want to require native node bundles from other
|
|
132
|
-
// OS architectures
|
|
133
|
-
if (process.env.ATLASPACK_SUPER_BUILD === 'true' && b.type === 'node') {
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
130
|
this.externals.set((0, _utils().relativeBundlePath)(this.bundle, b), new Map());
|
|
137
131
|
}
|
|
138
132
|
}
|
|
@@ -235,15 +229,35 @@ class ScopeHoistingPackager {
|
|
|
235
229
|
shouldBundleQueue(bundle) {
|
|
236
230
|
let referencingBundles = this.bundleGraph.getReferencingBundles(bundle);
|
|
237
231
|
let hasHtmlReference = referencingBundles.some(b => b.type === 'html');
|
|
238
|
-
|
|
232
|
+
let hasConditionalReference = false;
|
|
233
|
+
let isConditionalBundle = false;
|
|
234
|
+
if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi') && (0, _featureFlags().getFeatureFlag)('conditionalBundlingAsyncRuntime')) {
|
|
235
|
+
// If the bundle has a conditional bundle reference (has an importCond)
|
|
236
|
+
hasConditionalReference = this.bundleGraph.getReferencedConditionalBundles(bundle).length > 0;
|
|
237
|
+
// If the bundle is a conditional bundle
|
|
238
|
+
isConditionalBundle = this.hasConditionalDependency();
|
|
239
|
+
}
|
|
240
|
+
return this.useAsyncBundleRuntime && bundle.type === 'js' && bundle.bundleBehavior !== 'inline' && bundle.env.outputFormat === 'esmodule' && !bundle.env.isIsolated() && bundle.bundleBehavior !== 'isolated' && (hasHtmlReference || hasConditionalReference || isConditionalBundle);
|
|
239
241
|
}
|
|
240
242
|
runWhenReady(bundle, codeToRun) {
|
|
241
243
|
let deps = this.bundleGraph.getReferencedBundles(bundle).filter(b => this.shouldBundleQueue(b)).map(b => b.publicId);
|
|
242
|
-
|
|
244
|
+
const conditions = [];
|
|
245
|
+
if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi') && (0, _featureFlags().getFeatureFlag)('conditionalBundlingAsyncRuntime')) {
|
|
246
|
+
const conditionSet = this.bundleGraph.getConditionalBundleMapping().get(bundle.id);
|
|
247
|
+
for (const [key, {
|
|
248
|
+
ifTrueBundles,
|
|
249
|
+
ifFalseBundles
|
|
250
|
+
}] of (conditionSet === null || conditionSet === void 0 ? void 0 : conditionSet.entries()) ?? []) {
|
|
251
|
+
const ifTrueBundleIds = ifTrueBundles.map(b => `"${b.publicId}"`).join(',');
|
|
252
|
+
const ifFalseBundleIds = ifFalseBundles.map(b => `"${b.publicId}"`).join(',');
|
|
253
|
+
conditions.push(`(globalThis.__MCOND && globalThis.__MCOND('${key}') ? [${ifTrueBundleIds}] : [${ifFalseBundleIds}])`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (deps.length === 0 && conditions.length === 0) {
|
|
243
257
|
// If no deps we can safely execute immediately
|
|
244
258
|
return codeToRun;
|
|
245
259
|
}
|
|
246
|
-
let params = [JSON.stringify(this.bundle.publicId), (0, _helpers.fnExpr)(this.bundle.env, [], [codeToRun]), JSON.stringify(deps)];
|
|
260
|
+
let params = [JSON.stringify(this.bundle.publicId), (0, _helpers.fnExpr)(this.bundle.env, [], [codeToRun]), `${JSON.stringify(deps)}${conditions.length > 0 ? `.concat([${conditions.map(conditions => `...${conditions}`).join(',')}])` : ''}`];
|
|
247
261
|
return `$parcel$global.rwr(${params.join(', ')});`;
|
|
248
262
|
}
|
|
249
263
|
async loadAssets() {
|
|
@@ -574,14 +588,6 @@ ${code}
|
|
|
574
588
|
this.externalAssets.add(resolved);
|
|
575
589
|
continue;
|
|
576
590
|
}
|
|
577
|
-
|
|
578
|
-
// If the referencedBundle is a native node import then require it
|
|
579
|
-
// directly
|
|
580
|
-
// Only enabled for internal builds for now
|
|
581
|
-
if (process.env.ATLASPACK_SUPER_BUILD === 'true' && referencedBundle && referencedBundle.type === 'node') {
|
|
582
|
-
replacements.set((0, _nullthrows().default)(dep.symbols.get('*')).local, `require('${(0, _utils().relativeBundlePath)(this.bundle, referencedBundle)}')`);
|
|
583
|
-
continue;
|
|
584
|
-
}
|
|
585
591
|
}
|
|
586
592
|
for (let [imported, {
|
|
587
593
|
local
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/packager-js",
|
|
3
|
-
"version": "2.14.1-dev.
|
|
3
|
+
"version": "2.14.1-dev.58+304528673",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"node": ">= 16.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@atlaspack/diagnostic": "2.14.1-dev.
|
|
19
|
-
"@atlaspack/feature-flags": "2.14.1-dev.
|
|
20
|
-
"@atlaspack/plugin": "2.14.1-dev.
|
|
21
|
-
"@atlaspack/rust": "3.0.1-dev.
|
|
22
|
-
"@atlaspack/types": "2.14.1-dev.
|
|
23
|
-
"@atlaspack/utils": "2.14.1-dev.
|
|
18
|
+
"@atlaspack/diagnostic": "2.14.1-dev.58+304528673",
|
|
19
|
+
"@atlaspack/feature-flags": "2.14.1-dev.58+304528673",
|
|
20
|
+
"@atlaspack/plugin": "2.14.1-dev.58+304528673",
|
|
21
|
+
"@atlaspack/rust": "3.0.1-dev.58+304528673",
|
|
22
|
+
"@atlaspack/types": "2.14.1-dev.58+304528673",
|
|
23
|
+
"@atlaspack/utils": "2.14.1-dev.58+304528673",
|
|
24
24
|
"@parcel/source-map": "^2.1.1",
|
|
25
25
|
"globals": "^13.2.0",
|
|
26
26
|
"nullthrows": "^1.1.1"
|
|
27
27
|
},
|
|
28
28
|
"type": "commonjs",
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "304528673208007ba9e03ec6360fdf99a4945910"
|
|
30
30
|
}
|
|
@@ -149,13 +149,6 @@ export class ScopeHoistingPackager {
|
|
|
149
149
|
for (let b of this.bundleGraph.getReferencedBundles(this.bundle, {
|
|
150
150
|
recursive: false,
|
|
151
151
|
})) {
|
|
152
|
-
// If the referenced bundle is a native node bundle then don't require it as
|
|
153
|
-
// an external as we don't want to require native node bundles from other
|
|
154
|
-
// OS architectures
|
|
155
|
-
if (process.env.ATLASPACK_SUPER_BUILD === 'true' && b.type === 'node') {
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
152
|
this.externals.set(relativeBundlePath(this.bundle, b), new Map());
|
|
160
153
|
}
|
|
161
154
|
}
|
|
@@ -286,6 +279,19 @@ export class ScopeHoistingPackager {
|
|
|
286
279
|
let referencingBundles = this.bundleGraph.getReferencingBundles(bundle);
|
|
287
280
|
let hasHtmlReference = referencingBundles.some((b) => b.type === 'html');
|
|
288
281
|
|
|
282
|
+
let hasConditionalReference = false;
|
|
283
|
+
let isConditionalBundle = false;
|
|
284
|
+
if (
|
|
285
|
+
getFeatureFlag('conditionalBundlingApi') &&
|
|
286
|
+
getFeatureFlag('conditionalBundlingAsyncRuntime')
|
|
287
|
+
) {
|
|
288
|
+
// If the bundle has a conditional bundle reference (has an importCond)
|
|
289
|
+
hasConditionalReference =
|
|
290
|
+
this.bundleGraph.getReferencedConditionalBundles(bundle).length > 0;
|
|
291
|
+
// If the bundle is a conditional bundle
|
|
292
|
+
isConditionalBundle = this.hasConditionalDependency();
|
|
293
|
+
}
|
|
294
|
+
|
|
289
295
|
return (
|
|
290
296
|
this.useAsyncBundleRuntime &&
|
|
291
297
|
bundle.type === 'js' &&
|
|
@@ -293,7 +299,7 @@ export class ScopeHoistingPackager {
|
|
|
293
299
|
bundle.env.outputFormat === 'esmodule' &&
|
|
294
300
|
!bundle.env.isIsolated() &&
|
|
295
301
|
bundle.bundleBehavior !== 'isolated' &&
|
|
296
|
-
hasHtmlReference
|
|
302
|
+
(hasHtmlReference || hasConditionalReference || isConditionalBundle)
|
|
297
303
|
);
|
|
298
304
|
}
|
|
299
305
|
|
|
@@ -303,7 +309,32 @@ export class ScopeHoistingPackager {
|
|
|
303
309
|
.filter((b) => this.shouldBundleQueue(b))
|
|
304
310
|
.map((b) => b.publicId);
|
|
305
311
|
|
|
306
|
-
|
|
312
|
+
const conditions = [];
|
|
313
|
+
if (
|
|
314
|
+
getFeatureFlag('conditionalBundlingApi') &&
|
|
315
|
+
getFeatureFlag('conditionalBundlingAsyncRuntime')
|
|
316
|
+
) {
|
|
317
|
+
const conditionSet = this.bundleGraph
|
|
318
|
+
.getConditionalBundleMapping()
|
|
319
|
+
.get(bundle.id);
|
|
320
|
+
|
|
321
|
+
for (const [
|
|
322
|
+
key,
|
|
323
|
+
{ifTrueBundles, ifFalseBundles},
|
|
324
|
+
] of conditionSet?.entries() ?? []) {
|
|
325
|
+
const ifTrueBundleIds = ifTrueBundles
|
|
326
|
+
.map((b) => `"${b.publicId}"`)
|
|
327
|
+
.join(',');
|
|
328
|
+
const ifFalseBundleIds = ifFalseBundles
|
|
329
|
+
.map((b) => `"${b.publicId}"`)
|
|
330
|
+
.join(',');
|
|
331
|
+
conditions.push(
|
|
332
|
+
`(globalThis.__MCOND && globalThis.__MCOND('${key}') ? [${ifTrueBundleIds}] : [${ifFalseBundleIds}])`,
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (deps.length === 0 && conditions.length === 0) {
|
|
307
338
|
// If no deps we can safely execute immediately
|
|
308
339
|
return codeToRun;
|
|
309
340
|
}
|
|
@@ -311,7 +342,13 @@ export class ScopeHoistingPackager {
|
|
|
311
342
|
let params = [
|
|
312
343
|
JSON.stringify(this.bundle.publicId),
|
|
313
344
|
fnExpr(this.bundle.env, [], [codeToRun]),
|
|
314
|
-
JSON.stringify(deps)
|
|
345
|
+
`${JSON.stringify(deps)}${
|
|
346
|
+
conditions.length > 0
|
|
347
|
+
? `.concat([${conditions
|
|
348
|
+
.map((conditions) => `...${conditions}`)
|
|
349
|
+
.join(',')}])`
|
|
350
|
+
: ''
|
|
351
|
+
}`,
|
|
315
352
|
];
|
|
316
353
|
|
|
317
354
|
return `$parcel$global.rwr(${params.join(', ')});`;
|
|
@@ -772,21 +809,6 @@ ${code}
|
|
|
772
809
|
this.externalAssets.add(resolved);
|
|
773
810
|
continue;
|
|
774
811
|
}
|
|
775
|
-
|
|
776
|
-
// If the referencedBundle is a native node import then require it
|
|
777
|
-
// directly
|
|
778
|
-
// Only enabled for internal builds for now
|
|
779
|
-
if (
|
|
780
|
-
process.env.ATLASPACK_SUPER_BUILD === 'true' &&
|
|
781
|
-
referencedBundle &&
|
|
782
|
-
referencedBundle.type === 'node'
|
|
783
|
-
) {
|
|
784
|
-
replacements.set(
|
|
785
|
-
nullthrows(dep.symbols.get('*')).local,
|
|
786
|
-
`require('${relativeBundlePath(this.bundle, referencedBundle)}')`,
|
|
787
|
-
);
|
|
788
|
-
continue;
|
|
789
|
-
}
|
|
790
812
|
}
|
|
791
813
|
|
|
792
814
|
for (let [imported, {local}] of dep.symbols) {
|