@atlaspack/packager-js 2.14.1-dev.55 → 2.14.1-dev.76

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,21 @@
1
1
  # @atlaspack/packager-js
2
2
 
3
+ ## 2.14.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+
9
+ - [#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.
10
+ This has hopefully been fixed, so this change will force those packages to re-release.
11
+ - 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)]:
12
+ - @atlaspack/rust@3.0.1
13
+ - @atlaspack/utils@2.14.1
14
+ - @atlaspack/feature-flags@2.14.1
15
+ - @atlaspack/diagnostic@2.14.1
16
+ - @atlaspack/plugin@2.14.1
17
+ - @atlaspack/types@2.14.1
18
+
3
19
  ## 2.14.0
4
20
 
5
21
  ### 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
- 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);
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
- 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) {
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.55+f298b7f5c",
3
+ "version": "2.14.1-dev.76+5fc6dbc65",
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.55+f298b7f5c",
19
- "@atlaspack/feature-flags": "2.14.1-dev.55+f298b7f5c",
20
- "@atlaspack/plugin": "2.14.1-dev.55+f298b7f5c",
21
- "@atlaspack/rust": "3.0.1-dev.55+f298b7f5c",
22
- "@atlaspack/types": "2.14.1-dev.55+f298b7f5c",
23
- "@atlaspack/utils": "2.14.1-dev.55+f298b7f5c",
18
+ "@atlaspack/diagnostic": "2.14.1-dev.76+5fc6dbc65",
19
+ "@atlaspack/feature-flags": "2.14.1-dev.76+5fc6dbc65",
20
+ "@atlaspack/plugin": "2.14.1-dev.76+5fc6dbc65",
21
+ "@atlaspack/rust": "3.0.1-dev.76+5fc6dbc65",
22
+ "@atlaspack/types": "2.14.1-dev.76+5fc6dbc65",
23
+ "@atlaspack/utils": "2.14.1-dev.76+5fc6dbc65",
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": "f298b7f5cac438d5150790475bde0cb959b3f6a5"
29
+ "gitHead": "5fc6dbc6504a411f5dfc0c549b811d998f95ca7c"
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
- 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) {
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) {