@atlaspack/core 2.34.0 → 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.
- package/CHANGELOG.md +46 -0
- package/dist/AssetGraph.js +4 -72
- package/dist/BundleGraph.js +34 -0
- package/dist/PackagerRunner.js +8 -53
- package/dist/RequestTracker.js +17 -80
- package/dist/TargetDescriptor.schema.js +3 -0
- package/dist/UncommittedAsset.js +0 -5
- package/dist/atlaspack-v3/AtlaspackV3.js +6 -2
- package/dist/requests/AssetGraphRequest.js +6 -15
- package/dist/requests/AssetGraphRequestRust.js +51 -7
- package/dist/requests/AtlaspackBuildRequest.js +8 -2
- package/dist/requests/BundleGraphRequest.js +8 -15
- package/dist/requests/BundleGraphRequestRust.js +1 -2
- package/dist/requests/PackageRequest.js +1 -1
- package/dist/requests/TargetRequest.js +5 -0
- package/dist/requests/WriteBundleRequest.js +3 -9
- package/dist/resolveOptions.js +2 -4
- package/lib/AssetGraph.js +3 -62
- package/lib/BundleGraph.js +38 -0
- package/lib/PackagerRunner.js +8 -42
- package/lib/RequestTracker.js +15 -69
- package/lib/TargetDescriptor.schema.js +3 -0
- package/lib/UncommittedAsset.js +0 -11
- package/lib/atlaspack-v3/AtlaspackV3.js +6 -2
- package/lib/requests/AssetGraphRequest.js +4 -18
- package/lib/requests/AssetGraphRequestRust.js +51 -7
- package/lib/requests/AtlaspackBuildRequest.js +8 -2
- package/lib/requests/BundleGraphRequest.js +10 -15
- package/lib/requests/BundleGraphRequestRust.js +2 -3
- package/lib/requests/PackageRequest.js +3 -1
- package/lib/requests/TargetRequest.js +5 -0
- package/lib/requests/WriteBundleRequest.js +3 -3
- package/lib/resolveOptions.js +2 -4
- package/lib/types/AssetGraph.d.ts +2 -27
- package/lib/types/BundleGraph.d.ts +5 -0
- package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +3 -2
- package/lib/types/requests/BundleGraphRequest.d.ts +1 -1
- package/lib/types/types.d.ts +1 -0
- package/package.json +15 -15
- package/src/AssetGraph.ts +4 -72
- package/src/BundleGraph.ts +39 -0
- package/src/PackagerRunner.ts +9 -55
- package/src/RequestTracker.ts +24 -110
- package/src/TargetDescriptor.schema.ts +3 -0
- package/src/UncommittedAsset.ts +1 -11
- package/src/atlaspack-v3/AtlaspackV3.ts +19 -3
- package/src/requests/AssetGraphRequest.ts +8 -20
- package/src/requests/AssetGraphRequestRust.ts +59 -7
- package/src/requests/AtlaspackBuildRequest.ts +16 -8
- package/src/requests/BundleGraphRequest.ts +11 -30
- package/src/requests/BundleGraphRequestRust.ts +1 -2
- package/src/requests/PackageRequest.ts +1 -1
- package/src/requests/TargetRequest.ts +5 -0
- package/src/requests/WriteBundleRequest.ts +3 -9
- package/src/resolveOptions.ts +2 -4
- package/src/types.ts +1 -0
- package/test/AssetGraph.test.ts +0 -32
- package/test/RequestTracker.test.ts +0 -165
- package/test/TargetRequest.test.ts +25 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -6,10 +6,12 @@ import {
|
|
|
6
6
|
atlaspackNapiCompleteSession,
|
|
7
7
|
atlaspackNapiLoadBundleGraph,
|
|
8
8
|
atlaspackNapiPackage,
|
|
9
|
+
atlaspackNapiUpdateBundleGraph,
|
|
9
10
|
AtlaspackNapi,
|
|
10
11
|
Lmdb,
|
|
11
12
|
AtlaspackNapiOptions,
|
|
12
13
|
CacheStats,
|
|
14
|
+
PackageOptions,
|
|
13
15
|
} from '@atlaspack/rust';
|
|
14
16
|
import {NapiWorkerPool} from './NapiWorkerPool';
|
|
15
17
|
import ThrowableDiagnostic, {Diagnostic} from '@atlaspack/diagnostic';
|
|
@@ -119,12 +121,26 @@ export class AtlaspackV3 {
|
|
|
119
121
|
) as Promise<void>;
|
|
120
122
|
}
|
|
121
123
|
|
|
124
|
+
updateBundleGraph(
|
|
125
|
+
bundleGraph: BundleGraph,
|
|
126
|
+
changedAssetIds: string[],
|
|
127
|
+
): Promise<void> {
|
|
128
|
+
const nodesJson = bundleGraph.serializeAssetNodesForNative(changedAssetIds);
|
|
129
|
+
return atlaspackNapiUpdateBundleGraph(
|
|
130
|
+
this._atlaspack_napi,
|
|
131
|
+
nodesJson,
|
|
132
|
+
) as Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
|
|
122
135
|
package(
|
|
123
136
|
bundleId: string,
|
|
137
|
+
options?: PackageOptions,
|
|
124
138
|
): Promise<[RunPackagerRunnerResult, Diagnostic | null]> {
|
|
125
|
-
return atlaspackNapiPackage(
|
|
126
|
-
|
|
127
|
-
|
|
139
|
+
return atlaspackNapiPackage(
|
|
140
|
+
this._atlaspack_napi,
|
|
141
|
+
bundleId,
|
|
142
|
+
options,
|
|
143
|
+
) as Promise<[RunPackagerRunnerResult, Diagnostic | null]>;
|
|
128
144
|
}
|
|
129
145
|
|
|
130
146
|
async respondToFsEvents(events: Array<Event>): Promise<boolean> {
|
|
@@ -18,7 +18,6 @@ import logger from '@atlaspack/logger';
|
|
|
18
18
|
|
|
19
19
|
import invariant from 'assert';
|
|
20
20
|
import nullthrows from 'nullthrows';
|
|
21
|
-
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
22
21
|
import {PromiseQueue, setEqual} from '@atlaspack/utils';
|
|
23
22
|
import {hashString} from '@atlaspack/rust';
|
|
24
23
|
import ThrowableDiagnostic from '@atlaspack/diagnostic';
|
|
@@ -85,10 +84,12 @@ export default function createAssetGraphRequest(
|
|
|
85
84
|
let assetGraphRequest = await builder.build();
|
|
86
85
|
|
|
87
86
|
// early break for incremental bundling if production or flag is off;
|
|
88
|
-
|
|
87
|
+
if (
|
|
89
88
|
!input.options.shouldBundleIncrementally ||
|
|
90
|
-
|
|
91
|
-
)
|
|
89
|
+
input.options.mode === 'production'
|
|
90
|
+
) {
|
|
91
|
+
assetGraphRequest.assetGraph.safeToIncrementallyBundle = false;
|
|
92
|
+
}
|
|
92
93
|
|
|
93
94
|
if (
|
|
94
95
|
!input.options.shouldBundleIncrementally ||
|
|
@@ -171,21 +172,12 @@ export class AssetGraphBuilder {
|
|
|
171
172
|
this.lazyExcludes = lazyExcludes ?? [];
|
|
172
173
|
this.skipSymbolProp = input.skipSymbolProp ?? false;
|
|
173
174
|
|
|
174
|
-
|
|
175
|
-
|
|
175
|
+
this.cacheKey =
|
|
176
|
+
hashString(
|
|
176
177
|
`${ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${
|
|
177
178
|
options.mode
|
|
178
179
|
}${options.shouldBuildLazily ? 'lazy' : 'eager'}`,
|
|
179
|
-
);
|
|
180
|
-
this.cacheKey = `AssetGraph/${ATLASPACK_VERSION}/${options.mode}/${key}`;
|
|
181
|
-
} else {
|
|
182
|
-
this.cacheKey =
|
|
183
|
-
hashString(
|
|
184
|
-
`${ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${
|
|
185
|
-
options.mode
|
|
186
|
-
}${options.shouldBuildLazily ? 'lazy' : 'eager'}`,
|
|
187
|
-
) + '-AssetGraph';
|
|
188
|
-
}
|
|
180
|
+
) + '-AssetGraph';
|
|
189
181
|
|
|
190
182
|
this.isSingleChangeRebuild =
|
|
191
183
|
api
|
|
@@ -535,7 +527,6 @@ export class AssetGraphBuilder {
|
|
|
535
527
|
|
|
536
528
|
if (didEntriesChange) {
|
|
537
529
|
this.assetGraph.safeToIncrementallyBundle = false;
|
|
538
|
-
this.assetGraph.setNeedsBundling();
|
|
539
530
|
}
|
|
540
531
|
}
|
|
541
532
|
}
|
|
@@ -590,12 +581,10 @@ export class AssetGraphBuilder {
|
|
|
590
581
|
invariant(otherAsset.type === 'asset');
|
|
591
582
|
if (!this._areDependenciesEqualForAssets(asset, otherAsset.value)) {
|
|
592
583
|
this.assetGraph.safeToIncrementallyBundle = false;
|
|
593
|
-
this.assetGraph.setNeedsBundling();
|
|
594
584
|
}
|
|
595
585
|
} else {
|
|
596
586
|
// adding a new entry or dependency
|
|
597
587
|
this.assetGraph.safeToIncrementallyBundle = false;
|
|
598
|
-
this.assetGraph.setNeedsBundling();
|
|
599
588
|
}
|
|
600
589
|
}
|
|
601
590
|
this.changedAssets.set(asset.id, asset);
|
|
@@ -604,7 +593,6 @@ export class AssetGraphBuilder {
|
|
|
604
593
|
this.assetGraph.resolveAssetGroup(input, assets, request.id);
|
|
605
594
|
} else {
|
|
606
595
|
this.assetGraph.safeToIncrementallyBundle = false;
|
|
607
|
-
this.assetGraph.setNeedsBundling();
|
|
608
596
|
}
|
|
609
597
|
|
|
610
598
|
this.isSingleChangeRebuild = false;
|
|
@@ -238,7 +238,32 @@ export function getAssetGraph(
|
|
|
238
238
|
return envId;
|
|
239
239
|
};
|
|
240
240
|
|
|
241
|
-
function
|
|
241
|
+
function describeNode(node: AssetGraphNode): Record<string, unknown> {
|
|
242
|
+
const base = {type: node.type, id: node.id};
|
|
243
|
+
if (node.type === 'asset') {
|
|
244
|
+
return {
|
|
245
|
+
...base,
|
|
246
|
+
filePath: node.value.filePath,
|
|
247
|
+
fileType: node.value.type,
|
|
248
|
+
pipeline: node.value.pipeline,
|
|
249
|
+
};
|
|
250
|
+
} else if (node.type === 'dependency') {
|
|
251
|
+
return {
|
|
252
|
+
...base,
|
|
253
|
+
specifier: node.value.specifier,
|
|
254
|
+
specifierType: node.value.specifierType,
|
|
255
|
+
sourceAssetId: node.value.sourceAssetId,
|
|
256
|
+
sourcePath: node.value.sourcePath,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
return base;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function updateNode(
|
|
263
|
+
newNode: AssetGraphNode,
|
|
264
|
+
isUpdateNode: boolean,
|
|
265
|
+
index: number,
|
|
266
|
+
) {
|
|
242
267
|
if (isUpdateNode) {
|
|
243
268
|
let existingNode = graph.getNodeByContentKey(newNode.id);
|
|
244
269
|
|
|
@@ -246,7 +271,34 @@ export function getAssetGraph(
|
|
|
246
271
|
|
|
247
272
|
Object.assign(existingNode, newNode);
|
|
248
273
|
} else {
|
|
249
|
-
|
|
274
|
+
try {
|
|
275
|
+
graph.addNodeByContentKey(newNode.id, newNode);
|
|
276
|
+
} catch (e) {
|
|
277
|
+
if (
|
|
278
|
+
e instanceof Error &&
|
|
279
|
+
e.message.includes('already has content key')
|
|
280
|
+
) {
|
|
281
|
+
let existingNode = graph.getNodeByContentKey(newNode.id);
|
|
282
|
+
let diagnostics = {
|
|
283
|
+
contentKey: newNode.id,
|
|
284
|
+
newNode: describeNode(newNode),
|
|
285
|
+
existingNode: existingNode ? describeNode(existingNode) : null,
|
|
286
|
+
iterationIndex: index,
|
|
287
|
+
totalSerializedNodes: nodesCount,
|
|
288
|
+
newNodesCount: serializedGraph.nodes.length,
|
|
289
|
+
updatesCount: serializedGraph.updates.length,
|
|
290
|
+
edgesCount: serializedGraph.edges.length,
|
|
291
|
+
hadPreviousGraph: !!prevAssetGraph,
|
|
292
|
+
safeToSkipBundling: serializedGraph.safeToSkipBundling,
|
|
293
|
+
graphNodeCount: graph._contentKeyToNodeId.size,
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
throw new Error(
|
|
297
|
+
`Graph already has content key '${newNode.id}'. Diagnostics: ${JSON.stringify(diagnostics, null, 2)}`,
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
throw e;
|
|
301
|
+
}
|
|
250
302
|
}
|
|
251
303
|
}
|
|
252
304
|
|
|
@@ -305,7 +357,7 @@ export function getAssetGraph(
|
|
|
305
357
|
usedSymbolsUpDirty: true,
|
|
306
358
|
value: asset,
|
|
307
359
|
};
|
|
308
|
-
updateNode(assetNode, isUpdateNode);
|
|
360
|
+
updateNode(assetNode, isUpdateNode, index);
|
|
309
361
|
} else if (node.type === 'dependency') {
|
|
310
362
|
let {dependency, id} = node.value;
|
|
311
363
|
|
|
@@ -325,12 +377,12 @@ export function getAssetGraph(
|
|
|
325
377
|
|
|
326
378
|
if (node.used_symbols_up) {
|
|
327
379
|
for (let usedSymbol of node.used_symbols_up) {
|
|
328
|
-
// Transform Rust UsedSymbol { symbol: Symbol, asset: string }
|
|
329
|
-
// to JS format { symbol: string, asset: string } where symbol is the
|
|
380
|
+
// Transform Rust UsedSymbol { symbol: Symbol, asset: string, resolved_symbol: string }
|
|
381
|
+
// to JS format { symbol: string, asset: string } where symbol is the resolved name
|
|
330
382
|
const exportedName = usedSymbol.symbol.exported;
|
|
331
383
|
usedSymbolsUp.set(exportedName, {
|
|
332
384
|
asset: usedSymbol.asset,
|
|
333
|
-
symbol: exportedName,
|
|
385
|
+
symbol: usedSymbol.resolved_symbol ?? exportedName,
|
|
334
386
|
});
|
|
335
387
|
}
|
|
336
388
|
}
|
|
@@ -355,7 +407,7 @@ export function getAssetGraph(
|
|
|
355
407
|
value: dependency,
|
|
356
408
|
};
|
|
357
409
|
|
|
358
|
-
updateNode(depNode, isUpdateNode);
|
|
410
|
+
updateNode(depNode, isUpdateNode, index);
|
|
359
411
|
}
|
|
360
412
|
}
|
|
361
413
|
|
|
@@ -23,7 +23,6 @@ import {tracer} from '@atlaspack/profiler';
|
|
|
23
23
|
import {requestTypes} from '../RequestTracker';
|
|
24
24
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
25
25
|
import {fromEnvironmentId} from '../EnvironmentManager';
|
|
26
|
-
import invariant from 'assert';
|
|
27
26
|
|
|
28
27
|
type AtlaspackBuildRequestInput = {
|
|
29
28
|
optionsRef: SharedReference;
|
|
@@ -87,12 +86,16 @@ async function run({
|
|
|
87
86
|
signal,
|
|
88
87
|
});
|
|
89
88
|
|
|
90
|
-
let {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
let {
|
|
90
|
+
bundleGraph,
|
|
91
|
+
changedAssets,
|
|
92
|
+
assetRequests,
|
|
93
|
+
didIncrementallyBundle,
|
|
94
|
+
}: BundleGraphResult = await api.runRequest(bundleGraphRequest, {
|
|
95
|
+
force:
|
|
96
|
+
Boolean(rustAtlaspack) ||
|
|
97
|
+
(options.shouldBuildLazily && requestedAssetIds.size > 0),
|
|
98
|
+
});
|
|
96
99
|
|
|
97
100
|
if (
|
|
98
101
|
getFeatureFlag('nativePackager') &&
|
|
@@ -110,7 +113,12 @@ async function run({
|
|
|
110
113
|
}
|
|
111
114
|
});
|
|
112
115
|
if (hasSupportedTarget) {
|
|
113
|
-
|
|
116
|
+
if (didIncrementallyBundle) {
|
|
117
|
+
const changedAssetIds = Array.from(changedAssets.keys());
|
|
118
|
+
await rustAtlaspack.updateBundleGraph(bundleGraph, changedAssetIds);
|
|
119
|
+
} else {
|
|
120
|
+
await rustAtlaspack.loadBundleGraph(bundleGraph);
|
|
121
|
+
}
|
|
114
122
|
}
|
|
115
123
|
}
|
|
116
124
|
|
|
@@ -14,7 +14,6 @@ import type {ConfigAndCachePath} from './AtlaspackConfigRequest';
|
|
|
14
14
|
|
|
15
15
|
import fs from 'fs';
|
|
16
16
|
import invariant from 'assert';
|
|
17
|
-
import assert from 'assert';
|
|
18
17
|
import nullthrows from 'nullthrows';
|
|
19
18
|
import {instrumentAsync, PluginLogger} from '@atlaspack/logger';
|
|
20
19
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
@@ -36,13 +35,8 @@ import {
|
|
|
36
35
|
createDevDependency,
|
|
37
36
|
getDevDepRequests,
|
|
38
37
|
invalidateDevDeps,
|
|
39
|
-
runDevDepRequest,
|
|
40
38
|
} from './DevDepRequest';
|
|
41
|
-
import {
|
|
42
|
-
loadPluginConfig,
|
|
43
|
-
runConfigRequest,
|
|
44
|
-
PluginWithLoadConfig,
|
|
45
|
-
} from './ConfigRequest';
|
|
39
|
+
import {PluginWithLoadConfig} from './ConfigRequest';
|
|
46
40
|
import {fromProjectPathRelative} from '../projectPath';
|
|
47
41
|
import {
|
|
48
42
|
validateBundles,
|
|
@@ -74,9 +68,9 @@ type RunInput = {
|
|
|
74
68
|
// TODO: Rename to BundleGraphRequestResult
|
|
75
69
|
export type BundleGraphResult = {
|
|
76
70
|
bundleGraph: InternalBundleGraph;
|
|
77
|
-
assetGraphBundlingVersion: number;
|
|
78
71
|
changedAssets: Map<string, Asset>;
|
|
79
72
|
assetRequests: Array<AssetGroup>;
|
|
73
|
+
didIncrementallyBundle: boolean;
|
|
80
74
|
};
|
|
81
75
|
|
|
82
76
|
type BundleGraphRequest = {
|
|
@@ -214,7 +208,6 @@ export default function createBundleGraphRequest(
|
|
|
214
208
|
|
|
215
209
|
if (subRequestsInvalid) {
|
|
216
210
|
assetGraph.safeToIncrementallyBundle = false;
|
|
217
|
-
assetGraph.setNeedsBundling();
|
|
218
211
|
}
|
|
219
212
|
|
|
220
213
|
let configResult = nullthrows(
|
|
@@ -283,21 +276,12 @@ class BundlerRunner {
|
|
|
283
276
|
this.pluginOptions = new PluginOptions(
|
|
284
277
|
optionsProxy(this.options, api.invalidateOnOptionChange),
|
|
285
278
|
);
|
|
286
|
-
|
|
287
|
-
|
|
279
|
+
this.cacheKey =
|
|
280
|
+
hashString(
|
|
288
281
|
`${ATLASPACK_VERSION}:BundleGraph:${
|
|
289
282
|
JSON.stringify(options.entries) ?? ''
|
|
290
283
|
}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`,
|
|
291
|
-
);
|
|
292
|
-
this.cacheKey = `BundleGraph/${ATLASPACK_VERSION}/${options.mode}/${key}`;
|
|
293
|
-
} else {
|
|
294
|
-
this.cacheKey =
|
|
295
|
-
hashString(
|
|
296
|
-
`${ATLASPACK_VERSION}:BundleGraph:${
|
|
297
|
-
JSON.stringify(options.entries) ?? ''
|
|
298
|
-
}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`,
|
|
299
|
-
) + '-BundleGraph';
|
|
300
|
-
}
|
|
284
|
+
) + '-BundleGraph';
|
|
301
285
|
}
|
|
302
286
|
|
|
303
287
|
async loadConfigs() {
|
|
@@ -344,7 +328,7 @@ class BundlerRunner {
|
|
|
344
328
|
type: 'buildProgress',
|
|
345
329
|
phase: 'bundling',
|
|
346
330
|
});
|
|
347
|
-
|
|
331
|
+
let didIncrementallyBundle = false;
|
|
348
332
|
await this.loadConfigs();
|
|
349
333
|
|
|
350
334
|
let plugin = await this.config.getBundler();
|
|
@@ -354,14 +338,10 @@ class BundlerRunner {
|
|
|
354
338
|
const previousBundleGraphResult: BundleGraphResult | null | undefined =
|
|
355
339
|
await this.api.getPreviousResult();
|
|
356
340
|
const canIncrementallyBundle =
|
|
357
|
-
previousBundleGraphResult
|
|
358
|
-
graph.canIncrementallyBundle(
|
|
359
|
-
previousBundleGraphResult.assetGraphBundlingVersion,
|
|
360
|
-
);
|
|
341
|
+
previousBundleGraphResult != null && graph.canIncrementallyBundle();
|
|
361
342
|
|
|
362
343
|
if (graph.safeToIncrementallyBundle && previousBundleGraphResult == null) {
|
|
363
344
|
graph.safeToIncrementallyBundle = false;
|
|
364
|
-
graph.setNeedsBundling();
|
|
365
345
|
}
|
|
366
346
|
|
|
367
347
|
let internalBundleGraph;
|
|
@@ -382,6 +362,7 @@ class BundlerRunner {
|
|
|
382
362
|
invariant(changedAssetNode.type === 'asset');
|
|
383
363
|
internalBundleGraph.updateAsset(changedAssetNode);
|
|
384
364
|
}
|
|
365
|
+
didIncrementallyBundle = true;
|
|
385
366
|
} else {
|
|
386
367
|
internalBundleGraph = InternalBundleGraph.fromAssetGraph(
|
|
387
368
|
graph,
|
|
@@ -474,9 +455,9 @@ class BundlerRunner {
|
|
|
474
455
|
this.api.storeResult(
|
|
475
456
|
{
|
|
476
457
|
bundleGraph: internalBundleGraph,
|
|
477
|
-
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
478
458
|
changedAssets: new Map(),
|
|
479
459
|
assetRequests: [],
|
|
460
|
+
didIncrementallyBundle,
|
|
480
461
|
},
|
|
481
462
|
this.cacheKey,
|
|
482
463
|
);
|
|
@@ -560,18 +541,18 @@ class BundlerRunner {
|
|
|
560
541
|
this.api.storeResult(
|
|
561
542
|
{
|
|
562
543
|
bundleGraph: internalBundleGraph,
|
|
563
|
-
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
564
544
|
changedAssets: new Map(),
|
|
565
545
|
assetRequests: [],
|
|
546
|
+
didIncrementallyBundle,
|
|
566
547
|
},
|
|
567
548
|
this.cacheKey,
|
|
568
549
|
);
|
|
569
550
|
|
|
570
551
|
return {
|
|
571
552
|
bundleGraph: internalBundleGraph,
|
|
572
|
-
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
573
553
|
changedAssets: changedRuntimes,
|
|
574
554
|
assetRequests,
|
|
555
|
+
didIncrementallyBundle,
|
|
575
556
|
};
|
|
576
557
|
}
|
|
577
558
|
}
|
|
@@ -181,10 +181,9 @@ export default function createBundleGraphRequestRust(
|
|
|
181
181
|
|
|
182
182
|
return {
|
|
183
183
|
bundleGraph,
|
|
184
|
-
// Not accurate yet — ok for now.
|
|
185
|
-
assetGraphBundlingVersion: 0,
|
|
186
184
|
changedAssets: changedRuntimes,
|
|
187
185
|
assetRequests: [],
|
|
186
|
+
didIncrementallyBundle: false,
|
|
188
187
|
};
|
|
189
188
|
},
|
|
190
189
|
input,
|
|
@@ -72,7 +72,7 @@ async function run({input, api, farm, rustAtlaspack}: RunInput<BundleInfo>) {
|
|
|
72
72
|
bundle.type === 'js'
|
|
73
73
|
) {
|
|
74
74
|
// Once this actually does something, the code below will be in an `else` block (i.e. we'll only run one or the other)
|
|
75
|
-
let result = await rustAtlaspack.package(bundle.id);
|
|
75
|
+
let result = await rustAtlaspack.package(bundle.id, {inlineRequires: true});
|
|
76
76
|
let error: Diagnostic | null = null;
|
|
77
77
|
[packagingResult, error] = result;
|
|
78
78
|
if (error) {
|
|
@@ -332,6 +332,7 @@ export class TargetResolver {
|
|
|
332
332
|
publicUrl:
|
|
333
333
|
descriptor.publicUrl ??
|
|
334
334
|
this.options.defaultTargetOptions.publicUrl,
|
|
335
|
+
inlineRequires: descriptor.inlineRequires ?? false,
|
|
335
336
|
env: createEnvironment({
|
|
336
337
|
engines: descriptor.engines,
|
|
337
338
|
context: descriptor.context,
|
|
@@ -426,6 +427,7 @@ export class TargetResolver {
|
|
|
426
427
|
this.options.serveOptions.distDir,
|
|
427
428
|
),
|
|
428
429
|
publicUrl: this.options.defaultTargetOptions.publicUrl ?? '/',
|
|
430
|
+
inlineRequires: false,
|
|
429
431
|
env: createEnvironment({
|
|
430
432
|
context: 'browser',
|
|
431
433
|
engines: {
|
|
@@ -930,6 +932,7 @@ export class TargetResolver {
|
|
|
930
932
|
distEntry,
|
|
931
933
|
publicUrl:
|
|
932
934
|
descriptor.publicUrl ?? this.options.defaultTargetOptions.publicUrl,
|
|
935
|
+
inlineRequires: descriptor.inlineRequires ?? false,
|
|
933
936
|
env: createEnvironment({
|
|
934
937
|
engines: descriptor.engines ?? pkgEngines,
|
|
935
938
|
// @ts-expect-error TS2322
|
|
@@ -1131,6 +1134,7 @@ export class TargetResolver {
|
|
|
1131
1134
|
distEntry,
|
|
1132
1135
|
publicUrl:
|
|
1133
1136
|
descriptor.publicUrl ?? this.options.defaultTargetOptions.publicUrl,
|
|
1137
|
+
inlineRequires: descriptor.inlineRequires ?? false,
|
|
1134
1138
|
env: createEnvironment({
|
|
1135
1139
|
engines: descriptor.engines ?? pkgEngines,
|
|
1136
1140
|
context: descriptor.context,
|
|
@@ -1205,6 +1209,7 @@ export class TargetResolver {
|
|
|
1205
1209
|
path.join(pkgDir, DEFAULT_DIST_DIRNAME),
|
|
1206
1210
|
),
|
|
1207
1211
|
publicUrl: this.options.defaultTargetOptions.publicUrl,
|
|
1212
|
+
inlineRequires: false,
|
|
1208
1213
|
env: createEnvironment({
|
|
1209
1214
|
engines: pkgEngines,
|
|
1210
1215
|
// @ts-expect-error TS2322
|
|
@@ -185,9 +185,7 @@ async function run({input, options, api}) {
|
|
|
185
185
|
bundleReplacements,
|
|
186
186
|
);
|
|
187
187
|
|
|
188
|
-
const hasSourceMap =
|
|
189
|
-
? await options.cache.hasLargeBlob(mapKey)
|
|
190
|
-
: await options.cache.has(mapKey);
|
|
188
|
+
const hasSourceMap = await options.cache.has(mapKey);
|
|
191
189
|
if (mapKey && env.sourceMap && !env.sourceMap.inline && hasSourceMap) {
|
|
192
190
|
let mapStream: Readable;
|
|
193
191
|
if (
|
|
@@ -195,9 +193,7 @@ async function run({input, options, api}) {
|
|
|
195
193
|
bundleReplacements &&
|
|
196
194
|
bundleReplacements.length > 0
|
|
197
195
|
) {
|
|
198
|
-
const mapEntry =
|
|
199
|
-
? await options.cache.getLargeBlob(mapKey)
|
|
200
|
-
: await options.cache.getBlob(mapKey);
|
|
196
|
+
const mapEntry = await options.cache.getBlob(mapKey);
|
|
201
197
|
const mapBuffer = Buffer.isBuffer(mapEntry)
|
|
202
198
|
? mapEntry
|
|
203
199
|
: Buffer.from(mapEntry);
|
|
@@ -219,9 +215,7 @@ async function run({input, options, api}) {
|
|
|
219
215
|
),
|
|
220
216
|
);
|
|
221
217
|
} else {
|
|
222
|
-
const mapEntry =
|
|
223
|
-
? await options.cache.getLargeBlob(mapKey)
|
|
224
|
-
: await options.cache.getBlob(mapKey);
|
|
218
|
+
const mapEntry = await options.cache.getBlob(mapKey);
|
|
225
219
|
mapStream = blobToStream(mapEntry);
|
|
226
220
|
}
|
|
227
221
|
await writeFiles(
|
package/src/resolveOptions.ts
CHANGED
|
@@ -184,10 +184,8 @@ export default async function resolveOptions(
|
|
|
184
184
|
const needsRustLmdbCache =
|
|
185
185
|
getFeatureFlag('atlaspackV3') || getFeatureFlag('nativePackager');
|
|
186
186
|
|
|
187
|
-
if (!
|
|
188
|
-
|
|
189
|
-
return new FSCache(outputFS, cacheDir);
|
|
190
|
-
}
|
|
187
|
+
if (!needsRustLmdbCache && !(outputFS instanceof NodeFS)) {
|
|
188
|
+
return new FSCache(outputFS, cacheDir);
|
|
191
189
|
}
|
|
192
190
|
|
|
193
191
|
return new LMDBLiteCache(cacheDir);
|
package/src/types.ts
CHANGED
package/test/AssetGraph.test.ts
CHANGED
|
@@ -687,36 +687,4 @@ describe('AssetGraph', () => {
|
|
|
687
687
|
invariant(node.type === 'asset_group');
|
|
688
688
|
assert(!node.hasDeferred);
|
|
689
689
|
});
|
|
690
|
-
|
|
691
|
-
it('should serialize the bundling version and incremental bundling flag', () => {
|
|
692
|
-
const graph = new AssetGraph();
|
|
693
|
-
graph.setDisableIncrementalBundling(true);
|
|
694
|
-
graph.setNeedsBundling();
|
|
695
|
-
const serialized = serialize(graph);
|
|
696
|
-
const deserialized = deserialize(serialized);
|
|
697
|
-
|
|
698
|
-
assert.equal(deserialized.getBundlingVersion(), 1);
|
|
699
|
-
assert.equal(deserialized.testing_getDisableIncrementalBundling(), true);
|
|
700
|
-
});
|
|
701
|
-
|
|
702
|
-
describe('setNeedsBundling', () => {
|
|
703
|
-
it('should increment the bundling version', () => {
|
|
704
|
-
const graph = new AssetGraph();
|
|
705
|
-
assert.equal(graph.getBundlingVersion(), 0);
|
|
706
|
-
graph.setNeedsBundling();
|
|
707
|
-
assert.equal(graph.getBundlingVersion(), 1);
|
|
708
|
-
graph.setNeedsBundling();
|
|
709
|
-
assert.equal(graph.getBundlingVersion(), 2);
|
|
710
|
-
});
|
|
711
|
-
});
|
|
712
|
-
|
|
713
|
-
describe('canIncrementallyBundle', () => {
|
|
714
|
-
it('should return true if the bundling version has changed', () => {
|
|
715
|
-
const graph = new AssetGraph();
|
|
716
|
-
const lastVersion = graph.getBundlingVersion();
|
|
717
|
-
assert.equal(graph.canIncrementallyBundle(lastVersion), true);
|
|
718
|
-
graph.setNeedsBundling();
|
|
719
|
-
assert.equal(graph.canIncrementallyBundle(lastVersion), false);
|
|
720
|
-
});
|
|
721
|
-
});
|
|
722
690
|
});
|