@atlaspack/core 2.33.1 → 2.35.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 (68) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/dist/AssetGraph.js +4 -72
  3. package/dist/BundleGraph.js +34 -0
  4. package/dist/PackagerRunner.js +13 -88
  5. package/dist/RequestTracker.js +17 -80
  6. package/dist/TargetDescriptor.schema.js +3 -0
  7. package/dist/UncommittedAsset.js +0 -5
  8. package/dist/applyRuntimes.js +2 -1
  9. package/dist/atlaspack-v3/AtlaspackV3.js +6 -2
  10. package/dist/requests/AssetGraphRequest.js +6 -15
  11. package/dist/requests/AssetGraphRequestRust.js +119 -22
  12. package/dist/requests/AtlaspackBuildRequest.js +8 -2
  13. package/dist/requests/BundleGraphRequest.js +9 -15
  14. package/dist/requests/BundleGraphRequestRust.js +1 -2
  15. package/dist/requests/PackageRequest.js +1 -1
  16. package/dist/requests/TargetRequest.js +5 -0
  17. package/dist/requests/WriteBundleRequest.js +129 -12
  18. package/dist/requests/WriteBundlesRequest.js +15 -9
  19. package/dist/resolveOptions.js +2 -4
  20. package/lib/AssetGraph.js +3 -62
  21. package/lib/BundleGraph.js +38 -0
  22. package/lib/PackagerRunner.js +13 -77
  23. package/lib/RequestTracker.js +15 -69
  24. package/lib/TargetDescriptor.schema.js +3 -0
  25. package/lib/UncommittedAsset.js +0 -11
  26. package/lib/applyRuntimes.js +1 -1
  27. package/lib/atlaspack-v3/AtlaspackV3.js +6 -2
  28. package/lib/requests/AssetGraphRequest.js +4 -18
  29. package/lib/requests/AssetGraphRequestRust.js +88 -23
  30. package/lib/requests/AtlaspackBuildRequest.js +8 -2
  31. package/lib/requests/BundleGraphRequest.js +12 -16
  32. package/lib/requests/BundleGraphRequestRust.js +2 -3
  33. package/lib/requests/PackageRequest.js +3 -1
  34. package/lib/requests/TargetRequest.js +5 -0
  35. package/lib/requests/WriteBundleRequest.js +131 -8
  36. package/lib/requests/WriteBundlesRequest.js +12 -5
  37. package/lib/resolveOptions.js +2 -4
  38. package/lib/types/AssetGraph.d.ts +2 -27
  39. package/lib/types/BundleGraph.d.ts +5 -0
  40. package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +3 -2
  41. package/lib/types/requests/BundleGraphRequest.d.ts +1 -1
  42. package/lib/types/requests/WriteBundleRequest.d.ts +20 -1
  43. package/lib/types/types.d.ts +1 -0
  44. package/package.json +15 -15
  45. package/src/AssetGraph.ts +4 -72
  46. package/src/BundleGraph.ts +39 -0
  47. package/src/PackagerRunner.ts +15 -101
  48. package/src/RequestTracker.ts +24 -110
  49. package/src/TargetDescriptor.schema.ts +3 -0
  50. package/src/UncommittedAsset.ts +1 -11
  51. package/src/applyRuntimes.ts +3 -1
  52. package/src/atlaspack-v3/AtlaspackV3.ts +19 -3
  53. package/src/requests/AssetGraphRequest.ts +8 -20
  54. package/src/requests/AssetGraphRequestRust.ts +96 -23
  55. package/src/requests/AtlaspackBuildRequest.ts +16 -8
  56. package/src/requests/BundleGraphRequest.ts +12 -30
  57. package/src/requests/BundleGraphRequestRust.ts +1 -2
  58. package/src/requests/PackageRequest.ts +1 -1
  59. package/src/requests/TargetRequest.ts +5 -0
  60. package/src/requests/WriteBundleRequest.ts +177 -13
  61. package/src/requests/WriteBundlesRequest.ts +25 -13
  62. package/src/resolveOptions.ts +2 -4
  63. package/src/types.ts +1 -0
  64. package/test/AssetGraph.test.ts +0 -32
  65. package/test/RequestTracker.test.ts +0 -165
  66. package/test/TargetRequest.test.ts +25 -0
  67. package/test/requests/WriteBundleRequest.test.ts +239 -0
  68. package/tsconfig.tsbuildinfo +1 -1
@@ -58,8 +58,12 @@ class AtlaspackV3 {
58
58
  const { nodesJson, edges, publicIdByAssetId, environmentsJson } = bundleGraph.serializeForNative();
59
59
  return (0, rust_1.atlaspackNapiLoadBundleGraph)(this._atlaspack_napi, nodesJson, edges, publicIdByAssetId, environmentsJson);
60
60
  }
61
- package(bundleId) {
62
- return (0, rust_1.atlaspackNapiPackage)(this._atlaspack_napi, bundleId);
61
+ updateBundleGraph(bundleGraph, changedAssetIds) {
62
+ const nodesJson = bundleGraph.serializeAssetNodesForNative(changedAssetIds);
63
+ return (0, rust_1.atlaspackNapiUpdateBundleGraph)(this._atlaspack_napi, nodesJson);
64
+ }
65
+ package(bundleId, options) {
66
+ return (0, rust_1.atlaspackNapiPackage)(this._atlaspack_napi, bundleId, options);
63
67
  }
64
68
  async respondToFsEvents(events) {
65
69
  // @ts-expect-error TS2488
@@ -8,7 +8,6 @@ exports.default = createAssetGraphRequest;
8
8
  const logger_1 = __importDefault(require("@atlaspack/logger"));
9
9
  const assert_1 = __importDefault(require("assert"));
10
10
  const nullthrows_1 = __importDefault(require("nullthrows"));
11
- const feature_flags_1 = require("@atlaspack/feature-flags");
12
11
  const utils_1 = require("@atlaspack/utils");
13
12
  const rust_1 = require("@atlaspack/rust");
14
13
  const diagnostic_1 = __importDefault(require("@atlaspack/diagnostic"));
@@ -32,8 +31,10 @@ function createAssetGraphRequest(requestInput) {
32
31
  let builder = new AssetGraphBuilder(input, prevResult);
33
32
  let assetGraphRequest = await builder.build();
34
33
  // early break for incremental bundling if production or flag is off;
35
- assetGraphRequest.assetGraph.setDisableIncrementalBundling(!input.options.shouldBundleIncrementally ||
36
- input.options.mode === 'production');
34
+ if (!input.options.shouldBundleIncrementally ||
35
+ input.options.mode === 'production') {
36
+ assetGraphRequest.assetGraph.safeToIncrementallyBundle = false;
37
+ }
37
38
  if (!input.options.shouldBundleIncrementally ||
38
39
  input.options.mode === 'production') {
39
40
  assetGraphRequest.assetGraph.safeToIncrementallyBundle = false;
@@ -77,14 +78,8 @@ class AssetGraphBuilder {
77
78
  this.lazyIncludes = lazyIncludes ?? [];
78
79
  this.lazyExcludes = lazyExcludes ?? [];
79
80
  this.skipSymbolProp = input.skipSymbolProp ?? false;
80
- if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
81
- const key = (0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`);
82
- this.cacheKey = `AssetGraph/${constants_1.ATLASPACK_VERSION}/${options.mode}/${key}`;
83
- }
84
- else {
85
- this.cacheKey =
86
- (0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-AssetGraph';
87
- }
81
+ this.cacheKey =
82
+ (0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-AssetGraph';
88
83
  this.isSingleChangeRebuild =
89
84
  api
90
85
  .getInvalidSubRequests()
@@ -357,7 +352,6 @@ class AssetGraphBuilder {
357
352
  prevEntries.every((entryId, index) => entryId === currentEntries[index]);
358
353
  if (didEntriesChange) {
359
354
  this.assetGraph.safeToIncrementallyBundle = false;
360
- this.assetGraph.setNeedsBundling();
361
355
  }
362
356
  }
363
357
  }
@@ -399,13 +393,11 @@ class AssetGraphBuilder {
399
393
  (0, assert_1.default)(otherAsset.type === 'asset');
400
394
  if (!this._areDependenciesEqualForAssets(asset, otherAsset.value)) {
401
395
  this.assetGraph.safeToIncrementallyBundle = false;
402
- this.assetGraph.setNeedsBundling();
403
396
  }
404
397
  }
405
398
  else {
406
399
  // adding a new entry or dependency
407
400
  this.assetGraph.safeToIncrementallyBundle = false;
408
- this.assetGraph.setNeedsBundling();
409
401
  }
410
402
  }
411
403
  this.changedAssets.set(asset.id, asset);
@@ -415,7 +407,6 @@ class AssetGraphBuilder {
415
407
  }
416
408
  else {
417
409
  this.assetGraph.safeToIncrementallyBundle = false;
418
- this.assetGraph.setNeedsBundling();
419
410
  }
420
411
  this.isSingleChangeRebuild = false;
421
412
  }
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -7,7 +40,7 @@ exports.createAssetGraphRequestRust = createAssetGraphRequestRust;
7
40
  exports.getAssetGraph = getAssetGraph;
8
41
  const assert_1 = __importDefault(require("assert"));
9
42
  const diagnostic_1 = __importDefault(require("@atlaspack/diagnostic"));
10
- const logger_1 = require("@atlaspack/logger");
43
+ const logger_1 = __importStar(require("@atlaspack/logger"));
11
44
  const feature_flags_1 = require("@atlaspack/feature-flags");
12
45
  const AssetGraph_1 = __importDefault(require("../AssetGraph"));
13
46
  const RequestTracker_1 = require("../RequestTracker");
@@ -20,8 +53,8 @@ function createAssetGraphRequestRust(rustAtlaspack) {
20
53
  return (input) => ({
21
54
  type: RequestTracker_1.requestTypes.asset_graph_request,
22
55
  id: input.name,
23
- run: async (input) => {
24
- let options = input.options;
56
+ run: async (runInput) => {
57
+ let options = runInput.options;
25
58
  let { assetGraphPromise, commitPromise } = await rustAtlaspack.buildAssetGraph();
26
59
  let [serializedAssetGraph, assetGraphError] = (await assetGraphPromise);
27
60
  if (assetGraphError) {
@@ -33,23 +66,32 @@ function createAssetGraphRequestRust(rustAtlaspack) {
33
66
  let prevResult = null;
34
67
  if (serializedAssetGraph.hadPreviousGraph) {
35
68
  prevResult =
36
- await input.api.getPreviousResult();
69
+ await runInput.api.getPreviousResult();
37
70
  }
38
71
  let { assetGraph, changedAssets } = (0, logger_1.instrument)('atlaspack_v3_getAssetGraph', () => getAssetGraph(serializedAssetGraph, prevResult?.assetGraph));
39
72
  let changedAssetsPropagation = new Set(changedAssets.keys());
40
- let errors = (0, SymbolPropagation_1.propagateSymbols)({
41
- options,
42
- assetGraph,
43
- changedAssetsPropagation,
44
- assetGroupsWithRemovedParents: new Set(),
45
- previousErrors: new Map(), //this.previousSymbolPropagationErrors,
46
- });
47
- if (errors.size > 0) {
48
- // Just throw the first error. Since errors can bubble (e.g. reexporting a reexported symbol also fails),
49
- // determining which failing export is the root cause is nontrivial (because of circular dependencies).
50
- throw new diagnostic_1.default({
51
- diagnostic: [...errors.values()][0],
73
+ // Skip symbol propagation for runtime assets - they have pre-computed symbol data
74
+ if (input.skipSymbolProp) {
75
+ logger_1.default.verbose({
76
+ origin: '@atlaspack/core',
77
+ message: 'Skipping symbol propagation for runtime asset graph',
78
+ });
79
+ }
80
+ else {
81
+ let errors = (0, SymbolPropagation_1.propagateSymbols)({
82
+ options,
83
+ assetGraph,
84
+ changedAssetsPropagation,
85
+ assetGroupsWithRemovedParents: new Set(),
86
+ previousErrors: new Map(), //this.previousSymbolPropagationErrors,
52
87
  });
88
+ if (errors.size > 0) {
89
+ // Just throw the first error. Since errors can bubble (e.g. reexporting a reexported symbol also fails),
90
+ // determining which failing export is the root cause is nontrivial (because of circular dependencies).
91
+ throw new diagnostic_1.default({
92
+ diagnostic: [...errors.values()][0],
93
+ });
94
+ }
53
95
  }
54
96
  await (0, dumpGraphToGraphViz_1.default)(assetGraph, 'AssetGraphV3');
55
97
  let result = {
@@ -68,8 +110,8 @@ function createAssetGraphRequestRust(rustAtlaspack) {
68
110
  },
69
111
  });
70
112
  }
71
- await input.api.storeResult(result);
72
- input.api.invalidateOnBuild();
113
+ await runInput.api.storeResult(result);
114
+ runInput.api.invalidateOnBuild();
73
115
  return result;
74
116
  },
75
117
  input,
@@ -161,14 +203,58 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
161
203
  }
162
204
  return envId;
163
205
  };
164
- function updateNode(newNode, isUpdateNode) {
206
+ function describeNode(node) {
207
+ const base = { type: node.type, id: node.id };
208
+ if (node.type === 'asset') {
209
+ return {
210
+ ...base,
211
+ filePath: node.value.filePath,
212
+ fileType: node.value.type,
213
+ pipeline: node.value.pipeline,
214
+ };
215
+ }
216
+ else if (node.type === 'dependency') {
217
+ return {
218
+ ...base,
219
+ specifier: node.value.specifier,
220
+ specifierType: node.value.specifierType,
221
+ sourceAssetId: node.value.sourceAssetId,
222
+ sourcePath: node.value.sourcePath,
223
+ };
224
+ }
225
+ return base;
226
+ }
227
+ function updateNode(newNode, isUpdateNode, index) {
165
228
  if (isUpdateNode) {
166
229
  let existingNode = graph.getNodeByContentKey(newNode.id);
167
230
  (0, assert_2.default)(existingNode && existingNode.type === newNode.type);
168
231
  Object.assign(existingNode, newNode);
169
232
  }
170
233
  else {
171
- graph.addNodeByContentKey(newNode.id, newNode);
234
+ try {
235
+ graph.addNodeByContentKey(newNode.id, newNode);
236
+ }
237
+ catch (e) {
238
+ if (e instanceof Error &&
239
+ e.message.includes('already has content key')) {
240
+ let existingNode = graph.getNodeByContentKey(newNode.id);
241
+ let diagnostics = {
242
+ contentKey: newNode.id,
243
+ newNode: describeNode(newNode),
244
+ existingNode: existingNode ? describeNode(existingNode) : null,
245
+ iterationIndex: index,
246
+ totalSerializedNodes: nodesCount,
247
+ newNodesCount: serializedGraph.nodes.length,
248
+ updatesCount: serializedGraph.updates.length,
249
+ edgesCount: serializedGraph.edges.length,
250
+ hadPreviousGraph: !!prevAssetGraph,
251
+ safeToSkipBundling: serializedGraph.safeToSkipBundling,
252
+ graphNodeCount: graph._contentKeyToNodeId.size,
253
+ };
254
+ throw new Error(`Graph already has content key '${newNode.id}'. Diagnostics: ${JSON.stringify(diagnostics, null, 2)}`);
255
+ }
256
+ throw e;
257
+ }
172
258
  }
173
259
  }
174
260
  let nodeTypeSwitchoverIndex = serializedGraph.nodes.length;
@@ -215,7 +301,7 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
215
301
  usedSymbolsUpDirty: true,
216
302
  value: asset,
217
303
  };
218
- updateNode(assetNode, isUpdateNode);
304
+ updateNode(assetNode, isUpdateNode, index);
219
305
  }
220
306
  else if (node.type === 'dependency') {
221
307
  let { dependency, id } = node.value;
@@ -230,6 +316,17 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
230
316
  }
231
317
  let usedSymbolsDown = new Set();
232
318
  let usedSymbolsUp = new Map();
319
+ if (node.used_symbols_up) {
320
+ for (let usedSymbol of node.used_symbols_up) {
321
+ // Transform Rust UsedSymbol { symbol: Symbol, asset: string, resolved_symbol: string }
322
+ // to JS format { symbol: string, asset: string } where symbol is the resolved name
323
+ const exportedName = usedSymbol.symbol.exported;
324
+ usedSymbolsUp.set(exportedName, {
325
+ asset: usedSymbol.asset,
326
+ symbol: usedSymbol.resolved_symbol ?? exportedName,
327
+ });
328
+ }
329
+ }
233
330
  if (dependency.isEntry && dependency.isLibrary) {
234
331
  usedSymbolsDown.add('*');
235
332
  usedSymbolsUp.set('*', undefined);
@@ -248,7 +345,7 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
248
345
  usedSymbolsUpDirtyUp: true,
249
346
  value: dependency,
250
347
  };
251
- updateNode(depNode, isUpdateNode);
348
+ updateNode(depNode, isUpdateNode, index);
252
349
  }
253
350
  }
254
351
  if (!reuseEdges) {
@@ -39,7 +39,7 @@ async function run({ input, api, options, rustAtlaspack, }) {
39
39
  requestedAssetIds,
40
40
  signal,
41
41
  });
42
- let { bundleGraph, changedAssets, assetRequests } = await api.runRequest(bundleGraphRequest, {
42
+ let { bundleGraph, changedAssets, assetRequests, didIncrementallyBundle, } = await api.runRequest(bundleGraphRequest, {
43
43
  force: Boolean(rustAtlaspack) ||
44
44
  (options.shouldBuildLazily && requestedAssetIds.size > 0),
45
45
  });
@@ -55,7 +55,13 @@ async function run({ input, api, options, rustAtlaspack, }) {
55
55
  }
56
56
  });
57
57
  if (hasSupportedTarget) {
58
- await rustAtlaspack.loadBundleGraph(bundleGraph);
58
+ if (didIncrementallyBundle) {
59
+ const changedAssetIds = Array.from(changedAssets.keys());
60
+ await rustAtlaspack.updateBundleGraph(bundleGraph, changedAssetIds);
61
+ }
62
+ else {
63
+ await rustAtlaspack.loadBundleGraph(bundleGraph);
64
+ }
59
65
  }
60
66
  }
61
67
  // @ts-expect-error TS2345
@@ -110,6 +110,7 @@ function createBundleGraphRequest(input) {
110
110
  lazyIncludes: options.lazyIncludes,
111
111
  lazyExcludes: options.lazyExcludes,
112
112
  requestedAssetIds,
113
+ skipSymbolProp: (0, feature_flags_1.getFeatureFlag)('rustSymbolTracker'),
113
114
  });
114
115
  let { assetGraph, changedAssets, assetRequests } = await (0, logger_1.instrumentAsync)('asset-graph-request', () => {
115
116
  return api.runRequest(request, {
@@ -156,7 +157,6 @@ function createBundleGraphRequest(input) {
156
157
  .some((req) => !input.api.canSkipSubrequest(req.id));
157
158
  if (subRequestsInvalid) {
158
159
  assetGraph.safeToIncrementallyBundle = false;
159
- assetGraph.setNeedsBundling();
160
160
  }
161
161
  let configResult = (0, nullthrows_1.default)(await input.api.runRequest((0, AtlaspackConfigRequest_1.default)()));
162
162
  (0, utils_1.assertSignalNotAborted)(signal);
@@ -192,14 +192,8 @@ class BundlerRunner {
192
192
  this.devDepRequests = new Map();
193
193
  this.configs = new Map();
194
194
  this.pluginOptions = new PluginOptions_1.default((0, utils_1.optionsProxy)(this.options, api.invalidateOnOptionChange));
195
- if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
196
- const key = (0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`);
197
- this.cacheKey = `BundleGraph/${constants_1.ATLASPACK_VERSION}/${options.mode}/${key}`;
198
- }
199
- else {
200
- this.cacheKey =
201
- (0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-BundleGraph';
202
- }
195
+ this.cacheKey =
196
+ (0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-BundleGraph';
203
197
  }
204
198
  async loadConfigs() {
205
199
  // Load all configs up front so we can use them in the cache key
@@ -225,16 +219,15 @@ class BundlerRunner {
225
219
  type: 'buildProgress',
226
220
  phase: 'bundling',
227
221
  });
222
+ let didIncrementallyBundle = false;
228
223
  await this.loadConfigs();
229
224
  let plugin = await this.config.getBundler();
230
225
  let { plugin: bundler, name, resolveFrom } = plugin;
231
226
  // if a previous asset graph hash is passed in, check if the bundle graph is also available
232
227
  const previousBundleGraphResult = await this.api.getPreviousResult();
233
- const canIncrementallyBundle = previousBundleGraphResult?.assetGraphBundlingVersion != null &&
234
- graph.canIncrementallyBundle(previousBundleGraphResult.assetGraphBundlingVersion);
228
+ const canIncrementallyBundle = previousBundleGraphResult != null && graph.canIncrementallyBundle();
235
229
  if (graph.safeToIncrementallyBundle && previousBundleGraphResult == null) {
236
230
  graph.safeToIncrementallyBundle = false;
237
- graph.setNeedsBundling();
238
231
  }
239
232
  let internalBundleGraph;
240
233
  let logger = new logger_1.PluginLogger({ origin: name });
@@ -251,6 +244,7 @@ class BundlerRunner {
251
244
  (0, assert_1.default)(changedAssetNode.type === 'asset');
252
245
  internalBundleGraph.updateAsset(changedAssetNode);
253
246
  }
247
+ didIncrementallyBundle = true;
254
248
  }
255
249
  else {
256
250
  internalBundleGraph = BundleGraph_1.default.fromAssetGraph(graph, this.options.mode === 'production');
@@ -317,9 +311,9 @@ class BundlerRunner {
317
311
  if (internalBundleGraph != null) {
318
312
  this.api.storeResult({
319
313
  bundleGraph: internalBundleGraph,
320
- assetGraphBundlingVersion: graph.getBundlingVersion(),
321
314
  changedAssets: new Map(),
322
315
  assetRequests: [],
316
+ didIncrementallyBundle,
323
317
  }, this.cacheKey);
324
318
  }
325
319
  throw new diagnostic_1.default({
@@ -370,15 +364,15 @@ class BundlerRunner {
370
364
  internalBundleGraph._graph, 'after_runtimes', BundleGraph_1.bundleGraphEdgeTypes);
371
365
  this.api.storeResult({
372
366
  bundleGraph: internalBundleGraph,
373
- assetGraphBundlingVersion: graph.getBundlingVersion(),
374
367
  changedAssets: new Map(),
375
368
  assetRequests: [],
369
+ didIncrementallyBundle,
376
370
  }, this.cacheKey);
377
371
  return {
378
372
  bundleGraph: internalBundleGraph,
379
- assetGraphBundlingVersion: graph.getBundlingVersion(),
380
373
  changedAssets: changedRuntimes,
381
374
  assetRequests,
375
+ didIncrementallyBundle,
382
376
  };
383
377
  }
384
378
  }
@@ -112,10 +112,9 @@ function createBundleGraphRequestRust(input) {
112
112
  }
113
113
  return {
114
114
  bundleGraph,
115
- // Not accurate yet — ok for now.
116
- assetGraphBundlingVersion: 0,
117
115
  changedAssets: changedRuntimes,
118
116
  assetRequests: [],
117
+ didIncrementallyBundle: false,
119
118
  };
120
119
  },
121
120
  input,
@@ -34,7 +34,7 @@ async function run({ input, api, farm, rustAtlaspack }) {
34
34
  (0, EnvironmentManager_1.fromEnvironmentId)(bundle.env).context === 'tesseract' &&
35
35
  bundle.type === 'js') {
36
36
  // Once this actually does something, the code below will be in an `else` block (i.e. we'll only run one or the other)
37
- let result = await rustAtlaspack.package(bundle.id);
37
+ let result = await rustAtlaspack.package(bundle.id, { inlineRequires: true });
38
38
  let error = null;
39
39
  [packagingResult, error] = result;
40
40
  if (error) {
@@ -227,6 +227,7 @@ class TargetResolver {
227
227
  distDir: (0, projectPath_1.toProjectPath)(this.options.projectRoot, path_1.default.resolve(this.fs.cwd(), distDir)),
228
228
  publicUrl: descriptor.publicUrl ??
229
229
  this.options.defaultTargetOptions.publicUrl,
230
+ inlineRequires: descriptor.inlineRequires ?? false,
230
231
  env: (0, Environment_1.createEnvironment)({
231
232
  engines: descriptor.engines,
232
233
  context: descriptor.context,
@@ -299,6 +300,7 @@ class TargetResolver {
299
300
  name: 'default',
300
301
  distDir: (0, projectPath_1.toProjectPath)(this.options.projectRoot, this.options.serveOptions.distDir),
301
302
  publicUrl: this.options.defaultTargetOptions.publicUrl ?? '/',
303
+ inlineRequires: false,
302
304
  env: (0, Environment_1.createEnvironment)({
303
305
  context: 'browser',
304
306
  engines: {
@@ -705,6 +707,7 @@ class TargetResolver {
705
707
  distDir,
706
708
  distEntry,
707
709
  publicUrl: descriptor.publicUrl ?? this.options.defaultTargetOptions.publicUrl,
710
+ inlineRequires: descriptor.inlineRequires ?? false,
708
711
  env: (0, Environment_1.createEnvironment)({
709
712
  engines: descriptor.engines ?? pkgEngines,
710
713
  // @ts-expect-error TS2322
@@ -870,6 +873,7 @@ class TargetResolver {
870
873
  : distDir),
871
874
  distEntry,
872
875
  publicUrl: descriptor.publicUrl ?? this.options.defaultTargetOptions.publicUrl,
876
+ inlineRequires: descriptor.inlineRequires ?? false,
873
877
  env: (0, Environment_1.createEnvironment)({
874
878
  engines: descriptor.engines ?? pkgEngines,
875
879
  context: descriptor.context,
@@ -932,6 +936,7 @@ class TargetResolver {
932
936
  distDir: this.options.defaultTargetOptions.distDir ??
933
937
  (0, projectPath_1.toProjectPath)(this.options.projectRoot, path_1.default.join(pkgDir, DEFAULT_DIST_DIRNAME)),
934
938
  publicUrl: this.options.defaultTargetOptions.publicUrl,
939
+ inlineRequires: false,
935
940
  env: (0, Environment_1.createEnvironment)({
936
941
  engines: pkgEngines,
937
942
  // @ts-expect-error TS2322