@atlaspack/core 2.16.2-canary.267 → 2.16.2-canary.269
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.
|
@@ -27,7 +27,12 @@ function createAssetGraphRequestRust(rustAtlaspack) {
|
|
|
27
27
|
serializedAssetGraph.nodes = serializedAssetGraph.nodes.map((node) => JSON.parse(node));
|
|
28
28
|
// Updated existing nodes
|
|
29
29
|
serializedAssetGraph.updates = serializedAssetGraph.updates.map((node) => JSON.parse(node));
|
|
30
|
-
|
|
30
|
+
// Don't reuse a previous asset graph result if Rust didn't have one too
|
|
31
|
+
let prevResult = null;
|
|
32
|
+
if (serializedAssetGraph.hadPreviousGraph) {
|
|
33
|
+
prevResult =
|
|
34
|
+
await input.api.getPreviousResult();
|
|
35
|
+
}
|
|
31
36
|
let { assetGraph, changedAssets } = (0, logger_1.instrument)('atlaspack_v3_getAssetGraph', () => getAssetGraph(serializedAssetGraph, prevResult?.assetGraph));
|
|
32
37
|
let changedAssetsPropagation = new Set(changedAssets.keys());
|
|
33
38
|
let errors = (0, SymbolPropagation_1.propagateSymbols)({
|
|
@@ -62,7 +67,19 @@ function createAssetGraphRequestRust(rustAtlaspack) {
|
|
|
62
67
|
}
|
|
63
68
|
function getAssetGraph(serializedGraph, prevAssetGraph) {
|
|
64
69
|
let graph;
|
|
65
|
-
|
|
70
|
+
let reuseEdges = false;
|
|
71
|
+
if (prevAssetGraph && serializedGraph.safeToSkipBundling) {
|
|
72
|
+
graph = new AssetGraph_1.default({
|
|
73
|
+
_contentKeyToNodeId: prevAssetGraph._contentKeyToNodeId,
|
|
74
|
+
_nodeIdToContentKey: prevAssetGraph._nodeIdToContentKey,
|
|
75
|
+
nodes: prevAssetGraph.nodes,
|
|
76
|
+
rootNodeId: prevAssetGraph.rootNodeId,
|
|
77
|
+
adjacencyList: prevAssetGraph.adjacencyList,
|
|
78
|
+
});
|
|
79
|
+
reuseEdges = true;
|
|
80
|
+
}
|
|
81
|
+
else if (prevAssetGraph &&
|
|
82
|
+
(serializedGraph.updates.length > 0 || serializedGraph.nodes.length > 0)) {
|
|
66
83
|
graph = new AssetGraph_1.default({
|
|
67
84
|
_contentKeyToNodeId: prevAssetGraph._contentKeyToNodeId,
|
|
68
85
|
_nodeIdToContentKey: prevAssetGraph._nodeIdToContentKey,
|
|
@@ -72,6 +89,7 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
|
|
|
72
89
|
initialNodeCapacity: prevAssetGraph.nodes.length + 1,
|
|
73
90
|
rootNodeId: prevAssetGraph.rootNodeId,
|
|
74
91
|
});
|
|
92
|
+
graph.safeToIncrementallyBundle = false;
|
|
75
93
|
}
|
|
76
94
|
else {
|
|
77
95
|
graph = new AssetGraph_1.default({
|
|
@@ -87,10 +105,10 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
|
|
|
87
105
|
value: null,
|
|
88
106
|
});
|
|
89
107
|
graph.setRootNodeId(rootNodeId);
|
|
108
|
+
graph.safeToIncrementallyBundle = false;
|
|
90
109
|
}
|
|
91
110
|
(0, assert_1.default)(graph, 'Asset graph not initialized');
|
|
92
111
|
(0, assert_1.default)(graph.rootNodeId != null, 'Asset graph has no root node');
|
|
93
|
-
graph.safeToIncrementallyBundle = false;
|
|
94
112
|
// @ts-expect-error TS7031
|
|
95
113
|
function mapSymbols({ exported, ...symbol }) {
|
|
96
114
|
let jsSymbol = {
|
|
@@ -222,18 +240,20 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
|
|
|
222
240
|
updateNode(depNode, isUpdateNode);
|
|
223
241
|
}
|
|
224
242
|
}
|
|
225
|
-
|
|
226
|
-
let
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
fromNode
|
|
243
|
+
if (!reuseEdges) {
|
|
244
|
+
for (let i = 0; i < serializedGraph.edges.length; i += 2) {
|
|
245
|
+
let from = serializedGraph.edges[i];
|
|
246
|
+
let to = serializedGraph.edges[i + 1];
|
|
247
|
+
let fromNode = graph.getNode(from);
|
|
248
|
+
let toNode = graph.getNode(to);
|
|
249
|
+
if (fromNode?.type === 'dependency') {
|
|
250
|
+
(0, assert_1.default)(toNode?.type === 'asset');
|
|
251
|
+
}
|
|
252
|
+
if (fromNode?.type === 'asset' && toNode?.type === 'dependency') {
|
|
253
|
+
fromNode.value.dependencies.set(toNode.value.id, toNode.value);
|
|
254
|
+
}
|
|
255
|
+
graph.addEdge(from, to);
|
|
235
256
|
}
|
|
236
|
-
graph.addEdge(from, to);
|
|
237
257
|
}
|
|
238
258
|
return {
|
|
239
259
|
assetGraph: graph,
|
|
@@ -53,11 +53,19 @@ function createAssetGraphRequestRust(rustAtlaspack) {
|
|
|
53
53
|
|
|
54
54
|
// Updated existing nodes
|
|
55
55
|
serializedAssetGraph.updates = serializedAssetGraph.updates.map(node => JSON.parse(node));
|
|
56
|
-
|
|
56
|
+
|
|
57
|
+
// Don't reuse a previous asset graph result if Rust didn't have one too
|
|
58
|
+
let prevResult = null;
|
|
59
|
+
if (serializedAssetGraph.hadPreviousGraph) {
|
|
60
|
+
prevResult = await input.api.getPreviousResult();
|
|
61
|
+
}
|
|
57
62
|
let {
|
|
58
63
|
assetGraph,
|
|
59
64
|
changedAssets
|
|
60
|
-
} = (0, _logger().instrument)('atlaspack_v3_getAssetGraph', () =>
|
|
65
|
+
} = (0, _logger().instrument)('atlaspack_v3_getAssetGraph', () => {
|
|
66
|
+
var _prevResult;
|
|
67
|
+
return getAssetGraph(serializedAssetGraph, (_prevResult = prevResult) === null || _prevResult === void 0 ? void 0 : _prevResult.assetGraph);
|
|
68
|
+
});
|
|
61
69
|
let changedAssetsPropagation = new Set(changedAssets.keys());
|
|
62
70
|
let errors = (0, _SymbolPropagation.propagateSymbols)({
|
|
63
71
|
options,
|
|
@@ -92,7 +100,17 @@ function createAssetGraphRequestRust(rustAtlaspack) {
|
|
|
92
100
|
}
|
|
93
101
|
function getAssetGraph(serializedGraph, prevAssetGraph) {
|
|
94
102
|
let graph;
|
|
95
|
-
|
|
103
|
+
let reuseEdges = false;
|
|
104
|
+
if (prevAssetGraph && serializedGraph.safeToSkipBundling) {
|
|
105
|
+
graph = new _AssetGraph.default({
|
|
106
|
+
_contentKeyToNodeId: prevAssetGraph._contentKeyToNodeId,
|
|
107
|
+
_nodeIdToContentKey: prevAssetGraph._nodeIdToContentKey,
|
|
108
|
+
nodes: prevAssetGraph.nodes,
|
|
109
|
+
rootNodeId: prevAssetGraph.rootNodeId,
|
|
110
|
+
adjacencyList: prevAssetGraph.adjacencyList
|
|
111
|
+
});
|
|
112
|
+
reuseEdges = true;
|
|
113
|
+
} else if (prevAssetGraph && (serializedGraph.updates.length > 0 || serializedGraph.nodes.length > 0)) {
|
|
96
114
|
graph = new _AssetGraph.default({
|
|
97
115
|
_contentKeyToNodeId: prevAssetGraph._contentKeyToNodeId,
|
|
98
116
|
_nodeIdToContentKey: prevAssetGraph._nodeIdToContentKey,
|
|
@@ -102,6 +120,7 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
|
|
|
102
120
|
initialNodeCapacity: prevAssetGraph.nodes.length + 1,
|
|
103
121
|
rootNodeId: prevAssetGraph.rootNodeId
|
|
104
122
|
});
|
|
123
|
+
graph.safeToIncrementallyBundle = false;
|
|
105
124
|
} else {
|
|
106
125
|
graph = new _AssetGraph.default({
|
|
107
126
|
_contentKeyToNodeId: new Map(),
|
|
@@ -116,10 +135,10 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
|
|
|
116
135
|
value: null
|
|
117
136
|
});
|
|
118
137
|
graph.setRootNodeId(rootNodeId);
|
|
138
|
+
graph.safeToIncrementallyBundle = false;
|
|
119
139
|
}
|
|
120
140
|
(0, _assert().default)(graph, 'Asset graph not initialized');
|
|
121
141
|
(0, _assert().default)(graph.rootNodeId != null, 'Asset graph has no root node');
|
|
122
|
-
graph.safeToIncrementallyBundle = false;
|
|
123
142
|
|
|
124
143
|
// @ts-expect-error TS7031
|
|
125
144
|
function mapSymbols({
|
|
@@ -243,18 +262,20 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
|
|
|
243
262
|
updateNode(depNode, isUpdateNode);
|
|
244
263
|
}
|
|
245
264
|
}
|
|
246
|
-
|
|
247
|
-
let
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
fromNode.
|
|
265
|
+
if (!reuseEdges) {
|
|
266
|
+
for (let i = 0; i < serializedGraph.edges.length; i += 2) {
|
|
267
|
+
let from = serializedGraph.edges[i];
|
|
268
|
+
let to = serializedGraph.edges[i + 1];
|
|
269
|
+
let fromNode = graph.getNode(from);
|
|
270
|
+
let toNode = graph.getNode(to);
|
|
271
|
+
if ((fromNode === null || fromNode === void 0 ? void 0 : fromNode.type) === 'dependency') {
|
|
272
|
+
(0, _assert().default)((toNode === null || toNode === void 0 ? void 0 : toNode.type) === 'asset');
|
|
273
|
+
}
|
|
274
|
+
if ((fromNode === null || fromNode === void 0 ? void 0 : fromNode.type) === 'asset' && (toNode === null || toNode === void 0 ? void 0 : toNode.type) === 'dependency') {
|
|
275
|
+
fromNode.value.dependencies.set(toNode.value.id, toNode.value);
|
|
276
|
+
}
|
|
277
|
+
graph.addEdge(from, to);
|
|
256
278
|
}
|
|
257
|
-
graph.addEdge(from, to);
|
|
258
279
|
}
|
|
259
280
|
return {
|
|
260
281
|
assetGraph: graph,
|
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.269+cfb470708",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,21 +22,21 @@
|
|
|
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/types": "2.14.5-canary.
|
|
38
|
-
"@atlaspack/utils": "2.14.5-canary.
|
|
39
|
-
"@atlaspack/workers": "2.14.5-canary.
|
|
25
|
+
"@atlaspack/build-cache": "2.13.3-canary.337+cfb470708",
|
|
26
|
+
"@atlaspack/cache": "3.1.1-canary.269+cfb470708",
|
|
27
|
+
"@atlaspack/diagnostic": "2.14.1-canary.337+cfb470708",
|
|
28
|
+
"@atlaspack/events": "2.14.1-canary.337+cfb470708",
|
|
29
|
+
"@atlaspack/feature-flags": "2.14.1-canary.337+cfb470708",
|
|
30
|
+
"@atlaspack/fs": "2.14.5-canary.269+cfb470708",
|
|
31
|
+
"@atlaspack/graph": "3.4.1-canary.337+cfb470708",
|
|
32
|
+
"@atlaspack/logger": "2.14.5-canary.269+cfb470708",
|
|
33
|
+
"@atlaspack/package-manager": "2.14.5-canary.269+cfb470708",
|
|
34
|
+
"@atlaspack/plugin": "2.14.5-canary.269+cfb470708",
|
|
35
|
+
"@atlaspack/profiler": "2.14.1-canary.337+cfb470708",
|
|
36
|
+
"@atlaspack/rust": "3.2.1-canary.269+cfb470708",
|
|
37
|
+
"@atlaspack/types": "2.14.5-canary.269+cfb470708",
|
|
38
|
+
"@atlaspack/utils": "2.14.5-canary.269+cfb470708",
|
|
39
|
+
"@atlaspack/workers": "2.14.5-canary.269+cfb470708",
|
|
40
40
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
41
41
|
"@parcel/source-map": "^2.1.1",
|
|
42
42
|
"base-x": "^3.0.8",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
62
62
|
},
|
|
63
63
|
"type": "commonjs",
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "cfb4707087498e4fa4dcf10753fe984a248d196b"
|
|
65
65
|
}
|
|
@@ -24,7 +24,6 @@ import type {
|
|
|
24
24
|
import {toEnvironmentRef} from '../EnvironmentManager';
|
|
25
25
|
import {getEnvironmentHash} from '../Environment';
|
|
26
26
|
import dumpGraphToGraphViz from '../dumpGraphToGraphViz';
|
|
27
|
-
import nullthrows from 'nullthrows';
|
|
28
27
|
import assert from 'assert';
|
|
29
28
|
|
|
30
29
|
type RunInput = {
|
|
@@ -42,6 +41,8 @@ type SerializedAssetGraphDelta = {
|
|
|
42
41
|
nodes: Array<any>;
|
|
43
42
|
edges: Array<string>;
|
|
44
43
|
updates: Array<any>;
|
|
44
|
+
safeToSkipBundling: boolean;
|
|
45
|
+
hadPreviousGraph: boolean;
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
export function createAssetGraphRequestRust(
|
|
@@ -65,8 +66,12 @@ export function createAssetGraphRequestRust(
|
|
|
65
66
|
JSON.parse(node),
|
|
66
67
|
);
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
// Don't reuse a previous asset graph result if Rust didn't have one too
|
|
70
|
+
let prevResult = null;
|
|
71
|
+
if (serializedAssetGraph.hadPreviousGraph) {
|
|
72
|
+
prevResult =
|
|
73
|
+
await input.api.getPreviousResult<AssetGraphRequestResult>();
|
|
74
|
+
}
|
|
70
75
|
|
|
71
76
|
let {assetGraph, changedAssets} = instrument(
|
|
72
77
|
'atlaspack_v3_getAssetGraph',
|
|
@@ -119,7 +124,21 @@ export function getAssetGraph(
|
|
|
119
124
|
} {
|
|
120
125
|
let graph: AssetGraph;
|
|
121
126
|
|
|
122
|
-
|
|
127
|
+
let reuseEdges = false;
|
|
128
|
+
|
|
129
|
+
if (prevAssetGraph && serializedGraph.safeToSkipBundling) {
|
|
130
|
+
graph = new AssetGraph({
|
|
131
|
+
_contentKeyToNodeId: prevAssetGraph._contentKeyToNodeId,
|
|
132
|
+
_nodeIdToContentKey: prevAssetGraph._nodeIdToContentKey,
|
|
133
|
+
nodes: prevAssetGraph.nodes,
|
|
134
|
+
rootNodeId: prevAssetGraph.rootNodeId,
|
|
135
|
+
adjacencyList: prevAssetGraph.adjacencyList,
|
|
136
|
+
});
|
|
137
|
+
reuseEdges = true;
|
|
138
|
+
} else if (
|
|
139
|
+
prevAssetGraph &&
|
|
140
|
+
(serializedGraph.updates.length > 0 || serializedGraph.nodes.length > 0)
|
|
141
|
+
) {
|
|
123
142
|
graph = new AssetGraph({
|
|
124
143
|
_contentKeyToNodeId: prevAssetGraph._contentKeyToNodeId,
|
|
125
144
|
_nodeIdToContentKey: prevAssetGraph._nodeIdToContentKey,
|
|
@@ -129,6 +148,7 @@ export function getAssetGraph(
|
|
|
129
148
|
initialNodeCapacity: prevAssetGraph.nodes.length + 1,
|
|
130
149
|
rootNodeId: prevAssetGraph.rootNodeId,
|
|
131
150
|
});
|
|
151
|
+
graph.safeToIncrementallyBundle = false;
|
|
132
152
|
} else {
|
|
133
153
|
graph = new AssetGraph({
|
|
134
154
|
_contentKeyToNodeId: new Map(),
|
|
@@ -145,13 +165,12 @@ export function getAssetGraph(
|
|
|
145
165
|
});
|
|
146
166
|
|
|
147
167
|
graph.setRootNodeId(rootNodeId);
|
|
168
|
+
graph.safeToIncrementallyBundle = false;
|
|
148
169
|
}
|
|
149
170
|
|
|
150
171
|
invariant(graph, 'Asset graph not initialized');
|
|
151
172
|
invariant(graph.rootNodeId != null, 'Asset graph has no root node');
|
|
152
173
|
|
|
153
|
-
graph.safeToIncrementallyBundle = false;
|
|
154
|
-
|
|
155
174
|
// @ts-expect-error TS7031
|
|
156
175
|
function mapSymbols({exported, ...symbol}) {
|
|
157
176
|
let jsSymbol = {
|
|
@@ -307,21 +326,23 @@ export function getAssetGraph(
|
|
|
307
326
|
}
|
|
308
327
|
}
|
|
309
328
|
|
|
310
|
-
|
|
311
|
-
let
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
329
|
+
if (!reuseEdges) {
|
|
330
|
+
for (let i = 0; i < serializedGraph.edges.length; i += 2) {
|
|
331
|
+
let from = serializedGraph.edges[i];
|
|
332
|
+
let to = serializedGraph.edges[i + 1];
|
|
333
|
+
let fromNode = graph.getNode(from);
|
|
334
|
+
let toNode = graph.getNode(to);
|
|
315
335
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
336
|
+
if (fromNode?.type === 'dependency') {
|
|
337
|
+
invariant(toNode?.type === 'asset');
|
|
338
|
+
}
|
|
319
339
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
340
|
+
if (fromNode?.type === 'asset' && toNode?.type === 'dependency') {
|
|
341
|
+
fromNode.value.dependencies.set(toNode.value.id, toNode.value);
|
|
342
|
+
}
|
|
323
343
|
|
|
324
|
-
|
|
344
|
+
graph.addEdge(from, to);
|
|
345
|
+
}
|
|
325
346
|
}
|
|
326
347
|
|
|
327
348
|
return {
|