@atlaspack/core 2.38.3-dev-862af7d26.0 → 2.38.4
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/BundleGraph.js +4 -3
- package/dist/SymbolPropagation.js +8 -4
- package/dist/requests/AssetGraphRequestRust.js +169 -72
- package/lib/BundleGraph.js +6 -6
- package/lib/SymbolPropagation.js +8 -8
- package/lib/requests/AssetGraphRequestRust.js +157 -68
- package/package.json +21 -22
- package/src/BundleGraph.ts +5 -3
- package/src/SymbolPropagation.ts +14 -5
- package/src/requests/AssetGraphRequestRust.ts +195 -79
- package/tsconfig.tsbuildinfo +1 -1
- package/LICENSE +0 -201
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @atlaspack/core
|
|
2
2
|
|
|
3
|
+
## 2.38.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1080](https://github.com/atlassian-labs/atlaspack/pull/1080) [`39b1fdf`](https://github.com/atlassian-labs/atlaspack/commit/39b1fdf59d317a9e862dceba0495dda9f1fda77c) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Fix scope hoisting crash when a module has both `import * as ns from 'x'` and `export * from 'x'` for the same specifier. The wildcard re-export was overwriting the namespace import binding on the shared dependency, causing a ReferenceError in the bundled output. Gated behind `fixExportStarNamespaceOverwrite` feature flag.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`39b1fdf`](https://github.com/atlassian-labs/atlaspack/commit/39b1fdf59d317a9e862dceba0495dda9f1fda77c)]:
|
|
10
|
+
- @atlaspack/feature-flags@2.31.2
|
|
11
|
+
- @atlaspack/rust@3.29.1
|
|
12
|
+
- @atlaspack/build-cache@2.13.16
|
|
13
|
+
- @atlaspack/cache@3.2.57
|
|
14
|
+
- @atlaspack/fs@2.15.57
|
|
15
|
+
- @atlaspack/graph@3.6.24
|
|
16
|
+
- @atlaspack/utils@3.4.4
|
|
17
|
+
- @atlaspack/logger@2.14.54
|
|
18
|
+
- @atlaspack/source-map@3.3.6
|
|
19
|
+
- @atlaspack/package-manager@2.14.62
|
|
20
|
+
- @atlaspack/workers@2.14.62
|
|
21
|
+
- @atlaspack/plugin@2.14.62
|
|
22
|
+
- @atlaspack/profiler@2.15.23
|
|
23
|
+
- @atlaspack/types@2.15.52
|
|
24
|
+
|
|
25
|
+
## 2.38.3
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [#1065](https://github.com/atlassian-labs/atlaspack/pull/1065) [`e898fda`](https://github.com/atlassian-labs/atlaspack/commit/e898fda7511d98e5597d847c4a32c028a8a24d6c) Thanks [@at-nathan](https://github.com/at-nathan)! - Update third-party dependencies to align with AFM
|
|
30
|
+
|
|
31
|
+
- [#1073](https://github.com/atlassian-labs/atlaspack/pull/1073) [`3ff901a`](https://github.com/atlassian-labs/atlaspack/commit/3ff901a222d5e077a3bb96031a89c3b5173ece69) Thanks [@matt-koko](https://github.com/matt-koko)! - Improve Rust/JS asset graph interop for atlaspack v3 by reducing scenarios where Rust/JS can diverge their respective previous asset graphs.
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [[`07edc83`](https://github.com/atlassian-labs/atlaspack/commit/07edc83079f6a752b09b28a9fe8b45f6523f0f81), [`e898fda`](https://github.com/atlassian-labs/atlaspack/commit/e898fda7511d98e5597d847c4a32c028a8a24d6c), [`3ff901a`](https://github.com/atlassian-labs/atlaspack/commit/3ff901a222d5e077a3bb96031a89c3b5173ece69), [`e8fe5c0`](https://github.com/atlassian-labs/atlaspack/commit/e8fe5c0070f0d92d68f98902edcc96dc82c1e52d), [`ff7e3f0`](https://github.com/atlassian-labs/atlaspack/commit/ff7e3f08c3977b0d9b9edfe739a8e596abbdd729), [`508e15c`](https://github.com/atlassian-labs/atlaspack/commit/508e15c7acd187703bade4d613ca7f5739ae3af7), [`34c7cec`](https://github.com/atlassian-labs/atlaspack/commit/34c7cecebae240f11f36971b4eeaeaaf579531c9), [`5256d37`](https://github.com/atlassian-labs/atlaspack/commit/5256d37a88334554ae78456622389c97f66a2196)]:
|
|
34
|
+
- @atlaspack/rust@3.29.0
|
|
35
|
+
- @atlaspack/cache@3.2.56
|
|
36
|
+
- @atlaspack/utils@3.4.3
|
|
37
|
+
- @atlaspack/feature-flags@2.31.1
|
|
38
|
+
- @atlaspack/fs@2.15.56
|
|
39
|
+
- @atlaspack/logger@2.14.53
|
|
40
|
+
- @atlaspack/source-map@3.3.5
|
|
41
|
+
- @atlaspack/package-manager@2.14.61
|
|
42
|
+
- @atlaspack/profiler@2.15.22
|
|
43
|
+
- @atlaspack/workers@2.14.61
|
|
44
|
+
- @atlaspack/build-cache@2.13.15
|
|
45
|
+
- @atlaspack/graph@3.6.23
|
|
46
|
+
- @atlaspack/types@2.15.51
|
|
47
|
+
- @atlaspack/plugin@2.14.61
|
|
48
|
+
|
|
3
49
|
## 2.38.2
|
|
4
50
|
|
|
5
51
|
### Patch Changes
|
package/dist/BundleGraph.js
CHANGED
|
@@ -199,7 +199,8 @@ class BundleGraph {
|
|
|
199
199
|
// Don't retarget because this cannot be resolved without also changing the asset symbols
|
|
200
200
|
// (and the asset content itself).
|
|
201
201
|
[...targets].every(([, t]) => new Set([...t.values()]).size === t.size)) {
|
|
202
|
-
let isReexportAll = nodeValueSymbols.get('*')?.local === '*'
|
|
202
|
+
let isReexportAll = nodeValueSymbols.get('*')?.local === '*' ||
|
|
203
|
+
node.value.meta?.hasExportStar;
|
|
203
204
|
let reexportAllLoc = isReexportAll
|
|
204
205
|
? (0, nullthrows_1.default)(nodeValueSymbols.get('*')).loc
|
|
205
206
|
: undefined;
|
|
@@ -1565,7 +1566,7 @@ class BundleGraph {
|
|
|
1565
1566
|
// Default exports are excluded from wildcard exports.
|
|
1566
1567
|
// Wildcard reexports are never listed in the reexporting asset's symbols.
|
|
1567
1568
|
if (identifier == null &&
|
|
1568
|
-
depSymbols.get('*')?.local === '*' &&
|
|
1569
|
+
(depSymbols.get('*')?.local === '*' || dep.meta?.hasExportStar) &&
|
|
1569
1570
|
symbol !== 'default') {
|
|
1570
1571
|
let resolved = this.getResolvedAsset(dep, boundary);
|
|
1571
1572
|
if (!resolved) {
|
|
@@ -1694,7 +1695,7 @@ class BundleGraph {
|
|
|
1694
1695
|
let depSymbols = dep.symbols;
|
|
1695
1696
|
if (!depSymbols)
|
|
1696
1697
|
continue;
|
|
1697
|
-
if (depSymbols.get('*')?.local === '*') {
|
|
1698
|
+
if (depSymbols.get('*')?.local === '*' || dep.meta?.hasExportStar) {
|
|
1698
1699
|
let resolved = this.getResolvedAsset(dep, boundary);
|
|
1699
1700
|
if (!resolved)
|
|
1700
1701
|
continue;
|
|
@@ -49,7 +49,8 @@ function propagateSymbols({ options, assetGraph, changedAssetsPropagation, asset
|
|
|
49
49
|
set.add(s);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
let hasNamespaceOutgoingDeps = outgoingDeps.some((d) => d.value.symbols?.get('*')?.local === '*'
|
|
52
|
+
let hasNamespaceOutgoingDeps = outgoingDeps.some((d) => d.value.symbols?.get('*')?.local === '*' ||
|
|
53
|
+
d.value.meta?.hasExportStar);
|
|
53
54
|
// 1) Determine what the incomingDeps requests from the asset
|
|
54
55
|
// ----------------------------------------------------------
|
|
55
56
|
let isEntry = false;
|
|
@@ -124,7 +125,8 @@ function propagateSymbols({ options, assetGraph, changedAssetsPropagation, asset
|
|
|
124
125
|
let depSymbols = dep.value.symbols;
|
|
125
126
|
if (!depSymbols)
|
|
126
127
|
continue;
|
|
127
|
-
if (depSymbols.get('*')?.local === '*'
|
|
128
|
+
if (depSymbols.get('*')?.local === '*' ||
|
|
129
|
+
dep.value.meta?.hasExportStar) {
|
|
128
130
|
if (addAll) {
|
|
129
131
|
depUsedSymbolsDown.add('*');
|
|
130
132
|
}
|
|
@@ -220,7 +222,8 @@ function propagateSymbols({ options, assetGraph, changedAssetsPropagation, asset
|
|
|
220
222
|
if (isExcluded) {
|
|
221
223
|
outgoingDep.usedSymbolsDown.forEach((_, s) => outgoingDep.usedSymbolsUp.set(s, null));
|
|
222
224
|
}
|
|
223
|
-
if (outgoingDepSymbols.get('*')?.local === '*'
|
|
225
|
+
if (outgoingDepSymbols.get('*')?.local === '*' ||
|
|
226
|
+
outgoingDep.value.meta?.hasExportStar) {
|
|
224
227
|
outgoingDep.usedSymbolsUp.forEach((sResolved, s) => {
|
|
225
228
|
if (s === 'default') {
|
|
226
229
|
return;
|
|
@@ -289,7 +292,8 @@ function propagateSymbols({ options, assetGraph, changedAssetsPropagation, asset
|
|
|
289
292
|
let incomingDepSymbols = incomingDep.value.symbols;
|
|
290
293
|
if (!incomingDepSymbols)
|
|
291
294
|
continue;
|
|
292
|
-
let hasNamespaceReexport = incomingDepSymbols.get('*')?.local === '*'
|
|
295
|
+
let hasNamespaceReexport = incomingDepSymbols.get('*')?.local === '*' ||
|
|
296
|
+
incomingDep.value.meta?.hasExportStar;
|
|
293
297
|
for (let s of incomingDep.usedSymbolsDown) {
|
|
294
298
|
if (assetSymbols == null || // Assume everything could be provided if symbols are cleared
|
|
295
299
|
assetNode.value.bundleBehavior === types_1.BundleBehavior.isolated ||
|
|
@@ -74,30 +74,6 @@ function createAssetGraphRequestRust(rustAtlaspack) {
|
|
|
74
74
|
}
|
|
75
75
|
let { assetGraph, changedAssets } = (0, logger_1.instrument)('atlaspack_v3_getAssetGraph', () => getAssetGraph(serializedAssetGraph, prevResult?.assetGraph));
|
|
76
76
|
let changedAssetsPropagation = new Set(changedAssets.keys());
|
|
77
|
-
// Skip symbol propagation for runtime assets - they have pre-computed symbol data
|
|
78
|
-
if (input.skipSymbolProp) {
|
|
79
|
-
logger_1.default.verbose({
|
|
80
|
-
origin: '@atlaspack/core',
|
|
81
|
-
message: 'Skipping symbol propagation for runtime asset graph',
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
let errors = (0, SymbolPropagation_1.propagateSymbols)({
|
|
86
|
-
options,
|
|
87
|
-
assetGraph,
|
|
88
|
-
changedAssetsPropagation,
|
|
89
|
-
assetGroupsWithRemovedParents: new Set(),
|
|
90
|
-
previousErrors: new Map(), //this.previousSymbolPropagationErrors,
|
|
91
|
-
});
|
|
92
|
-
if (errors.size > 0) {
|
|
93
|
-
// Just throw the first error. Since errors can bubble (e.g. reexporting a reexported symbol also fails),
|
|
94
|
-
// determining which failing export is the root cause is nontrivial (because of circular dependencies).
|
|
95
|
-
throw new diagnostic_1.default({
|
|
96
|
-
diagnostic: [...errors.values()][0],
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
await (0, dumpGraphToGraphViz_1.default)(assetGraph, 'AssetGraphV3');
|
|
101
77
|
let result = {
|
|
102
78
|
assetGraph,
|
|
103
79
|
assetRequests: [],
|
|
@@ -106,16 +82,56 @@ function createAssetGraphRequestRust(rustAtlaspack) {
|
|
|
106
82
|
changedAssetsPropagation,
|
|
107
83
|
previousSymbolPropagationErrors: undefined,
|
|
108
84
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
85
|
+
// When v3AssetGraphSyncImprovements is enabled, wrap downstream steps
|
|
86
|
+
// in try/catch and store the result even on error. This prevents Rust/JS
|
|
87
|
+
// divergence when symbol propagation or commit_assets fails.
|
|
88
|
+
let storeResultOnError = (0, feature_flags_1.getFeatureFlag)('v3AssetGraphSyncImprovements');
|
|
89
|
+
try {
|
|
90
|
+
// Skip symbol propagation for runtime assets - they have pre-computed symbol data
|
|
91
|
+
if (input.skipSymbolProp) {
|
|
92
|
+
logger_1.default.verbose({
|
|
93
|
+
origin: '@atlaspack/core',
|
|
94
|
+
message: 'Skipping symbol propagation for runtime asset graph',
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
let errors = (0, SymbolPropagation_1.propagateSymbols)({
|
|
99
|
+
options,
|
|
100
|
+
assetGraph,
|
|
101
|
+
changedAssetsPropagation,
|
|
102
|
+
assetGroupsWithRemovedParents: new Set(),
|
|
103
|
+
previousErrors: new Map(), //this.previousSymbolPropagationErrors,
|
|
104
|
+
});
|
|
105
|
+
if (errors.size > 0) {
|
|
106
|
+
// Just throw the first error. Since errors can bubble (e.g. reexporting a reexported symbol also fails),
|
|
107
|
+
// determining which failing export is the root cause is nontrivial (because of circular dependencies).
|
|
108
|
+
throw new diagnostic_1.default({
|
|
109
|
+
diagnostic: [...errors.values()][0],
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
await (0, dumpGraphToGraphViz_1.default)(assetGraph, 'AssetGraphV3');
|
|
114
|
+
let [_commitResult, commitError] = await commitPromise;
|
|
115
|
+
if (commitError) {
|
|
116
|
+
throw new diagnostic_1.default({
|
|
117
|
+
diagnostic: {
|
|
118
|
+
message: 'Error committing asset graph in Rust: ' + commitError.message,
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
await runInput.api.storeResult(result);
|
|
123
|
+
runInput.api.invalidateOnBuild();
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
if (storeResultOnError) {
|
|
127
|
+
// Store the graph even on error to prevent Rust/JS divergence.
|
|
128
|
+
// The graph from getAssetGraph is structurally correct — only
|
|
129
|
+
// downstream processing (symbols, commit) failed.
|
|
130
|
+
await runInput.api.storeResult(result);
|
|
131
|
+
runInput.api.invalidateOnBuild();
|
|
132
|
+
}
|
|
133
|
+
throw e;
|
|
116
134
|
}
|
|
117
|
-
await runInput.api.storeResult(result);
|
|
118
|
-
runInput.api.invalidateOnBuild();
|
|
119
135
|
return result;
|
|
120
136
|
},
|
|
121
137
|
input,
|
|
@@ -124,27 +140,52 @@ function createAssetGraphRequestRust(rustAtlaspack) {
|
|
|
124
140
|
function getAssetGraph(serializedGraph, prevAssetGraph) {
|
|
125
141
|
let graph;
|
|
126
142
|
let reuseEdges = false;
|
|
143
|
+
let clonePrevGraph = (0, feature_flags_1.getFeatureFlag)('v3AssetGraphSyncImprovements');
|
|
127
144
|
if (prevAssetGraph && serializedGraph.safeToSkipBundling) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
145
|
+
if (clonePrevGraph) {
|
|
146
|
+
graph = new AssetGraph_1.default({
|
|
147
|
+
_contentKeyToNodeId: new Map(prevAssetGraph._contentKeyToNodeId),
|
|
148
|
+
_nodeIdToContentKey: new Map(prevAssetGraph._nodeIdToContentKey),
|
|
149
|
+
nodes: [...prevAssetGraph.nodes],
|
|
150
|
+
rootNodeId: prevAssetGraph.rootNodeId,
|
|
151
|
+
adjacencyList: prevAssetGraph.adjacencyList,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
graph = new AssetGraph_1.default({
|
|
156
|
+
_contentKeyToNodeId: prevAssetGraph._contentKeyToNodeId,
|
|
157
|
+
_nodeIdToContentKey: prevAssetGraph._nodeIdToContentKey,
|
|
158
|
+
nodes: prevAssetGraph.nodes,
|
|
159
|
+
rootNodeId: prevAssetGraph.rootNodeId,
|
|
160
|
+
adjacencyList: prevAssetGraph.adjacencyList,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
135
163
|
reuseEdges = true;
|
|
136
164
|
}
|
|
137
165
|
else if (prevAssetGraph &&
|
|
138
166
|
(serializedGraph.updates.length > 0 || serializedGraph.nodes.length > 0)) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
167
|
+
if (clonePrevGraph) {
|
|
168
|
+
graph = new AssetGraph_1.default({
|
|
169
|
+
_contentKeyToNodeId: new Map(prevAssetGraph._contentKeyToNodeId),
|
|
170
|
+
_nodeIdToContentKey: new Map(prevAssetGraph._nodeIdToContentKey),
|
|
171
|
+
nodes: [...prevAssetGraph.nodes],
|
|
172
|
+
initialCapacity: serializedGraph.edges.length,
|
|
173
|
+
// Accomodate the root node
|
|
174
|
+
initialNodeCapacity: prevAssetGraph.nodes.length + 1,
|
|
175
|
+
rootNodeId: prevAssetGraph.rootNodeId,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
graph = new AssetGraph_1.default({
|
|
180
|
+
_contentKeyToNodeId: prevAssetGraph._contentKeyToNodeId,
|
|
181
|
+
_nodeIdToContentKey: prevAssetGraph._nodeIdToContentKey,
|
|
182
|
+
nodes: prevAssetGraph.nodes,
|
|
183
|
+
initialCapacity: serializedGraph.edges.length,
|
|
184
|
+
// Accomodate the root node
|
|
185
|
+
initialNodeCapacity: prevAssetGraph.nodes.length + 1,
|
|
186
|
+
rootNodeId: prevAssetGraph.rootNodeId,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
148
189
|
graph.safeToIncrementallyBundle = false;
|
|
149
190
|
}
|
|
150
191
|
else {
|
|
@@ -228,36 +269,92 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
|
|
|
228
269
|
}
|
|
229
270
|
return base;
|
|
230
271
|
}
|
|
272
|
+
function buildDivergenceDiagnostics(divergenceType, newNode, existingNode, index) {
|
|
273
|
+
return {
|
|
274
|
+
contentKey: newNode.id,
|
|
275
|
+
divergenceType,
|
|
276
|
+
newNode: describeNode(newNode),
|
|
277
|
+
existingNode: existingNode ? describeNode(existingNode) : null,
|
|
278
|
+
iterationIndex: index,
|
|
279
|
+
totalSerializedNodes: nodesCount,
|
|
280
|
+
newNodesCount: serializedGraph.nodes.length,
|
|
281
|
+
updatesCount: serializedGraph.updates.length,
|
|
282
|
+
edgesCount: serializedGraph.edges.length,
|
|
283
|
+
hadPreviousGraph: !!prevAssetGraph,
|
|
284
|
+
safeToSkipBundling: serializedGraph.safeToSkipBundling,
|
|
285
|
+
graphNodeCount: graph._contentKeyToNodeId.size,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
231
288
|
function updateNode(newNode, isUpdateNode, index) {
|
|
289
|
+
let healDivergence = (0, feature_flags_1.getFeatureFlag)('v3AssetGraphSyncImprovements');
|
|
232
290
|
if (isUpdateNode) {
|
|
233
291
|
let existingNode = graph.getNodeByContentKey(newNode.id);
|
|
234
|
-
(
|
|
235
|
-
|
|
292
|
+
if (healDivergence) {
|
|
293
|
+
if (existingNode) {
|
|
294
|
+
(0, assert_2.default)(existingNode.type === newNode.type);
|
|
295
|
+
Object.assign(existingNode, newNode);
|
|
296
|
+
}
|
|
297
|
+
else {
|
|
298
|
+
// Rust sent an update for a node JS doesn't have.
|
|
299
|
+
// This means JS's graph is stale. Add the node as new instead.
|
|
300
|
+
// This handles the "undefined == true" error class.
|
|
301
|
+
let diagnostics = buildDivergenceDiagnostics('update_node_not_found', newNode, existingNode, index);
|
|
302
|
+
logger_1.default.warn({
|
|
303
|
+
origin: '@atlaspack/core',
|
|
304
|
+
message: `Rust/JS asset graph divergence healed: update node not found, ` +
|
|
305
|
+
`adding as new. contentKey=${newNode.id} type=${newNode.type} iterationIndex=${index}`,
|
|
306
|
+
meta: {
|
|
307
|
+
trackableEvent: 'asset_graph_divergence_healed',
|
|
308
|
+
...diagnostics,
|
|
309
|
+
},
|
|
310
|
+
});
|
|
311
|
+
graph.addNodeByContentKey(newNode.id, newNode);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
(0, assert_2.default)(existingNode && existingNode.type === newNode.type);
|
|
316
|
+
Object.assign(existingNode, newNode);
|
|
317
|
+
}
|
|
236
318
|
}
|
|
237
319
|
else {
|
|
238
|
-
|
|
239
|
-
graph.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
320
|
+
if (healDivergence) {
|
|
321
|
+
if (graph.hasContentKey(newNode.id)) {
|
|
322
|
+
// Rust sent a "new" node that JS already has.
|
|
323
|
+
// This means JS's graph has nodes that Rust considers new.
|
|
324
|
+
// Treat as an update instead of throwing.
|
|
325
|
+
// This handles the "Graph already has content key" error class.
|
|
244
326
|
let existingNode = graph.getNodeByContentKey(newNode.id);
|
|
245
|
-
let diagnostics =
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
}
|
|
258
|
-
|
|
327
|
+
let diagnostics = buildDivergenceDiagnostics('new_node_already_exists', newNode, existingNode, index);
|
|
328
|
+
logger_1.default.warn({
|
|
329
|
+
origin: '@atlaspack/core',
|
|
330
|
+
message: `Rust/JS asset graph divergence healed: new node already exists, ` +
|
|
331
|
+
`treating as update. contentKey=${newNode.id} type=${newNode.type} iterationIndex=${index}`,
|
|
332
|
+
meta: {
|
|
333
|
+
trackableEvent: 'asset_graph_divergence_healed',
|
|
334
|
+
...diagnostics,
|
|
335
|
+
},
|
|
336
|
+
});
|
|
337
|
+
if (existingNode) {
|
|
338
|
+
Object.assign(existingNode, newNode);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
graph.addNodeByContentKey(newNode.id, newNode);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
else {
|
|
346
|
+
try {
|
|
347
|
+
graph.addNodeByContentKey(newNode.id, newNode);
|
|
348
|
+
}
|
|
349
|
+
catch (e) {
|
|
350
|
+
if (e instanceof Error &&
|
|
351
|
+
e.message.includes('already has content key')) {
|
|
352
|
+
let existingNode = graph.getNodeByContentKey(newNode.id);
|
|
353
|
+
let diagnostics = buildDivergenceDiagnostics('new_node_already_exists', newNode, existingNode, index);
|
|
354
|
+
throw new Error(`Graph already has content key '${newNode.id}'. Diagnostics: ${JSON.stringify(diagnostics, null, 2)}`);
|
|
355
|
+
}
|
|
356
|
+
throw e;
|
|
259
357
|
}
|
|
260
|
-
throw e;
|
|
261
358
|
}
|
|
262
359
|
}
|
|
263
360
|
}
|
package/lib/BundleGraph.js
CHANGED
|
@@ -257,8 +257,8 @@ class BundleGraph {
|
|
|
257
257
|
// Don't retarget because this cannot be resolved without also changing the asset symbols
|
|
258
258
|
// (and the asset content itself).
|
|
259
259
|
[...targets].every(([, t]) => new Set([...t.values()]).size === t.size)) {
|
|
260
|
-
var _nodeValueSymbols$get;
|
|
261
|
-
let isReexportAll = ((_nodeValueSymbols$get = nodeValueSymbols.get('*')) === null || _nodeValueSymbols$get === void 0 ? void 0 : _nodeValueSymbols$get.local) === '*';
|
|
260
|
+
var _nodeValueSymbols$get, _node$value$meta;
|
|
261
|
+
let isReexportAll = ((_nodeValueSymbols$get = nodeValueSymbols.get('*')) === null || _nodeValueSymbols$get === void 0 ? void 0 : _nodeValueSymbols$get.local) === '*' || ((_node$value$meta = node.value.meta) === null || _node$value$meta === void 0 ? void 0 : _node$value$meta.hasExportStar);
|
|
262
262
|
let reexportAllLoc = isReexportAll ? (0, _nullthrows().default)(nodeValueSymbols.get('*')).loc : undefined;
|
|
263
263
|
|
|
264
264
|
// TODO adjust sourceAssetIdNode.value.dependencies ?
|
|
@@ -1503,7 +1503,7 @@ class BundleGraph {
|
|
|
1503
1503
|
let deps = this.getDependencies(asset).reverse();
|
|
1504
1504
|
let potentialResults = [];
|
|
1505
1505
|
for (let dep of deps) {
|
|
1506
|
-
var _depSymbols$get;
|
|
1506
|
+
var _depSymbols$get, _dep$meta2;
|
|
1507
1507
|
let depSymbols = dep.symbols;
|
|
1508
1508
|
if (!depSymbols) {
|
|
1509
1509
|
nonStaticDependency = true;
|
|
@@ -1555,7 +1555,7 @@ class BundleGraph {
|
|
|
1555
1555
|
// If this module exports wildcards, resolve the original module.
|
|
1556
1556
|
// Default exports are excluded from wildcard exports.
|
|
1557
1557
|
// Wildcard reexports are never listed in the reexporting asset's symbols.
|
|
1558
|
-
if (identifier == null && ((_depSymbols$get = depSymbols.get('*')) === null || _depSymbols$get === void 0 ? void 0 : _depSymbols$get.local) === '*' && symbol !== 'default') {
|
|
1558
|
+
if (identifier == null && (((_depSymbols$get = depSymbols.get('*')) === null || _depSymbols$get === void 0 ? void 0 : _depSymbols$get.local) === '*' || (_dep$meta2 = dep.meta) !== null && _dep$meta2 !== void 0 && _dep$meta2.hasExportStar) && symbol !== 'default') {
|
|
1559
1559
|
let resolved = this.getResolvedAsset(dep, boundary);
|
|
1560
1560
|
if (!resolved) {
|
|
1561
1561
|
continue;
|
|
@@ -1681,10 +1681,10 @@ class BundleGraph {
|
|
|
1681
1681
|
}
|
|
1682
1682
|
let deps = this.getDependencies(asset);
|
|
1683
1683
|
for (let dep of deps) {
|
|
1684
|
-
var _depSymbols$get2;
|
|
1684
|
+
var _depSymbols$get2, _dep$meta3;
|
|
1685
1685
|
let depSymbols = dep.symbols;
|
|
1686
1686
|
if (!depSymbols) continue;
|
|
1687
|
-
if (((_depSymbols$get2 = depSymbols.get('*')) === null || _depSymbols$get2 === void 0 ? void 0 : _depSymbols$get2.local) === '*') {
|
|
1687
|
+
if (((_depSymbols$get2 = depSymbols.get('*')) === null || _depSymbols$get2 === void 0 ? void 0 : _depSymbols$get2.local) === '*' || (_dep$meta3 = dep.meta) !== null && _dep$meta3 !== void 0 && _dep$meta3.hasExportStar) {
|
|
1688
1688
|
let resolved = this.getResolvedAsset(dep, boundary);
|
|
1689
1689
|
if (!resolved) continue;
|
|
1690
1690
|
let exported = this.getExportedSymbols(resolved, boundary).filter(s => s.exportSymbol !== 'default').map(s => s.exportSymbol !== '*' ? {
|
package/lib/SymbolPropagation.js
CHANGED
|
@@ -94,8 +94,8 @@ function propagateSymbols({
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
let hasNamespaceOutgoingDeps = outgoingDeps.some(d => {
|
|
97
|
-
var _d$value$symbols;
|
|
98
|
-
return ((_d$value$symbols = d.value.symbols) === null || _d$value$symbols === void 0 || (_d$value$symbols = _d$value$symbols.get('*')) === null || _d$value$symbols === void 0 ? void 0 : _d$value$symbols.local) === '*';
|
|
97
|
+
var _d$value$symbols, _d$value$meta;
|
|
98
|
+
return ((_d$value$symbols = d.value.symbols) === null || _d$value$symbols === void 0 || (_d$value$symbols = _d$value$symbols.get('*')) === null || _d$value$symbols === void 0 ? void 0 : _d$value$symbols.local) === '*' || ((_d$value$meta = d.value.meta) === null || _d$value$meta === void 0 ? void 0 : _d$value$meta.hasExportStar);
|
|
99
99
|
});
|
|
100
100
|
|
|
101
101
|
// 1) Determine what the incomingDeps requests from the asset
|
|
@@ -168,10 +168,10 @@ function propagateSymbols({
|
|
|
168
168
|
// lib/index.js: `export * from "./foo.js"; export * from "./bar.js";`
|
|
169
169
|
// lib/foo.js: `import { data } from "./bar.js"; export const foo = data + " esm2";`
|
|
170
170
|
assetNode.usedSymbols.size > 0 || namespaceReexportedSymbols.size > 0) {
|
|
171
|
-
var _depSymbols$get;
|
|
171
|
+
var _depSymbols$get, _dep$value$meta;
|
|
172
172
|
let depSymbols = dep.value.symbols;
|
|
173
173
|
if (!depSymbols) continue;
|
|
174
|
-
if (((_depSymbols$get = depSymbols.get('*')) === null || _depSymbols$get === void 0 ? void 0 : _depSymbols$get.local) === '*') {
|
|
174
|
+
if (((_depSymbols$get = depSymbols.get('*')) === null || _depSymbols$get === void 0 ? void 0 : _depSymbols$get.local) === '*' || (_dep$value$meta = dep.value.meta) !== null && _dep$value$meta !== void 0 && _dep$value$meta.hasExportStar) {
|
|
175
175
|
if (addAll) {
|
|
176
176
|
depUsedSymbolsDown.add('*');
|
|
177
177
|
} else {
|
|
@@ -258,7 +258,7 @@ function propagateSymbols({
|
|
|
258
258
|
// analyzable exports
|
|
259
259
|
let reexportedSymbolsSource = new Map();
|
|
260
260
|
for (let outgoingDep of outgoingDeps) {
|
|
261
|
-
var _outgoingDepSymbols$g;
|
|
261
|
+
var _outgoingDepSymbols$g, _outgoingDep$value$me;
|
|
262
262
|
let outgoingDepSymbols = outgoingDep.value.symbols;
|
|
263
263
|
if (!outgoingDepSymbols) continue;
|
|
264
264
|
let isExcluded = assetGraph.getNodeIdsConnectedFrom(assetGraph.getNodeIdByContentKey(outgoingDep.id)).length === 0;
|
|
@@ -266,7 +266,7 @@ function propagateSymbols({
|
|
|
266
266
|
if (isExcluded) {
|
|
267
267
|
outgoingDep.usedSymbolsDown.forEach((_, s) => outgoingDep.usedSymbolsUp.set(s, null));
|
|
268
268
|
}
|
|
269
|
-
if (((_outgoingDepSymbols$g = outgoingDepSymbols.get('*')) === null || _outgoingDepSymbols$g === void 0 ? void 0 : _outgoingDepSymbols$g.local) === '*') {
|
|
269
|
+
if (((_outgoingDepSymbols$g = outgoingDepSymbols.get('*')) === null || _outgoingDepSymbols$g === void 0 ? void 0 : _outgoingDepSymbols$g.local) === '*' || (_outgoingDep$value$me = outgoingDep.value.meta) !== null && _outgoingDep$value$me !== void 0 && _outgoingDep$value$me.hasExportStar) {
|
|
270
270
|
outgoingDep.usedSymbolsUp.forEach((sResolved, s) => {
|
|
271
271
|
if (s === 'default') {
|
|
272
272
|
return;
|
|
@@ -334,12 +334,12 @@ function propagateSymbols({
|
|
|
334
334
|
current.set(s, value);
|
|
335
335
|
}
|
|
336
336
|
for (let incomingDep of incomingDeps) {
|
|
337
|
-
var _incomingDepSymbols$g;
|
|
337
|
+
var _incomingDepSymbols$g, _incomingDep$value$me;
|
|
338
338
|
let incomingDepUsedSymbolsUpOld = incomingDep.usedSymbolsUp;
|
|
339
339
|
incomingDep.usedSymbolsUp = new Map();
|
|
340
340
|
let incomingDepSymbols = incomingDep.value.symbols;
|
|
341
341
|
if (!incomingDepSymbols) continue;
|
|
342
|
-
let hasNamespaceReexport = ((_incomingDepSymbols$g = incomingDepSymbols.get('*')) === null || _incomingDepSymbols$g === void 0 ? void 0 : _incomingDepSymbols$g.local) === '*';
|
|
342
|
+
let hasNamespaceReexport = ((_incomingDepSymbols$g = incomingDepSymbols.get('*')) === null || _incomingDepSymbols$g === void 0 ? void 0 : _incomingDepSymbols$g.local) === '*' || ((_incomingDep$value$me = incomingDep.value.meta) === null || _incomingDep$value$me === void 0 ? void 0 : _incomingDep$value$me.hasExportStar);
|
|
343
343
|
for (let s of incomingDep.usedSymbolsDown) {
|
|
344
344
|
if (assetSymbols == null ||
|
|
345
345
|
// Assume everything could be provided if symbols are cleared
|