@atlaspack/packager-js 2.14.5-canary.9 → 2.14.5-dev.14

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,16 @@
1
1
  # @atlaspack/packager-js
2
2
 
3
+ ## 2.14.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`11d6f16`](https://github.com/atlassian-labs/atlaspack/commit/11d6f16b6397dee2f217167e5c98b39edb63f7a7), [`e2ba0f6`](https://github.com/atlassian-labs/atlaspack/commit/e2ba0f69702656f3d1ce95ab1454e35062b13b39), [`d2c50c2`](https://github.com/atlassian-labs/atlaspack/commit/d2c50c2c020888b33bb25b8690d9320c2b69e2a6), [`46a90dc`](https://github.com/atlassian-labs/atlaspack/commit/46a90dccd019a26b222c878a92d23acc75dc67c5)]:
8
+ - @atlaspack/feature-flags@2.14.3
9
+ - @atlaspack/rust@3.3.0
10
+ - @atlaspack/utils@2.14.5
11
+ - @atlaspack/types@2.14.5
12
+ - @atlaspack/plugin@2.14.5
13
+
3
14
  ## 2.14.4
4
15
 
5
16
  ### Patch Changes
@@ -60,6 +60,13 @@ function _featureFlags() {
60
60
  };
61
61
  return data;
62
62
  }
63
+ function _buildCache() {
64
+ const data = require("@atlaspack/build-cache");
65
+ _buildCache = function () {
66
+ return data;
67
+ };
68
+ return data;
69
+ }
63
70
  var _ESMOutputFormat = require("./ESMOutputFormat");
64
71
  var _CJSOutputFormat = require("./CJSOutputFormat");
65
72
  var _GlobalOutputFormat = require("./GlobalOutputFormat");
@@ -89,6 +96,7 @@ const OUTPUT_FORMATS = {
89
96
  commonjs: _CJSOutputFormat.CJSOutputFormat,
90
97
  global: _GlobalOutputFormat.GlobalOutputFormat
91
98
  };
99
+ const bundleDirectReferences = (0, _buildCache().createBuildCache)();
92
100
  class ScopeHoistingPackager {
93
101
  exportedSymbols = new Map();
94
102
  externals = new Map();
@@ -265,6 +273,7 @@ class ScopeHoistingPackager {
265
273
  maxConcurrent: 32
266
274
  });
267
275
  let wrapped = [];
276
+ const referencedAssets = this.bundleGraph.getReferencedAssets(this.bundle, bundleDirectReferences);
268
277
  this.bundle.traverseAssets(asset => {
269
278
  queue.add(async () => {
270
279
  let [code, map] = await Promise.all([asset.getCode(), this.bundle.env.sourceMap ? asset.getMapBuffer() : null]);
@@ -273,7 +282,7 @@ class ScopeHoistingPackager {
273
282
  map
274
283
  }];
275
284
  });
276
- if (asset.meta.shouldWrap || this.bundle.env.sourceType === 'script' || this.bundleGraph.isAssetReferenced(this.bundle, asset) || this.bundleGraph.getIncomingDependencies(asset).some(dep => dep.meta.shouldWrap && dep.specifierType !== 'url')) {
285
+ if (asset.meta.shouldWrap || this.bundle.env.sourceType === 'script' || referencedAssets.has(asset.id) || this.bundleGraph.getIncomingDependencies(asset).some(dep => dep.meta.shouldWrap && dep.specifierType !== 'url')) {
277
286
  // Don't wrap constant "entry" modules _except_ if they are referenced by any lazy dependency
278
287
  if (!asset.meta.isConstantModule || this.bundleGraph.getIncomingDependencies(asset).some(dep => dep.priority === 'lazy')) {
279
288
  this.wrappedAssets.add(asset.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/packager-js",
3
- "version": "2.14.5-canary.9+4c1714103",
3
+ "version": "2.14.5-dev.14+8c369e38c",
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-canary.77+4c1714103",
19
- "@atlaspack/feature-flags": "2.14.1-canary.77+4c1714103",
20
- "@atlaspack/plugin": "2.14.5-canary.9+4c1714103",
21
- "@atlaspack/rust": "3.2.1-canary.9+4c1714103",
22
- "@atlaspack/types": "2.14.5-canary.9+4c1714103",
23
- "@atlaspack/utils": "2.14.5-canary.9+4c1714103",
18
+ "@atlaspack/diagnostic": "2.14.1-dev.82+8c369e38c",
19
+ "@atlaspack/feature-flags": "2.14.1-dev.82+8c369e38c",
20
+ "@atlaspack/plugin": "2.14.5-dev.14+8c369e38c",
21
+ "@atlaspack/rust": "3.2.1-dev.14+8c369e38c",
22
+ "@atlaspack/types": "2.14.5-dev.14+8c369e38c",
23
+ "@atlaspack/utils": "2.14.5-dev.14+8c369e38c",
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": "4c1714103dab2aa9039c488f381551d2b65d1d01"
29
+ "gitHead": "8c369e38ccd428409811114aebd6044c27f90705"
30
30
  }
@@ -25,6 +25,7 @@ import ThrowableDiagnostic, {
25
25
  import globals from 'globals';
26
26
  import path from 'path';
27
27
  import {getFeatureFlag} from '@atlaspack/feature-flags';
28
+ import {createBuildCache} from '@atlaspack/build-cache';
28
29
 
29
30
  import {ESMOutputFormat} from './ESMOutputFormat';
30
31
  import {CJSOutputFormat} from './CJSOutputFormat';
@@ -75,6 +76,8 @@ export interface OutputFormat {
75
76
  buildBundlePostlude(): [string, number];
76
77
  }
77
78
 
79
+ const bundleDirectReferences = createBuildCache();
80
+
78
81
  export class ScopeHoistingPackager {
79
82
  options: PluginOptions;
80
83
  bundleGraph: BundleGraph<NamedBundle>;
@@ -357,6 +360,12 @@ export class ScopeHoistingPackager {
357
360
  async loadAssets(): Promise<Array<Asset>> {
358
361
  let queue = new PromiseQueue({maxConcurrent: 32});
359
362
  let wrapped = [];
363
+
364
+ const referencedAssets = this.bundleGraph.getReferencedAssets(
365
+ this.bundle,
366
+ bundleDirectReferences,
367
+ );
368
+
360
369
  this.bundle.traverseAssets((asset) => {
361
370
  queue.add(async () => {
362
371
  let [code, map] = await Promise.all([
@@ -369,7 +378,7 @@ export class ScopeHoistingPackager {
369
378
  if (
370
379
  asset.meta.shouldWrap ||
371
380
  this.bundle.env.sourceType === 'script' ||
372
- this.bundleGraph.isAssetReferenced(this.bundle, asset) ||
381
+ referencedAssets.has(asset.id) ||
373
382
  this.bundleGraph
374
383
  .getIncomingDependencies(asset)
375
384
  .some((dep) => dep.meta.shouldWrap && dep.specifierType !== 'url')