@atlaspack/packager-js 2.14.1-canary.6 → 2.14.1-canary.61

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 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
@@ -229,15 +229,35 @@ class ScopeHoistingPackager {
229
229
  shouldBundleQueue(bundle) {
230
230
  let referencingBundles = this.bundleGraph.getReferencingBundles(bundle);
231
231
  let hasHtmlReference = referencingBundles.some(b => b.type === 'html');
232
- return this.useAsyncBundleRuntime && bundle.type === 'js' && bundle.bundleBehavior !== 'inline' && bundle.env.outputFormat === 'esmodule' && !bundle.env.isIsolated() && bundle.bundleBehavior !== 'isolated' && hasHtmlReference;
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);
233
241
  }
234
242
  runWhenReady(bundle, codeToRun) {
235
243
  let deps = this.bundleGraph.getReferencedBundles(bundle).filter(b => this.shouldBundleQueue(b)).map(b => b.publicId);
236
- if (deps.length === 0) {
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) {
237
257
  // If no deps we can safely execute immediately
238
258
  return codeToRun;
239
259
  }
240
- 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(',')}])` : ''}`];
241
261
  return `$parcel$global.rwr(${params.join(', ')});`;
242
262
  }
243
263
  async loadAssets() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/packager-js",
3
- "version": "2.14.1-canary.6+57e29c592",
3
+ "version": "2.14.1-canary.61+90150dfb6",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -12,20 +12,19 @@
12
12
  "main": "lib/index.js",
13
13
  "source": "src/index.js",
14
14
  "engines": {
15
- "atlaspack": "2.14.1-canary.6+57e29c592",
16
15
  "node": ">= 16.0.0"
17
16
  },
18
17
  "dependencies": {
19
- "@atlaspack/diagnostic": "2.14.1-canary.6+57e29c592",
20
- "@atlaspack/feature-flags": "2.14.1-canary.6+57e29c592",
21
- "@atlaspack/plugin": "2.14.1-canary.6+57e29c592",
22
- "@atlaspack/rust": "3.0.1-canary.6+57e29c592",
23
- "@atlaspack/types": "2.14.1-canary.6+57e29c592",
24
- "@atlaspack/utils": "2.14.1-canary.6+57e29c592",
18
+ "@atlaspack/diagnostic": "2.14.1-canary.61+90150dfb6",
19
+ "@atlaspack/feature-flags": "2.14.1-canary.61+90150dfb6",
20
+ "@atlaspack/plugin": "2.14.1-canary.61+90150dfb6",
21
+ "@atlaspack/rust": "3.0.1-canary.61+90150dfb6",
22
+ "@atlaspack/types": "2.14.1-canary.61+90150dfb6",
23
+ "@atlaspack/utils": "2.14.1-canary.61+90150dfb6",
25
24
  "@parcel/source-map": "^2.1.1",
26
25
  "globals": "^13.2.0",
27
26
  "nullthrows": "^1.1.1"
28
27
  },
29
28
  "type": "commonjs",
30
- "gitHead": "57e29c592cff406d084b3c676a1c899f0bb6e78f"
29
+ "gitHead": "90150dfb68236e1d1c11813108ecabd92cff9366"
31
30
  }
@@ -279,6 +279,19 @@ export class ScopeHoistingPackager {
279
279
  let referencingBundles = this.bundleGraph.getReferencingBundles(bundle);
280
280
  let hasHtmlReference = referencingBundles.some((b) => b.type === 'html');
281
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
+
282
295
  return (
283
296
  this.useAsyncBundleRuntime &&
284
297
  bundle.type === 'js' &&
@@ -286,7 +299,7 @@ export class ScopeHoistingPackager {
286
299
  bundle.env.outputFormat === 'esmodule' &&
287
300
  !bundle.env.isIsolated() &&
288
301
  bundle.bundleBehavior !== 'isolated' &&
289
- hasHtmlReference
302
+ (hasHtmlReference || hasConditionalReference || isConditionalBundle)
290
303
  );
291
304
  }
292
305
 
@@ -296,7 +309,32 @@ export class ScopeHoistingPackager {
296
309
  .filter((b) => this.shouldBundleQueue(b))
297
310
  .map((b) => b.publicId);
298
311
 
299
- if (deps.length === 0) {
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) {
300
338
  // If no deps we can safely execute immediately
301
339
  return codeToRun;
302
340
  }
@@ -304,7 +342,13 @@ export class ScopeHoistingPackager {
304
342
  let params = [
305
343
  JSON.stringify(this.bundle.publicId),
306
344
  fnExpr(this.bundle.env, [], [codeToRun]),
307
- JSON.stringify(deps),
345
+ `${JSON.stringify(deps)}${
346
+ conditions.length > 0
347
+ ? `.concat([${conditions
348
+ .map((conditions) => `...${conditions}`)
349
+ .join(',')}])`
350
+ : ''
351
+ }`,
308
352
  ];
309
353
 
310
354
  return `$parcel$global.rwr(${params.join(', ')});`;