@atlaspack/core 2.16.2-canary.421 → 2.16.2-canary.423
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/dist/BundleGraph.js +34 -0
- package/dist/atlaspack-v3/AtlaspackV3.js +4 -0
- package/dist/requests/AtlaspackBuildRequest.js +8 -2
- package/dist/requests/BundleGraphRequest.js +5 -0
- package/dist/requests/BundleGraphRequestRust.js +1 -0
- package/lib/BundleGraph.js +38 -0
- package/lib/atlaspack-v3/AtlaspackV3.js +4 -0
- package/lib/requests/AtlaspackBuildRequest.js +8 -2
- package/lib/requests/BundleGraphRequest.js +8 -3
- package/lib/requests/BundleGraphRequestRust.js +2 -1
- package/lib/types/BundleGraph.d.ts +5 -0
- package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +1 -0
- package/lib/types/requests/BundleGraphRequest.d.ts +1 -0
- package/package.json +18 -18
- package/src/BundleGraph.ts +39 -0
- package/src/atlaspack-v3/AtlaspackV3.ts +12 -0
- package/src/requests/AtlaspackBuildRequest.ts +16 -8
- package/src/requests/BundleGraphRequest.ts +7 -8
- package/src/requests/BundleGraphRequestRust.ts +1 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/BundleGraph.js
CHANGED
|
@@ -449,6 +449,40 @@ class BundleGraph {
|
|
|
449
449
|
});
|
|
450
450
|
return { nodesJson, edges, publicIdByAssetId, environmentsJson };
|
|
451
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* Serialize only the given asset nodes for native incremental update.
|
|
454
|
+
* Same node shape and env/omit logic as serializeForNative.
|
|
455
|
+
*/
|
|
456
|
+
serializeAssetNodesForNative(assetIds) {
|
|
457
|
+
const start = performance.now();
|
|
458
|
+
if (assetIds.length === 0) {
|
|
459
|
+
return '[]';
|
|
460
|
+
}
|
|
461
|
+
const nodes = [];
|
|
462
|
+
for (const assetId of assetIds) {
|
|
463
|
+
const node = this._graph.getNodeByContentKey(assetId);
|
|
464
|
+
if (node?.type !== 'asset') {
|
|
465
|
+
continue;
|
|
466
|
+
}
|
|
467
|
+
const processedNode = { ...node };
|
|
468
|
+
if (node.value?.env) {
|
|
469
|
+
processedNode.value = {
|
|
470
|
+
...node.value,
|
|
471
|
+
env: (0, EnvironmentManager_1.fromEnvironmentId)(node.value.env).id,
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
nodes.push(processedNode);
|
|
475
|
+
}
|
|
476
|
+
const optimizedNodes = nodes.map((node) => this._omitNulls(node));
|
|
477
|
+
const nodesJson = JSON.stringify(optimizedNodes);
|
|
478
|
+
const duration = performance.now() - start;
|
|
479
|
+
const nodesSizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
|
|
480
|
+
logger_1.default.verbose({
|
|
481
|
+
origin: '@atlaspack/core',
|
|
482
|
+
message: `serializeAssetNodesForNative: ${duration.toFixed(1)}ms, ${nodesSizeMB}MB nodes, ${nodes.length} nodes`,
|
|
483
|
+
});
|
|
484
|
+
return nodesJson;
|
|
485
|
+
}
|
|
452
486
|
/**
|
|
453
487
|
* Remove null and undefined values from an object to reduce JSON size.
|
|
454
488
|
* Preserves false, 0, empty strings, and arrays.
|
|
@@ -58,6 +58,10 @@ 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
|
+
updateBundleGraph(bundleGraph, changedAssetIds) {
|
|
62
|
+
const nodesJson = bundleGraph.serializeAssetNodesForNative(changedAssetIds);
|
|
63
|
+
return (0, rust_1.atlaspackNapiUpdateBundleGraph)(this._atlaspack_napi, nodesJson);
|
|
64
|
+
}
|
|
61
65
|
package(bundleId) {
|
|
62
66
|
return (0, rust_1.atlaspackNapiPackage)(this._atlaspack_napi, bundleId);
|
|
63
67
|
}
|
|
@@ -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
|
-
|
|
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
|
|
@@ -220,6 +220,7 @@ class BundlerRunner {
|
|
|
220
220
|
type: 'buildProgress',
|
|
221
221
|
phase: 'bundling',
|
|
222
222
|
});
|
|
223
|
+
let didIncrementallyBundle = false;
|
|
223
224
|
await this.loadConfigs();
|
|
224
225
|
let plugin = await this.config.getBundler();
|
|
225
226
|
let { plugin: bundler, name, resolveFrom } = plugin;
|
|
@@ -246,6 +247,7 @@ class BundlerRunner {
|
|
|
246
247
|
(0, assert_1.default)(changedAssetNode.type === 'asset');
|
|
247
248
|
internalBundleGraph.updateAsset(changedAssetNode);
|
|
248
249
|
}
|
|
250
|
+
didIncrementallyBundle = true;
|
|
249
251
|
}
|
|
250
252
|
else {
|
|
251
253
|
internalBundleGraph = BundleGraph_1.default.fromAssetGraph(graph, this.options.mode === 'production');
|
|
@@ -315,6 +317,7 @@ class BundlerRunner {
|
|
|
315
317
|
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
316
318
|
changedAssets: new Map(),
|
|
317
319
|
assetRequests: [],
|
|
320
|
+
didIncrementallyBundle,
|
|
318
321
|
}, this.cacheKey);
|
|
319
322
|
}
|
|
320
323
|
throw new diagnostic_1.default({
|
|
@@ -368,12 +371,14 @@ class BundlerRunner {
|
|
|
368
371
|
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
369
372
|
changedAssets: new Map(),
|
|
370
373
|
assetRequests: [],
|
|
374
|
+
didIncrementallyBundle,
|
|
371
375
|
}, this.cacheKey);
|
|
372
376
|
return {
|
|
373
377
|
bundleGraph: internalBundleGraph,
|
|
374
378
|
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
375
379
|
changedAssets: changedRuntimes,
|
|
376
380
|
assetRequests,
|
|
381
|
+
didIncrementallyBundle,
|
|
377
382
|
};
|
|
378
383
|
}
|
|
379
384
|
}
|
package/lib/BundleGraph.js
CHANGED
|
@@ -516,6 +516,44 @@ class BundleGraph {
|
|
|
516
516
|
};
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
+
/**
|
|
520
|
+
* Serialize only the given asset nodes for native incremental update.
|
|
521
|
+
* Same node shape and env/omit logic as serializeForNative.
|
|
522
|
+
*/
|
|
523
|
+
serializeAssetNodesForNative(assetIds) {
|
|
524
|
+
const start = performance.now();
|
|
525
|
+
if (assetIds.length === 0) {
|
|
526
|
+
return '[]';
|
|
527
|
+
}
|
|
528
|
+
const nodes = [];
|
|
529
|
+
for (const assetId of assetIds) {
|
|
530
|
+
var _node$value4;
|
|
531
|
+
const node = this._graph.getNodeByContentKey(assetId);
|
|
532
|
+
if ((node === null || node === void 0 ? void 0 : node.type) !== 'asset') {
|
|
533
|
+
continue;
|
|
534
|
+
}
|
|
535
|
+
const processedNode = {
|
|
536
|
+
...node
|
|
537
|
+
};
|
|
538
|
+
if ((_node$value4 = node.value) !== null && _node$value4 !== void 0 && _node$value4.env) {
|
|
539
|
+
processedNode.value = {
|
|
540
|
+
...node.value,
|
|
541
|
+
env: (0, _EnvironmentManager.fromEnvironmentId)(node.value.env).id
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
nodes.push(processedNode);
|
|
545
|
+
}
|
|
546
|
+
const optimizedNodes = nodes.map(node => this._omitNulls(node));
|
|
547
|
+
const nodesJson = JSON.stringify(optimizedNodes);
|
|
548
|
+
const duration = performance.now() - start;
|
|
549
|
+
const nodesSizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
|
|
550
|
+
_logger().default.verbose({
|
|
551
|
+
origin: '@atlaspack/core',
|
|
552
|
+
message: `serializeAssetNodesForNative: ${duration.toFixed(1)}ms, ${nodesSizeMB}MB nodes, ${nodes.length} nodes`
|
|
553
|
+
});
|
|
554
|
+
return nodesJson;
|
|
555
|
+
}
|
|
556
|
+
|
|
519
557
|
/**
|
|
520
558
|
* Remove null and undefined values from an object to reduce JSON size.
|
|
521
559
|
* Preserves false, 0, empty strings, and arrays.
|
|
@@ -84,6 +84,10 @@ class AtlaspackV3 {
|
|
|
84
84
|
} = bundleGraph.serializeForNative();
|
|
85
85
|
return (0, _rust().atlaspackNapiLoadBundleGraph)(this._atlaspack_napi, nodesJson, edges, publicIdByAssetId, environmentsJson);
|
|
86
86
|
}
|
|
87
|
+
updateBundleGraph(bundleGraph, changedAssetIds) {
|
|
88
|
+
const nodesJson = bundleGraph.serializeAssetNodesForNative(changedAssetIds);
|
|
89
|
+
return (0, _rust().atlaspackNapiUpdateBundleGraph)(this._atlaspack_napi, nodesJson);
|
|
90
|
+
}
|
|
87
91
|
package(bundleId) {
|
|
88
92
|
return (0, _rust().atlaspackNapiPackage)(this._atlaspack_napi, bundleId);
|
|
89
93
|
}
|
|
@@ -62,7 +62,8 @@ async function run({
|
|
|
62
62
|
let {
|
|
63
63
|
bundleGraph,
|
|
64
64
|
changedAssets,
|
|
65
|
-
assetRequests
|
|
65
|
+
assetRequests,
|
|
66
|
+
didIncrementallyBundle
|
|
66
67
|
} = await api.runRequest(bundleGraphRequest, {
|
|
67
68
|
force: Boolean(rustAtlaspack) || options.shouldBuildLazily && requestedAssetIds.size > 0
|
|
68
69
|
});
|
|
@@ -75,7 +76,12 @@ async function run({
|
|
|
75
76
|
}
|
|
76
77
|
});
|
|
77
78
|
if (hasSupportedTarget) {
|
|
78
|
-
|
|
79
|
+
if (didIncrementallyBundle) {
|
|
80
|
+
const changedAssetIds = Array.from(changedAssets.keys());
|
|
81
|
+
await rustAtlaspack.updateBundleGraph(bundleGraph, changedAssetIds);
|
|
82
|
+
} else {
|
|
83
|
+
await rustAtlaspack.loadBundleGraph(bundleGraph);
|
|
84
|
+
}
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
|
|
@@ -260,6 +260,7 @@ class BundlerRunner {
|
|
|
260
260
|
type: 'buildProgress',
|
|
261
261
|
phase: 'bundling'
|
|
262
262
|
});
|
|
263
|
+
let didIncrementallyBundle = false;
|
|
263
264
|
await this.loadConfigs();
|
|
264
265
|
let plugin = await this.config.getBundler();
|
|
265
266
|
let {
|
|
@@ -292,6 +293,7 @@ class BundlerRunner {
|
|
|
292
293
|
(0, _assert().default)(changedAssetNode.type === 'asset');
|
|
293
294
|
internalBundleGraph.updateAsset(changedAssetNode);
|
|
294
295
|
}
|
|
296
|
+
didIncrementallyBundle = true;
|
|
295
297
|
} else {
|
|
296
298
|
var _this$configs$get;
|
|
297
299
|
internalBundleGraph = _BundleGraph.default.fromAssetGraph(graph, this.options.mode === 'production');
|
|
@@ -358,7 +360,8 @@ class BundlerRunner {
|
|
|
358
360
|
bundleGraph: internalBundleGraph,
|
|
359
361
|
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
360
362
|
changedAssets: new Map(),
|
|
361
|
-
assetRequests: []
|
|
363
|
+
assetRequests: [],
|
|
364
|
+
didIncrementallyBundle
|
|
362
365
|
}, this.cacheKey);
|
|
363
366
|
}
|
|
364
367
|
throw new (_diagnostic().default)({
|
|
@@ -414,13 +417,15 @@ class BundlerRunner {
|
|
|
414
417
|
bundleGraph: internalBundleGraph,
|
|
415
418
|
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
416
419
|
changedAssets: new Map(),
|
|
417
|
-
assetRequests: []
|
|
420
|
+
assetRequests: [],
|
|
421
|
+
didIncrementallyBundle
|
|
418
422
|
}, this.cacheKey);
|
|
419
423
|
return {
|
|
420
424
|
bundleGraph: internalBundleGraph,
|
|
421
425
|
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
422
426
|
changedAssets: changedRuntimes,
|
|
423
|
-
assetRequests
|
|
427
|
+
assetRequests,
|
|
428
|
+
didIncrementallyBundle
|
|
424
429
|
};
|
|
425
430
|
}
|
|
426
431
|
}
|
|
@@ -148,7 +148,8 @@ function createBundleGraphRequestRust(input) {
|
|
|
148
148
|
// Not accurate yet — ok for now.
|
|
149
149
|
assetGraphBundlingVersion: 0,
|
|
150
150
|
changedAssets: changedRuntimes,
|
|
151
|
-
assetRequests: []
|
|
151
|
+
assetRequests: [],
|
|
152
|
+
didIncrementallyBundle: false
|
|
152
153
|
};
|
|
153
154
|
},
|
|
154
155
|
input
|
|
@@ -87,6 +87,11 @@ export default class BundleGraph {
|
|
|
87
87
|
publicIdByAssetId: Record<string, string>;
|
|
88
88
|
environmentsJson: string;
|
|
89
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* Serialize only the given asset nodes for native incremental update.
|
|
92
|
+
* Same node shape and env/omit logic as serializeForNative.
|
|
93
|
+
*/
|
|
94
|
+
serializeAssetNodesForNative(assetIds: Array<string>): string;
|
|
90
95
|
/**
|
|
91
96
|
* Remove null and undefined values from an object to reduce JSON size.
|
|
92
97
|
* Preserves false, 0, empty strings, and arrays.
|
|
@@ -27,6 +27,7 @@ export declare class AtlaspackV3 {
|
|
|
27
27
|
buildAssetGraph(): Promise<any>;
|
|
28
28
|
buildBundleGraph(): Promise<any>;
|
|
29
29
|
loadBundleGraph(bundleGraph: BundleGraph): Promise<void>;
|
|
30
|
+
updateBundleGraph(bundleGraph: BundleGraph, changedAssetIds: string[]): Promise<void>;
|
|
30
31
|
package(bundleId: string): Promise<[RunPackagerRunnerResult, Diagnostic | null]>;
|
|
31
32
|
respondToFsEvents(events: Array<Event>): Promise<boolean>;
|
|
32
33
|
completeCacheSession(): Promise<CacheStats>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.16.2-canary.
|
|
3
|
+
"version": "2.16.2-canary.423+93ec10729",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,22 +22,22 @@
|
|
|
22
22
|
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@atlaspack/build-cache": "2.13.3-canary.
|
|
26
|
-
"@atlaspack/cache": "3.1.1-canary.
|
|
27
|
-
"@atlaspack/diagnostic": "2.14.1-canary.
|
|
28
|
-
"@atlaspack/events": "2.14.1-canary.
|
|
29
|
-
"@atlaspack/feature-flags": "2.14.1-canary.
|
|
30
|
-
"@atlaspack/fs": "2.14.5-canary.
|
|
31
|
-
"@atlaspack/graph": "3.4.1-canary.
|
|
32
|
-
"@atlaspack/logger": "2.14.5-canary.
|
|
33
|
-
"@atlaspack/package-manager": "2.14.5-canary.
|
|
34
|
-
"@atlaspack/plugin": "2.14.5-canary.
|
|
35
|
-
"@atlaspack/profiler": "2.14.1-canary.
|
|
36
|
-
"@atlaspack/rust": "3.2.1-canary.
|
|
37
|
-
"@atlaspack/source-map": "3.2.10-canary.
|
|
38
|
-
"@atlaspack/types": "2.14.5-canary.
|
|
39
|
-
"@atlaspack/utils": "2.14.5-canary.
|
|
40
|
-
"@atlaspack/workers": "2.14.5-canary.
|
|
25
|
+
"@atlaspack/build-cache": "2.13.3-canary.491+93ec10729",
|
|
26
|
+
"@atlaspack/cache": "3.1.1-canary.423+93ec10729",
|
|
27
|
+
"@atlaspack/diagnostic": "2.14.1-canary.491+93ec10729",
|
|
28
|
+
"@atlaspack/events": "2.14.1-canary.491+93ec10729",
|
|
29
|
+
"@atlaspack/feature-flags": "2.14.1-canary.491+93ec10729",
|
|
30
|
+
"@atlaspack/fs": "2.14.5-canary.423+93ec10729",
|
|
31
|
+
"@atlaspack/graph": "3.4.1-canary.491+93ec10729",
|
|
32
|
+
"@atlaspack/logger": "2.14.5-canary.423+93ec10729",
|
|
33
|
+
"@atlaspack/package-manager": "2.14.5-canary.423+93ec10729",
|
|
34
|
+
"@atlaspack/plugin": "2.14.5-canary.423+93ec10729",
|
|
35
|
+
"@atlaspack/profiler": "2.14.1-canary.491+93ec10729",
|
|
36
|
+
"@atlaspack/rust": "3.2.1-canary.423+93ec10729",
|
|
37
|
+
"@atlaspack/source-map": "3.2.10-canary.4202+93ec10729",
|
|
38
|
+
"@atlaspack/types": "2.14.5-canary.423+93ec10729",
|
|
39
|
+
"@atlaspack/utils": "2.14.5-canary.423+93ec10729",
|
|
40
|
+
"@atlaspack/workers": "2.14.5-canary.423+93ec10729",
|
|
41
41
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
42
42
|
"base-x": "^3.0.8",
|
|
43
43
|
"browserslist": "^4.6.6",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
62
62
|
},
|
|
63
63
|
"type": "commonjs",
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "93ec10729ad5a328b4320955357339746cd472f3"
|
|
65
65
|
}
|
package/src/BundleGraph.ts
CHANGED
|
@@ -654,6 +654,45 @@ export default class BundleGraph {
|
|
|
654
654
|
return {nodesJson, edges, publicIdByAssetId, environmentsJson};
|
|
655
655
|
}
|
|
656
656
|
|
|
657
|
+
/**
|
|
658
|
+
* Serialize only the given asset nodes for native incremental update.
|
|
659
|
+
* Same node shape and env/omit logic as serializeForNative.
|
|
660
|
+
*/
|
|
661
|
+
serializeAssetNodesForNative(assetIds: Array<string>): string {
|
|
662
|
+
const start = performance.now();
|
|
663
|
+
|
|
664
|
+
if (assetIds.length === 0) {
|
|
665
|
+
return '[]';
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
const nodes: Array<BundleGraphNode> = [];
|
|
669
|
+
for (const assetId of assetIds) {
|
|
670
|
+
const node = this._graph.getNodeByContentKey(assetId);
|
|
671
|
+
if (node?.type !== 'asset') {
|
|
672
|
+
continue;
|
|
673
|
+
}
|
|
674
|
+
const processedNode = {...node};
|
|
675
|
+
if (node.value?.env) {
|
|
676
|
+
processedNode.value = {
|
|
677
|
+
...node.value,
|
|
678
|
+
env: fromEnvironmentId(node.value.env).id,
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
nodes.push(processedNode);
|
|
682
|
+
}
|
|
683
|
+
const optimizedNodes = nodes.map((node) => this._omitNulls(node));
|
|
684
|
+
const nodesJson = JSON.stringify(optimizedNodes);
|
|
685
|
+
|
|
686
|
+
const duration = performance.now() - start;
|
|
687
|
+
const nodesSizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
|
|
688
|
+
|
|
689
|
+
logger.verbose({
|
|
690
|
+
origin: '@atlaspack/core',
|
|
691
|
+
message: `serializeAssetNodesForNative: ${duration.toFixed(1)}ms, ${nodesSizeMB}MB nodes, ${nodes.length} nodes`,
|
|
692
|
+
});
|
|
693
|
+
return nodesJson;
|
|
694
|
+
}
|
|
695
|
+
|
|
657
696
|
/**
|
|
658
697
|
* Remove null and undefined values from an object to reduce JSON size.
|
|
659
698
|
* Preserves false, 0, empty strings, and arrays.
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
atlaspackNapiCompleteSession,
|
|
7
7
|
atlaspackNapiLoadBundleGraph,
|
|
8
8
|
atlaspackNapiPackage,
|
|
9
|
+
atlaspackNapiUpdateBundleGraph,
|
|
9
10
|
AtlaspackNapi,
|
|
10
11
|
Lmdb,
|
|
11
12
|
AtlaspackNapiOptions,
|
|
@@ -119,6 +120,17 @@ export class AtlaspackV3 {
|
|
|
119
120
|
) as Promise<void>;
|
|
120
121
|
}
|
|
121
122
|
|
|
123
|
+
updateBundleGraph(
|
|
124
|
+
bundleGraph: BundleGraph,
|
|
125
|
+
changedAssetIds: string[],
|
|
126
|
+
): Promise<void> {
|
|
127
|
+
const nodesJson = bundleGraph.serializeAssetNodesForNative(changedAssetIds);
|
|
128
|
+
return atlaspackNapiUpdateBundleGraph(
|
|
129
|
+
this._atlaspack_napi,
|
|
130
|
+
nodesJson,
|
|
131
|
+
) as Promise<void>;
|
|
132
|
+
}
|
|
133
|
+
|
|
122
134
|
package(
|
|
123
135
|
bundleId: string,
|
|
124
136
|
): Promise<[RunPackagerRunnerResult, Diagnostic | null]> {
|
|
@@ -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,
|
|
@@ -77,6 +71,7 @@ export type BundleGraphResult = {
|
|
|
77
71
|
assetGraphBundlingVersion: number;
|
|
78
72
|
changedAssets: Map<string, Asset>;
|
|
79
73
|
assetRequests: Array<AssetGroup>;
|
|
74
|
+
didIncrementallyBundle: boolean;
|
|
80
75
|
};
|
|
81
76
|
|
|
82
77
|
type BundleGraphRequest = {
|
|
@@ -335,7 +330,7 @@ class BundlerRunner {
|
|
|
335
330
|
type: 'buildProgress',
|
|
336
331
|
phase: 'bundling',
|
|
337
332
|
});
|
|
338
|
-
|
|
333
|
+
let didIncrementallyBundle = false;
|
|
339
334
|
await this.loadConfigs();
|
|
340
335
|
|
|
341
336
|
let plugin = await this.config.getBundler();
|
|
@@ -373,6 +368,7 @@ class BundlerRunner {
|
|
|
373
368
|
invariant(changedAssetNode.type === 'asset');
|
|
374
369
|
internalBundleGraph.updateAsset(changedAssetNode);
|
|
375
370
|
}
|
|
371
|
+
didIncrementallyBundle = true;
|
|
376
372
|
} else {
|
|
377
373
|
internalBundleGraph = InternalBundleGraph.fromAssetGraph(
|
|
378
374
|
graph,
|
|
@@ -468,6 +464,7 @@ class BundlerRunner {
|
|
|
468
464
|
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
469
465
|
changedAssets: new Map(),
|
|
470
466
|
assetRequests: [],
|
|
467
|
+
didIncrementallyBundle,
|
|
471
468
|
},
|
|
472
469
|
this.cacheKey,
|
|
473
470
|
);
|
|
@@ -554,6 +551,7 @@ class BundlerRunner {
|
|
|
554
551
|
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
555
552
|
changedAssets: new Map(),
|
|
556
553
|
assetRequests: [],
|
|
554
|
+
didIncrementallyBundle,
|
|
557
555
|
},
|
|
558
556
|
this.cacheKey,
|
|
559
557
|
);
|
|
@@ -563,6 +561,7 @@ class BundlerRunner {
|
|
|
563
561
|
assetGraphBundlingVersion: graph.getBundlingVersion(),
|
|
564
562
|
changedAssets: changedRuntimes,
|
|
565
563
|
assetRequests,
|
|
564
|
+
didIncrementallyBundle,
|
|
566
565
|
};
|
|
567
566
|
}
|
|
568
567
|
}
|