@atlaspack/core 2.32.0 → 2.33.0

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/BundleGraph.js +78 -8
  3. package/dist/atlaspack-v3/AtlaspackV3.js +7 -4
  4. package/dist/atlaspack-v3/worker/worker.js +1 -0
  5. package/dist/requests/AtlaspackBuildRequest.js +12 -5
  6. package/dist/requests/BundleGraphRequest.js +15 -78
  7. package/dist/requests/BundleGraphRequestRust.js +320 -0
  8. package/dist/requests/BundleGraphRequestUtils.js +131 -0
  9. package/dist/requests/PackageRequest.js +27 -10
  10. package/lib/BundleGraph.js +85 -8
  11. package/lib/atlaspack-v3/AtlaspackV3.js +9 -4
  12. package/lib/atlaspack-v3/worker/worker.js +2 -1
  13. package/lib/requests/AtlaspackBuildRequest.js +6 -1
  14. package/lib/requests/BundleGraphRequest.js +15 -87
  15. package/lib/requests/BundleGraphRequestRust.js +378 -0
  16. package/lib/requests/BundleGraphRequestUtils.js +151 -0
  17. package/lib/requests/PackageRequest.js +38 -10
  18. package/lib/types/BundleGraph.d.ts +34 -4
  19. package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +4 -1
  20. package/lib/types/atlaspack-v3/worker/worker.d.ts +1 -0
  21. package/lib/types/requests/BundleGraphRequestRust.d.ts +34 -0
  22. package/lib/types/requests/BundleGraphRequestUtils.d.ts +31 -0
  23. package/package.json +15 -15
  24. package/src/BundleGraph.ts +83 -8
  25. package/src/atlaspack-v3/AtlaspackV3.ts +17 -5
  26. package/src/atlaspack-v3/worker/worker.ts +1 -0
  27. package/src/requests/AtlaspackBuildRequest.ts +13 -5
  28. package/src/requests/BundleGraphRequest.ts +25 -100
  29. package/src/requests/BundleGraphRequestRust.ts +464 -0
  30. package/src/requests/BundleGraphRequestUtils.ts +167 -0
  31. package/src/requests/PackageRequest.ts +20 -5
  32. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,55 @@
1
1
  # @atlaspack/core
2
2
 
3
+ ## 2.33.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#993](https://github.com/atlassian-labs/atlaspack/pull/993) [`e058f0e`](https://github.com/atlassian-labs/atlaspack/commit/e058f0e7a0423ba9373e85a7dbd5c1dd43b47916) Thanks [@matt-koko](https://github.com/matt-koko)! - Add disableCache option to TransformerSetup API
8
+
9
+ ### Patch Changes
10
+
11
+ - [#998](https://github.com/atlassian-labs/atlaspack/pull/998) [`349b19c`](https://github.com/atlassian-labs/atlaspack/commit/349b19c3aca2ccb1ffb5cdcdc74890f4b62228be) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Add initial native bundler boilerplate and single file bundler
12
+
13
+ - Updated dependencies [[`e058f0e`](https://github.com/atlassian-labs/atlaspack/commit/e058f0e7a0423ba9373e85a7dbd5c1dd43b47916), [`053e375`](https://github.com/atlassian-labs/atlaspack/commit/053e3754c08c5b5dc239e9f7267df289cbbf31ab), [`25c976e`](https://github.com/atlassian-labs/atlaspack/commit/25c976e01c30e536fb1027eab5b17594c604efff), [`1a86b65`](https://github.com/atlassian-labs/atlaspack/commit/1a86b657868ee881ca5acc68661cca208ac37779), [`349b19c`](https://github.com/atlassian-labs/atlaspack/commit/349b19c3aca2ccb1ffb5cdcdc74890f4b62228be), [`9959efe`](https://github.com/atlassian-labs/atlaspack/commit/9959efe30699a2de3b69275be7ecb47afe81c0b6)]:
14
+ - @atlaspack/rust@3.22.0
15
+ - @atlaspack/feature-flags@2.29.0
16
+ - @atlaspack/fs@2.15.47
17
+ - @atlaspack/graph@3.6.14
18
+ - @atlaspack/logger@2.14.44
19
+ - @atlaspack/plugin@2.14.52
20
+ - @atlaspack/profiler@2.15.13
21
+ - @atlaspack/types@2.15.42
22
+ - @atlaspack/utils@3.3.4
23
+ - @atlaspack/workers@2.14.52
24
+ - @atlaspack/cache@3.2.47
25
+ - @atlaspack/source-map@3.2.7
26
+ - @atlaspack/build-cache@2.13.10
27
+ - @atlaspack/package-manager@2.14.52
28
+
29
+ ## 2.32.1
30
+
31
+ ### Patch Changes
32
+
33
+ - [#988](https://github.com/atlassian-labs/atlaspack/pull/988) [`a631dcd`](https://github.com/atlassian-labs/atlaspack/commit/a631dcd961112db072b0f8de0831efd178f355a7) Thanks [@marcins](https://github.com/marcins)! - Implement a basic package() method for the native packager
34
+
35
+ - [#990](https://github.com/atlassian-labs/atlaspack/pull/990) [`5755a11`](https://github.com/atlassian-labs/atlaspack/commit/5755a114903bbf660e2ada3ae2e7ff6ceac7565b) Thanks [@vykimnguyen](https://github.com/vykimnguyen)! - changes conditional bundleGraphEdgeType value
36
+
37
+ - [#987](https://github.com/atlassian-labs/atlaspack/pull/987) [`fcaf517`](https://github.com/atlassian-labs/atlaspack/commit/fcaf517010d15c9300393bcad3f9b465689d9d16) Thanks [@vykimnguyen](https://github.com/vykimnguyen)! - add get_bundle_assets
38
+
39
+ - Updated dependencies [[`a631dcd`](https://github.com/atlassian-labs/atlaspack/commit/a631dcd961112db072b0f8de0831efd178f355a7), [`e9dce31`](https://github.com/atlassian-labs/atlaspack/commit/e9dce3168a8e6727a994bf2a6ac6041eb29f6027), [`59e1345`](https://github.com/atlassian-labs/atlaspack/commit/59e1345f84f43e0632d434ab42c06bf748241985), [`783118c`](https://github.com/atlassian-labs/atlaspack/commit/783118c772f45a0cf6a3b6b447fb9a0e225b25a6), [`fcaf517`](https://github.com/atlassian-labs/atlaspack/commit/fcaf517010d15c9300393bcad3f9b465689d9d16)]:
40
+ - @atlaspack/rust@3.21.0
41
+ - @atlaspack/cache@3.2.46
42
+ - @atlaspack/fs@2.15.46
43
+ - @atlaspack/logger@2.14.43
44
+ - @atlaspack/source-map@3.2.6
45
+ - @atlaspack/utils@3.3.3
46
+ - @atlaspack/package-manager@2.14.51
47
+ - @atlaspack/profiler@2.15.12
48
+ - @atlaspack/workers@2.14.51
49
+ - @atlaspack/types@2.15.41
50
+ - @atlaspack/graph@3.6.13
51
+ - @atlaspack/plugin@2.14.51
52
+
3
53
  ## 2.32.0
4
54
 
5
55
  ### Minor Changes
@@ -43,7 +43,7 @@ exports.bundleGraphEdgeTypes = {
43
43
  internal_async: 5,
44
44
  // This type is used to mark an edge between a bundle and a conditional bundle.
45
45
  // This allows efficient discovery of conditional bundles in packaging
46
- conditional: 5,
46
+ conditional: 6,
47
47
  };
48
48
  function makeReadOnlySet(set) {
49
49
  return new Proxy(set, {
@@ -383,7 +383,7 @@ class BundleGraph {
383
383
  }
384
384
  /**
385
385
  * Serialize the bundle graph for efficient transfer to native Rust code.
386
- * Returns a JSON string of nodes and an array of edges.
386
+ * Returns a JSON string of nodes, an array of edges, and a map of asset IDs to public IDs.
387
387
  */
388
388
  serializeForNative() {
389
389
  const start = performance.now();
@@ -396,16 +396,58 @@ class BundleGraph {
396
396
  edges.push([edge.from, edge.to, edge.type]);
397
397
  next = edgeIterator.next();
398
398
  }
399
+ // Extract and deduplicate environments
400
+ const environmentMap = new Map();
401
+ const extractEnvironment = (envRef) => {
402
+ const env = (0, EnvironmentManager_1.fromEnvironmentId)(envRef);
403
+ const envId = env.id;
404
+ if (!environmentMap.has(envId)) {
405
+ environmentMap.set(envId, env);
406
+ }
407
+ return envId;
408
+ };
409
+ // Replace env objects with env IDs in nodes
410
+ const processedNodes = nodes.map((node) => {
411
+ const processedNode = { ...node };
412
+ if (node.type === 'asset' && node.value?.env) {
413
+ processedNode.value = {
414
+ ...node.value,
415
+ env: extractEnvironment(node.value.env),
416
+ };
417
+ }
418
+ else if (node.type === 'dependency' && node.value?.env) {
419
+ processedNode.value = {
420
+ ...node.value,
421
+ env: extractEnvironment(node.value.env),
422
+ };
423
+ }
424
+ else if (node.type === 'bundle' && node.value?.env) {
425
+ processedNode.value = {
426
+ ...node.value,
427
+ env: extractEnvironment(node.value.env),
428
+ };
429
+ }
430
+ return processedNode;
431
+ });
399
432
  // Optimize nodes by omitting null/undefined values to reduce JSON size
400
- const optimizedNodes = nodes.map((node) => this._omitNulls(node));
433
+ const optimizedNodes = processedNodes.map((node) => this._omitNulls(node));
401
434
  const nodesJson = JSON.stringify(optimizedNodes);
435
+ // Serialize environments as array
436
+ const environments = Array.from(environmentMap.values());
437
+ const environmentsJson = JSON.stringify(environments);
438
+ // Convert Map to plain object for serialization
439
+ const publicIdByAssetId = {};
440
+ for (const [assetId, publicId] of this._publicIdByAssetId) {
441
+ publicIdByAssetId[assetId] = publicId;
442
+ }
402
443
  const duration = performance.now() - start;
403
- const sizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
444
+ const nodesSizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
445
+ const envsSizeMB = (environmentsJson.length / (1024 * 1024)).toFixed(2);
404
446
  logger_1.default.verbose({
405
447
  origin: '@atlaspack/core',
406
- message: `serializeForNative: ${duration.toFixed(1)}ms, ${sizeMB}MB JSON, ${nodes.length} nodes, ${edges.length} edges`,
448
+ message: `serializeForNative: ${duration.toFixed(1)}ms, ${nodesSizeMB}MB nodes, ${envsSizeMB}MB envs (${environmentMap.size} unique), ${nodes.length} nodes, ${edges.length} edges`,
407
449
  });
408
- return { nodesJson, edges };
450
+ return { nodesJson, edges, publicIdByAssetId, environmentsJson };
409
451
  }
410
452
  /**
411
453
  * Remove null and undefined values from an object to reduce JSON size.
@@ -1164,8 +1206,36 @@ class BundleGraph {
1164
1206
  });
1165
1207
  }
1166
1208
  /**
1167
- * TODO: Document why this works like this & why visitor order matters
1168
- * on these use-cases.
1209
+ * Performs a depth-first traversal of all assets and dependencies contained
1210
+ * within a bundle. Only visits nodes that are directly contained in the bundle
1211
+ * (connected via a `contains` edge).
1212
+ *
1213
+ * Entry Asset Ordering:
1214
+ * The traversal guarantees that entry assets are visited in the exact order they
1215
+ * appear in `bundle.entryAssetIds`. This ordering is critical for several reasons:
1216
+ *
1217
+ * 1. **Code Execution Order in Packagers**: Packagers (ScopeHoistingPackager,
1218
+ * DevPackager) use this traversal to concatenate assets into the final bundle.
1219
+ * The traversal order determines the execution order of code in the output.
1220
+ * Entry assets must be processed in their defined order to ensure correct
1221
+ * initialization sequences.
1222
+ *
1223
+ * 2. **Runtime Injection**: Runtime assets (HMR, bundle manifests) are prepended
1224
+ * to `entryAssetIds` via `unshift()` in `applyRuntimes.ts`. By honoring the
1225
+ * array order, runtimes are guaranteed to be visited (and thus output) before
1226
+ * application entry points, ensuring the runtime infrastructure is available
1227
+ * when application code executes.
1228
+ *
1229
+ * 3. **Deterministic Builds**: Consistent traversal order ensures reproducible
1230
+ * bundle output, which is essential for caching and build verification.
1231
+ *
1232
+ * The sorting only applies at the first traversal level (direct children of the
1233
+ * start node). Subsequent levels follow standard DFS order based on the graph's
1234
+ * edge structure.
1235
+ *
1236
+ * @param bundle - The bundle to traverse
1237
+ * @param visit - Visitor callback receiving asset or dependency nodes
1238
+ * @param startAsset - Optional asset to start traversal from (defaults to bundle root)
1169
1239
  */
1170
1240
  traverseBundle(bundle, visit, startAsset) {
1171
1241
  let entries = !startAsset;
@@ -51,12 +51,15 @@ class AtlaspackV3 {
51
51
  buildAssetGraph() {
52
52
  return (0, rust_1.atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
53
53
  }
54
+ buildBundleGraph() {
55
+ return (0, rust_1.atlaspackNapiBuildBundleGraph)(this._atlaspack_napi);
56
+ }
54
57
  loadBundleGraph(bundleGraph) {
55
- const { nodesJson, edges } = bundleGraph.serializeForNative();
56
- return (0, rust_1.atlaspackNapiLoadBundleGraph)(this._atlaspack_napi, nodesJson, edges);
58
+ const { nodesJson, edges, publicIdByAssetId, environmentsJson } = bundleGraph.serializeForNative();
59
+ return (0, rust_1.atlaspackNapiLoadBundleGraph)(this._atlaspack_napi, nodesJson, edges, publicIdByAssetId, environmentsJson);
57
60
  }
58
- package() {
59
- return (0, rust_1.atlaspackNapiPackage)(this._atlaspack_napi);
61
+ package(bundleId) {
62
+ return (0, rust_1.atlaspackNapiPackage)(this._atlaspack_napi, bundleId);
60
63
  }
61
64
  async respondToFsEvents(events) {
62
65
  // @ts-expect-error TS2488
@@ -355,6 +355,7 @@ class AtlaspackWorker {
355
355
  conditions: setupResult?.conditions,
356
356
  config,
357
357
  env: allowedEnv,
358
+ disableCache: setupResult?.disableCache,
358
359
  };
359
360
  }
360
361
  __classPrivateFieldGet(this, _AtlaspackWorker_transformers, "f").set(specifier, {
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = createAtlaspackBuildRequest;
7
7
  const BundleGraphRequest_1 = __importDefault(require("./BundleGraphRequest"));
8
+ const BundleGraphRequestRust_1 = __importDefault(require("./BundleGraphRequestRust"));
8
9
  const WriteBundlesRequest_1 = __importDefault(require("./WriteBundlesRequest"));
9
10
  const utils_1 = require("../utils");
10
11
  const dumpGraphToGraphViz_1 = __importDefault(require("../dumpGraphToGraphViz"));
@@ -27,11 +28,17 @@ function createAtlaspackBuildRequest(input) {
27
28
  }
28
29
  async function run({ input, api, options, rustAtlaspack, }) {
29
30
  let { optionsRef, requestedAssetIds, signal } = input;
30
- let bundleGraphRequest = (0, BundleGraphRequest_1.default)({
31
- optionsRef,
32
- requestedAssetIds,
33
- signal,
34
- });
31
+ let bundleGraphRequest = (0, feature_flags_1.getFeatureFlag)('nativeBundling') && rustAtlaspack
32
+ ? (0, BundleGraphRequestRust_1.default)({
33
+ optionsRef,
34
+ requestedAssetIds,
35
+ signal,
36
+ })
37
+ : (0, BundleGraphRequest_1.default)({
38
+ optionsRef,
39
+ requestedAssetIds,
40
+ signal,
41
+ });
35
42
  let { bundleGraph, changedAssets, assetRequests } = await api.runRequest(bundleGraphRequest, {
36
43
  force: Boolean(rustAtlaspack) ||
37
44
  (options.shouldBuildLazily && requestedAssetIds.size > 0),
@@ -39,28 +39,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.default = createBundleGraphRequest;
40
40
  const fs_1 = __importDefault(require("fs"));
41
41
  const assert_1 = __importDefault(require("assert"));
42
- const assert_2 = __importDefault(require("assert"));
43
42
  const nullthrows_1 = __importDefault(require("nullthrows"));
44
43
  const logger_1 = require("@atlaspack/logger");
45
44
  const feature_flags_1 = require("@atlaspack/feature-flags");
46
45
  const diagnostic_1 = __importStar(require("@atlaspack/diagnostic"));
47
- const BundleGraph_1 = __importDefault(require("../public/BundleGraph"));
48
- const BundleGraph_2 = __importStar(require("../BundleGraph"));
46
+ const BundleGraph_1 = __importStar(require("../BundleGraph"));
49
47
  const MutableBundleGraph_1 = __importDefault(require("../public/MutableBundleGraph"));
50
- const Bundle_1 = require("../public/Bundle");
51
48
  const ReporterRunner_1 = require("../ReporterRunner");
52
49
  const dumpGraphToGraphViz_1 = __importDefault(require("../dumpGraphToGraphViz"));
53
- const utils_1 = require("@atlaspack/utils");
54
50
  const rust_1 = require("@atlaspack/rust");
55
51
  const PluginOptions_1 = __importDefault(require("../public/PluginOptions"));
56
52
  const applyRuntimes_1 = __importDefault(require("../applyRuntimes"));
57
53
  const constants_1 = require("../constants");
58
- const utils_2 = require("../utils");
54
+ const utils_1 = require("../utils");
59
55
  const AtlaspackConfigRequest_1 = __importStar(require("./AtlaspackConfigRequest"));
60
56
  const DevDepRequest_1 = require("./DevDepRequest");
61
- const InternalConfig_1 = require("../InternalConfig");
62
- const ConfigRequest_1 = require("./ConfigRequest");
63
57
  const projectPath_1 = require("../projectPath");
58
+ const BundleGraphRequestUtils_1 = require("./BundleGraphRequestUtils");
64
59
  const AssetGraphRequest_1 = __importDefault(require("./AssetGraphRequest"));
65
60
  const AssetGraphRequestRust_1 = require("./AssetGraphRequestRust");
66
61
  const profiler_1 = require("@atlaspack/profiler");
@@ -151,7 +146,7 @@ function createBundleGraphRequest(input) {
151
146
  // );
152
147
  // }
153
148
  measurement && measurement.end();
154
- (0, utils_2.assertSignalNotAborted)(signal);
149
+ (0, utils_1.assertSignalNotAborted)(signal);
155
150
  // If any subrequests are invalid (e.g. dev dep requests or config requests),
156
151
  // bail on incremental bundling. We also need to invalidate for option changes,
157
152
  // which are hoisted to direct invalidations on the bundle graph request.
@@ -164,7 +159,7 @@ function createBundleGraphRequest(input) {
164
159
  assetGraph.setNeedsBundling();
165
160
  }
166
161
  let configResult = (0, nullthrows_1.default)(await input.api.runRequest((0, AtlaspackConfigRequest_1.default)()));
167
- (0, utils_2.assertSignalNotAborted)(signal);
162
+ (0, utils_1.assertSignalNotAborted)(signal);
168
163
  let atlaspackConfig = (0, AtlaspackConfigRequest_1.getCachedAtlaspackConfig)(configResult, input.options);
169
164
  let { devDeps, invalidDevDeps } = await (0, DevDepRequest_1.getDevDepRequests)(input.api);
170
165
  (0, DevDepRequest_1.invalidateDevDeps)(invalidDevDeps, input.options, atlaspackConfig);
@@ -181,7 +176,7 @@ function createBundleGraphRequest(input) {
181
176
  }
182
177
  await (0, dumpGraphToGraphViz_1.default)(
183
178
  // @ts-expect-error TS2345
184
- res.bundleGraph._graph, 'BundleGraph', BundleGraph_2.bundleGraphEdgeTypes);
179
+ res.bundleGraph._graph, 'BundleGraph', BundleGraph_1.bundleGraphEdgeTypes);
185
180
  return res;
186
181
  },
187
182
  input,
@@ -196,7 +191,7 @@ class BundlerRunner {
196
191
  this.previousDevDeps = previousDevDeps;
197
192
  this.devDepRequests = new Map();
198
193
  this.configs = new Map();
199
- this.pluginOptions = new PluginOptions_1.default((0, utils_2.optionsProxy)(this.options, api.invalidateOnOptionChange));
194
+ this.pluginOptions = new PluginOptions_1.default((0, utils_1.optionsProxy)(this.options, api.invalidateOnOptionChange));
200
195
  if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
201
196
  const key = (0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`);
202
197
  this.cacheKey = `BundleGraph/${constants_1.ATLASPACK_VERSION}/${options.mode}/${key}`;
@@ -220,23 +215,10 @@ class BundlerRunner {
220
215
  }
221
216
  }
222
217
  async loadConfig(plugin) {
223
- let config = (0, InternalConfig_1.createConfig)({
224
- plugin: plugin.name,
225
- searchPath: (0, projectPath_1.toProjectPathUnsafe)('index'),
226
- });
227
- await (0, ConfigRequest_1.loadPluginConfig)(plugin, config, this.options);
228
- await (0, ConfigRequest_1.runConfigRequest)(this.api, config);
229
- for (let devDep of config.devDeps) {
230
- let devDepRequest = await (0, DevDepRequest_1.createDevDependency)(devDep, this.previousDevDeps, this.options);
231
- await this.runDevDepRequest(devDepRequest);
232
- }
233
- this.configs.set(plugin.name, config);
218
+ await (0, BundleGraphRequestUtils_1.loadPluginConfigWithDevDeps)(plugin, this.options, this.api, this.previousDevDeps, this.devDepRequests, this.configs);
234
219
  }
235
220
  async runDevDepRequest(devDepRequest) {
236
- let { specifier, resolveFrom } = devDepRequest;
237
- let key = `${specifier}:${(0, projectPath_1.fromProjectPathRelative)(resolveFrom)}`;
238
- this.devDepRequests.set(key, devDepRequest);
239
- await (0, DevDepRequest_1.runDevDepRequest)(this.api, devDepRequest);
221
+ await (0, BundleGraphRequestUtils_1.runDevDepRequest)(this.api, devDepRequest, this.devDepRequests);
240
222
  }
241
223
  async bundle({ graph, changedAssets, assetRequests, }) {
242
224
  (0, ReporterRunner_1.report)({
@@ -271,11 +253,11 @@ class BundlerRunner {
271
253
  }
272
254
  }
273
255
  else {
274
- internalBundleGraph = BundleGraph_2.default.fromAssetGraph(graph, this.options.mode === 'production');
256
+ internalBundleGraph = BundleGraph_1.default.fromAssetGraph(graph, this.options.mode === 'production');
275
257
  (0, assert_1.default)(internalBundleGraph != null); // ensures the graph was created
276
258
  await (0, dumpGraphToGraphViz_1.default)(
277
259
  // @ts-expect-error TS2345
278
- internalBundleGraph._graph, 'before_bundle', BundleGraph_2.bundleGraphEdgeTypes);
260
+ internalBundleGraph._graph, 'before_bundle', BundleGraph_1.bundleGraphEdgeTypes);
279
261
  let mutableBundleGraph = new MutableBundleGraph_1.default(internalBundleGraph, this.options);
280
262
  let measurement;
281
263
  let measurementFilename;
@@ -350,7 +332,7 @@ class BundlerRunner {
350
332
  if (internalBundleGraph != null) {
351
333
  await (0, dumpGraphToGraphViz_1.default)(
352
334
  // @ts-expect-error TS2345
353
- internalBundleGraph._graph, 'after_bundle', BundleGraph_2.bundleGraphEdgeTypes);
335
+ internalBundleGraph._graph, 'after_bundle', BundleGraph_1.bundleGraphEdgeTypes);
354
336
  }
355
337
  }
356
338
  let changedRuntimes = new Map();
@@ -359,7 +341,7 @@ class BundlerRunner {
359
341
  // inline bundles must still be named so the PackagerRunner
360
342
  // can match them to the correct packager/optimizer plugins.
361
343
  let bundles = internalBundleGraph.getBundles({ includeInline: true });
362
- await Promise.all(bundles.map((bundle) => this.nameBundle(namers, bundle, internalBundleGraph)));
344
+ await Promise.all(bundles.map((bundle) => (0, BundleGraphRequestUtils_1.nameBundle)(namers, bundle, internalBundleGraph, this.options, this.pluginOptions, this.configs)));
363
345
  changedRuntimes = await (0, logger_1.instrumentAsync)('applyRuntimes', () => (0, applyRuntimes_1.default)({
364
346
  bundleGraph: internalBundleGraph,
365
347
  api: this.api,
@@ -379,13 +361,13 @@ class BundlerRunner {
379
361
  }, this.previousDevDeps, this.options);
380
362
  await this.runDevDepRequest(devDepRequest);
381
363
  }
382
- this.validateBundles(internalBundleGraph);
364
+ (0, BundleGraphRequestUtils_1.validateBundles)(internalBundleGraph);
383
365
  // Pre-compute the hashes for each bundle so they are only computed once and shared between workers.
384
366
  internalBundleGraph.getBundleGraphHash();
385
367
  }
386
368
  await (0, dumpGraphToGraphViz_1.default)(
387
369
  // @ts-expect-error TS2345
388
- internalBundleGraph._graph, 'after_runtimes', BundleGraph_2.bundleGraphEdgeTypes);
370
+ internalBundleGraph._graph, 'after_runtimes', BundleGraph_1.bundleGraphEdgeTypes);
389
371
  this.api.storeResult({
390
372
  bundleGraph: internalBundleGraph,
391
373
  assetGraphBundlingVersion: graph.getBundlingVersion(),
@@ -399,49 +381,4 @@ class BundlerRunner {
399
381
  assetRequests,
400
382
  };
401
383
  }
402
- validateBundles(bundleGraph) {
403
- let bundles = bundleGraph.getBundles();
404
- let bundleNames = bundles.map((b) => (0, projectPath_1.joinProjectPath)(b.target.distDir, (0, nullthrows_1.default)(b.name)));
405
- assert_2.default.deepEqual(bundleNames, (0, utils_1.unique)(bundleNames), 'Bundles must have unique name. Conflicting names: ' +
406
- [
407
- ...(0, utils_1.setSymmetricDifference)(new Set(bundleNames), new Set((0, utils_1.unique)(bundleNames))),
408
- ].join());
409
- }
410
- async nameBundle(namers, internalBundle, internalBundleGraph) {
411
- let bundle = Bundle_1.Bundle.get(internalBundle, internalBundleGraph, this.options);
412
- let bundleGraph = new BundleGraph_1.default(internalBundleGraph, Bundle_1.NamedBundle.get.bind(Bundle_1.NamedBundle), this.options);
413
- for (let namer of namers) {
414
- let measurement;
415
- try {
416
- measurement = profiler_1.tracer.createMeasurement(namer.name, 'namer', bundle.id);
417
- let name = await namer.plugin.name({
418
- bundle,
419
- bundleGraph,
420
- config: this.configs.get(namer.name)?.result,
421
- options: this.pluginOptions,
422
- logger: new logger_1.PluginLogger({ origin: namer.name }),
423
- tracer: new profiler_1.PluginTracer({ origin: namer.name, category: 'namer' }),
424
- });
425
- if (name != null) {
426
- internalBundle.name = name;
427
- let { hashReference } = internalBundle;
428
- internalBundle.displayName = name.includes(hashReference)
429
- ? name.replace(hashReference, '[hash]')
430
- : name;
431
- return;
432
- }
433
- }
434
- catch (e) {
435
- throw new diagnostic_1.default({
436
- diagnostic: (0, diagnostic_1.errorToDiagnostic)(e, {
437
- origin: namer.name,
438
- }),
439
- });
440
- }
441
- finally {
442
- measurement && measurement.end();
443
- }
444
- }
445
- throw new Error('Unable to name bundle');
446
- }
447
384
  }