@atlaspack/core 2.29.2-dev-swc44-2ebba71e5.0 → 2.30.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 +39 -0
- package/dist/applyRuntimes.js +79 -1
- package/dist/requests/AssetGraphRequest.js +32 -22
- package/dist/requests/BundleGraphRequest.js +2 -2
- package/lib/applyRuntimes.js +87 -3
- package/lib/requests/AssetGraphRequest.js +32 -22
- package/lib/requests/BundleGraphRequest.js +2 -2
- package/lib/types/requests/AssetGraphRequest.d.ts +2 -0
- package/lib/types/types.d.ts +2 -1
- package/package.json +21 -22
- package/src/applyRuntimes.ts +98 -0
- package/src/requests/AssetGraphRequest.ts +46 -32
- package/src/requests/BundleGraphRequest.ts +13 -11
- package/src/types.ts +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/LICENSE +0 -201
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @atlaspack/core
|
|
2
2
|
|
|
3
|
+
## 2.30.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#925](https://github.com/atlassian-labs/atlaspack/pull/925) [`00fa643`](https://github.com/atlassian-labs/atlaspack/commit/00fa6433202bfd3311479f6314c9ec878a789f2c) Thanks [@benjervis](https://github.com/benjervis)! - Save propagating symbols for runtimes by requiring symbol and dependency data be returned at the time the assets are injected.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies []:
|
|
12
|
+
- @atlaspack/fs@2.15.38
|
|
13
|
+
- @atlaspack/graph@3.6.5
|
|
14
|
+
- @atlaspack/logger@2.14.35
|
|
15
|
+
- @atlaspack/plugin@2.14.43
|
|
16
|
+
- @atlaspack/profiler@2.15.4
|
|
17
|
+
- @atlaspack/types@2.15.33
|
|
18
|
+
- @atlaspack/utils@3.2.4
|
|
19
|
+
- @atlaspack/workers@2.14.43
|
|
20
|
+
- @atlaspack/cache@3.2.38
|
|
21
|
+
- @atlaspack/package-manager@2.14.43
|
|
22
|
+
|
|
23
|
+
## 2.29.2
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Updated dependencies [[`787290a`](https://github.com/atlassian-labs/atlaspack/commit/787290a63b3f781e7af86097201dfdb5a36c8551), [`cbb66a5`](https://github.com/atlassian-labs/atlaspack/commit/cbb66a554f7ad679fd4dfc9e2bf2d5abb859f846), [`7815a93`](https://github.com/atlassian-labs/atlaspack/commit/7815a931b18983c3f34a39990b2f4b8b86855cc6), [`25aa273`](https://github.com/atlassian-labs/atlaspack/commit/25aa2735f4db920960de3d65d3a427775086b7d5), [`9468e16`](https://github.com/atlassian-labs/atlaspack/commit/9468e164e8ca20a5e8f552f5dc203aa3716cb154), [`e55c80c`](https://github.com/atlassian-labs/atlaspack/commit/e55c80cd0ae3cc40356fe063cb7d45fbb9095356)]:
|
|
28
|
+
- @atlaspack/rust@3.14.0
|
|
29
|
+
- @atlaspack/feature-flags@2.27.3
|
|
30
|
+
- @atlaspack/cache@3.2.37
|
|
31
|
+
- @atlaspack/fs@2.15.37
|
|
32
|
+
- @atlaspack/logger@2.14.34
|
|
33
|
+
- @atlaspack/source-map@3.1.3
|
|
34
|
+
- @atlaspack/utils@3.2.3
|
|
35
|
+
- @atlaspack/graph@3.6.4
|
|
36
|
+
- @atlaspack/package-manager@2.14.42
|
|
37
|
+
- @atlaspack/profiler@2.15.3
|
|
38
|
+
- @atlaspack/workers@2.14.42
|
|
39
|
+
- @atlaspack/plugin@2.14.42
|
|
40
|
+
- @atlaspack/types@2.15.32
|
|
41
|
+
|
|
3
42
|
## 2.29.1
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
package/dist/applyRuntimes.js
CHANGED
|
@@ -56,6 +56,7 @@ const projectPath_1 = require("./projectPath");
|
|
|
56
56
|
const profiler_1 = require("@atlaspack/profiler");
|
|
57
57
|
const utils_1 = require("@atlaspack/utils");
|
|
58
58
|
const EnvironmentManager_1 = require("./EnvironmentManager");
|
|
59
|
+
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
59
60
|
function nameRuntimeBundle(bundle, siblingBundle) {
|
|
60
61
|
// We don't run custom namers on runtime bundles as the runtime assumes that they are
|
|
61
62
|
// located at the same nesting level as their owning bundle. Custom naming could
|
|
@@ -121,7 +122,7 @@ async function applyRuntimes({ bundleGraph, config, options, pluginOptions, api,
|
|
|
121
122
|
});
|
|
122
123
|
if (applied) {
|
|
123
124
|
let runtimeAssets = Array.isArray(applied) ? applied : [applied];
|
|
124
|
-
for (let { code, dependency, filePath, isEntry, env, runtimeAssetRequiringExecutionOnLoad, priority, } of runtimeAssets) {
|
|
125
|
+
for (let { code, dependency, filePath, isEntry, env, runtimeAssetRequiringExecutionOnLoad, priority, symbolData, } of runtimeAssets) {
|
|
125
126
|
let sourceName = path_1.default.join(path_1.default.dirname(filePath), `runtime-${(0, rust_1.hashString)(code)}.${bundle.type}`);
|
|
126
127
|
let assetGroup = {
|
|
127
128
|
code,
|
|
@@ -131,6 +132,7 @@ async function applyRuntimes({ bundleGraph, config, options, pluginOptions, api,
|
|
|
131
132
|
// Runtime assets should be considered source, as they should be
|
|
132
133
|
// e.g. compiled to run in the target environment
|
|
133
134
|
isSource: true,
|
|
135
|
+
symbolData,
|
|
134
136
|
};
|
|
135
137
|
let connectionBundle = bundle;
|
|
136
138
|
/**
|
|
@@ -213,6 +215,10 @@ async function applyRuntimes({ bundleGraph, config, options, pluginOptions, api,
|
|
|
213
215
|
// Create a new AssetGraph from the generated runtime assets which also runs
|
|
214
216
|
// transforms and resolves all dependencies.
|
|
215
217
|
let { assetGraph: runtimesAssetGraph, changedAssets } = await reconcileNewRuntimes(api, connections, optionsRef);
|
|
218
|
+
if ((0, feature_flags_1.getFeatureFlag)('skipRuntimeSymbolProp')) {
|
|
219
|
+
// Apply pre-computed symbol data from runtime assets to skip symbol propagation
|
|
220
|
+
applyRuntimeSymbolData(runtimesAssetGraph, connections);
|
|
221
|
+
}
|
|
216
222
|
// Convert the runtime AssetGraph into a BundleGraph, this includes assigning
|
|
217
223
|
// the assets their public ids
|
|
218
224
|
let runtimesBundleGraph = BundleGraph_2.default.fromAssetGraph(runtimesAssetGraph, options.mode === 'production', bundleGraph._publicIdByAssetId, bundleGraph._assetPublicIds);
|
|
@@ -293,12 +299,84 @@ async function applyRuntimes({ bundleGraph, config, options, pluginOptions, api,
|
|
|
293
299
|
}
|
|
294
300
|
return changedAssets;
|
|
295
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Apply pre-computed symbol data from runtime assets to the asset graph
|
|
304
|
+
* to avoid running symbol propagation on runtime code we control.
|
|
305
|
+
*/
|
|
306
|
+
function applyRuntimeSymbolData(assetGraph, connections) {
|
|
307
|
+
for (let { assetGroup } of connections) {
|
|
308
|
+
let assetGroupNode = (0, AssetGraph_1.nodeFromAssetGroup)(assetGroup);
|
|
309
|
+
let assetGroupAssetNodeIds = assetGraph.getNodeIdsConnectedFrom(assetGraph.getNodeIdByContentKey(assetGroupNode.id));
|
|
310
|
+
if (assetGroupAssetNodeIds.length !== 1) {
|
|
311
|
+
continue;
|
|
312
|
+
}
|
|
313
|
+
let runtimeAssetNodeId = assetGroupAssetNodeIds[0];
|
|
314
|
+
let runtimeAssetNode = assetGraph.getNode(runtimeAssetNodeId);
|
|
315
|
+
if (!runtimeAssetNode || runtimeAssetNode.type !== 'asset') {
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
let symbolData = assetGroup.symbolData;
|
|
319
|
+
if (!symbolData) {
|
|
320
|
+
// We completely skip symbol propagation for runtime assets, so symbolData
|
|
321
|
+
// is required
|
|
322
|
+
throw new Error('Runtime asset is missing symbol data');
|
|
323
|
+
}
|
|
324
|
+
if (symbolData.symbols) {
|
|
325
|
+
// Convert from SymbolData format to internal Asset.symbols format
|
|
326
|
+
let internalSymbols = new Map();
|
|
327
|
+
for (let [symbol, data] of symbolData.symbols) {
|
|
328
|
+
internalSymbols.set(symbol, {
|
|
329
|
+
local: data.local,
|
|
330
|
+
loc: data.loc || null,
|
|
331
|
+
meta: data.meta,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
runtimeAssetNode.value.symbols = internalSymbols;
|
|
335
|
+
}
|
|
336
|
+
if (symbolData.dependencies && symbolData.dependencies.length > 0) {
|
|
337
|
+
let outgoingDeps = assetGraph
|
|
338
|
+
.getNodeIdsConnectedFrom(runtimeAssetNodeId)
|
|
339
|
+
.map((id) => assetGraph.getNode(id))
|
|
340
|
+
.filter((node) => node?.type === 'dependency')
|
|
341
|
+
.map((node) => node);
|
|
342
|
+
for (let depSymbolData of symbolData.dependencies) {
|
|
343
|
+
let matchingDep = outgoingDeps.find((depNode) => depNode.value.specifier === depSymbolData.specifier);
|
|
344
|
+
if (matchingDep) {
|
|
345
|
+
if (depSymbolData.symbols) {
|
|
346
|
+
let internalDepSymbols = new Map();
|
|
347
|
+
for (let [symbol, data] of depSymbolData.symbols) {
|
|
348
|
+
internalDepSymbols.set(symbol, {
|
|
349
|
+
local: data.local,
|
|
350
|
+
loc: data.loc || null,
|
|
351
|
+
isWeak: data.isWeak,
|
|
352
|
+
meta: data.meta,
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
matchingDep.value.symbols = internalDepSymbols;
|
|
356
|
+
}
|
|
357
|
+
if (depSymbolData.usedSymbols) {
|
|
358
|
+
matchingDep.usedSymbolsDown = new Set(depSymbolData.usedSymbols);
|
|
359
|
+
// For runtime assets, usedSymbolsUp will be the same as usedSymbolsDown
|
|
360
|
+
// since we know exactly what we're using
|
|
361
|
+
let usedSymbolsUp = new Map();
|
|
362
|
+
for (let symbol of depSymbolData.usedSymbols) {
|
|
363
|
+
// Mark as resolved to external (null) since runtime deps are typically external
|
|
364
|
+
usedSymbolsUp.set(symbol, null);
|
|
365
|
+
}
|
|
366
|
+
matchingDep.usedSymbolsUp = usedSymbolsUp;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
296
373
|
function reconcileNewRuntimes(api, connections, optionsRef) {
|
|
297
374
|
let assetGroups = connections.map((t) => t.assetGroup);
|
|
298
375
|
let request = (0, AssetGraphRequest_1.default)({
|
|
299
376
|
name: 'Runtimes',
|
|
300
377
|
assetGroups,
|
|
301
378
|
optionsRef,
|
|
379
|
+
skipSymbolProp: (0, feature_flags_1.getFeatureFlag)('skipRuntimeSymbolProp'),
|
|
302
380
|
});
|
|
303
381
|
// rebuild the graph
|
|
304
382
|
return api.runRequest(request, { force: true });
|
|
@@ -76,6 +76,7 @@ class AssetGraphBuilder {
|
|
|
76
76
|
this.shouldBuildLazily = shouldBuildLazily ?? false;
|
|
77
77
|
this.lazyIncludes = lazyIncludes ?? [];
|
|
78
78
|
this.lazyExcludes = lazyExcludes ?? [];
|
|
79
|
+
this.skipSymbolProp = input.skipSymbolProp ?? false;
|
|
79
80
|
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
80
81
|
const key = (0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`);
|
|
81
82
|
this.cacheKey = `AssetGraph/${constants_1.ATLASPACK_VERSION}/${options.mode}/${key}`;
|
|
@@ -172,34 +173,43 @@ class AssetGraphBuilder {
|
|
|
172
173
|
}
|
|
173
174
|
if (this.assetGraph.nodes.length > 1) {
|
|
174
175
|
await (0, dumpGraphToGraphViz_1.default)(this.assetGraph, 'AssetGraph_' + this.name + '_before_prop');
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
assetGroupsWithRemovedParents: this.assetGroupsWithRemovedParents,
|
|
181
|
-
previousErrors: this.previousSymbolPropagationErrors,
|
|
176
|
+
// Skip symbol propagation for runtime assets - they have pre-computed symbol data
|
|
177
|
+
if (this.skipSymbolProp) {
|
|
178
|
+
logger_1.default.verbose({
|
|
179
|
+
origin: '@atlaspack/core',
|
|
180
|
+
message: 'Skipping symbol propagation for runtime asset graph',
|
|
182
181
|
});
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
try {
|
|
185
|
+
let errors = (0, SymbolPropagation_1.propagateSymbols)({
|
|
186
|
+
options: this.options,
|
|
186
187
|
assetGraph: this.assetGraph,
|
|
187
|
-
changedAssets: this.changedAssets,
|
|
188
188
|
changedAssetsPropagation: this.changedAssetsPropagation,
|
|
189
189
|
assetGroupsWithRemovedParents: this.assetGroupsWithRemovedParents,
|
|
190
|
-
|
|
191
|
-
assetRequests: [],
|
|
192
|
-
}, this.cacheKey);
|
|
193
|
-
// Just throw the first error. Since errors can bubble (e.g. reexporting a reexported symbol also fails),
|
|
194
|
-
// determining which failing export is the root cause is nontrivial (because of circular dependencies).
|
|
195
|
-
throw new diagnostic_1.default({
|
|
196
|
-
diagnostic: [...errors.values()][0],
|
|
190
|
+
previousErrors: this.previousSymbolPropagationErrors,
|
|
197
191
|
});
|
|
192
|
+
this.changedAssetsPropagation.clear();
|
|
193
|
+
if (errors.size > 0) {
|
|
194
|
+
this.api.storeResult({
|
|
195
|
+
assetGraph: this.assetGraph,
|
|
196
|
+
changedAssets: this.changedAssets,
|
|
197
|
+
changedAssetsPropagation: this.changedAssetsPropagation,
|
|
198
|
+
assetGroupsWithRemovedParents: this.assetGroupsWithRemovedParents,
|
|
199
|
+
previousSymbolPropagationErrors: errors,
|
|
200
|
+
assetRequests: [],
|
|
201
|
+
}, this.cacheKey);
|
|
202
|
+
// Just throw the first error. Since errors can bubble (e.g. reexporting a reexported symbol also fails),
|
|
203
|
+
// determining which failing export is the root cause is nontrivial (because of circular dependencies).
|
|
204
|
+
throw new diagnostic_1.default({
|
|
205
|
+
diagnostic: [...errors.values()][0],
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
catch (e) {
|
|
210
|
+
await (0, dumpGraphToGraphViz_1.default)(this.assetGraph, 'AssetGraph_' + this.name + '_failed');
|
|
211
|
+
throw e;
|
|
198
212
|
}
|
|
199
|
-
}
|
|
200
|
-
catch (e) {
|
|
201
|
-
await (0, dumpGraphToGraphViz_1.default)(this.assetGraph, 'AssetGraph_' + this.name + '_failed');
|
|
202
|
-
throw e;
|
|
203
213
|
}
|
|
204
214
|
}
|
|
205
215
|
await (0, dumpGraphToGraphViz_1.default)(this.assetGraph, 'AssetGraph_' + this.name);
|
|
@@ -360,7 +360,7 @@ class BundlerRunner {
|
|
|
360
360
|
// can match them to the correct packager/optimizer plugins.
|
|
361
361
|
let bundles = internalBundleGraph.getBundles({ includeInline: true });
|
|
362
362
|
await Promise.all(bundles.map((bundle) => this.nameBundle(namers, bundle, internalBundleGraph)));
|
|
363
|
-
changedRuntimes = await (0, applyRuntimes_1.default)({
|
|
363
|
+
changedRuntimes = await (0, logger_1.instrumentAsync)('applyRuntimes', () => (0, applyRuntimes_1.default)({
|
|
364
364
|
bundleGraph: internalBundleGraph,
|
|
365
365
|
api: this.api,
|
|
366
366
|
config: this.config,
|
|
@@ -370,7 +370,7 @@ class BundlerRunner {
|
|
|
370
370
|
previousDevDeps: this.previousDevDeps,
|
|
371
371
|
devDepRequests: this.devDepRequests,
|
|
372
372
|
configs: this.configs,
|
|
373
|
-
});
|
|
373
|
+
}));
|
|
374
374
|
// Add dev deps for namers, AFTER running them to account for lazy require().
|
|
375
375
|
for (let namer of namers) {
|
|
376
376
|
let devDepRequest = await (0, DevDepRequest_1.createDevDependency)({
|
package/lib/applyRuntimes.js
CHANGED
|
@@ -70,6 +70,13 @@ function _utils() {
|
|
|
70
70
|
return data;
|
|
71
71
|
}
|
|
72
72
|
var _EnvironmentManager = require("./EnvironmentManager");
|
|
73
|
+
function _featureFlags() {
|
|
74
|
+
const data = require("@atlaspack/feature-flags");
|
|
75
|
+
_featureFlags = function () {
|
|
76
|
+
return data;
|
|
77
|
+
};
|
|
78
|
+
return data;
|
|
79
|
+
}
|
|
73
80
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
74
81
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
75
82
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -162,7 +169,8 @@ async function applyRuntimes({
|
|
|
162
169
|
isEntry,
|
|
163
170
|
env,
|
|
164
171
|
runtimeAssetRequiringExecutionOnLoad,
|
|
165
|
-
priority
|
|
172
|
+
priority,
|
|
173
|
+
symbolData
|
|
166
174
|
} of runtimeAssets) {
|
|
167
175
|
let sourceName = _path().default.join(_path().default.dirname(filePath), `runtime-${(0, _rust().hashString)(code)}.${bundle.type}`);
|
|
168
176
|
let assetGroup = {
|
|
@@ -172,7 +180,8 @@ async function applyRuntimes({
|
|
|
172
180
|
env: (0, _Environment.mergeEnvironments)(options.projectRoot, (0, _EnvironmentManager.fromEnvironmentId)(bundle.env), env),
|
|
173
181
|
// Runtime assets should be considered source, as they should be
|
|
174
182
|
// e.g. compiled to run in the target environment
|
|
175
|
-
isSource: true
|
|
183
|
+
isSource: true,
|
|
184
|
+
symbolData
|
|
176
185
|
};
|
|
177
186
|
let connectionBundle = bundle;
|
|
178
187
|
|
|
@@ -262,6 +271,10 @@ async function applyRuntimes({
|
|
|
262
271
|
assetGraph: runtimesAssetGraph,
|
|
263
272
|
changedAssets
|
|
264
273
|
} = await reconcileNewRuntimes(api, connections, optionsRef);
|
|
274
|
+
if ((0, _featureFlags().getFeatureFlag)('skipRuntimeSymbolProp')) {
|
|
275
|
+
// Apply pre-computed symbol data from runtime assets to skip symbol propagation
|
|
276
|
+
applyRuntimeSymbolData(runtimesAssetGraph, connections);
|
|
277
|
+
}
|
|
265
278
|
|
|
266
279
|
// Convert the runtime AssetGraph into a BundleGraph, this includes assigning
|
|
267
280
|
// the assets their public ids
|
|
@@ -348,12 +361,83 @@ async function applyRuntimes({
|
|
|
348
361
|
}
|
|
349
362
|
return changedAssets;
|
|
350
363
|
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Apply pre-computed symbol data from runtime assets to the asset graph
|
|
367
|
+
* to avoid running symbol propagation on runtime code we control.
|
|
368
|
+
*/
|
|
369
|
+
function applyRuntimeSymbolData(assetGraph, connections) {
|
|
370
|
+
for (let {
|
|
371
|
+
assetGroup
|
|
372
|
+
} of connections) {
|
|
373
|
+
let assetGroupNode = (0, _AssetGraph.nodeFromAssetGroup)(assetGroup);
|
|
374
|
+
let assetGroupAssetNodeIds = assetGraph.getNodeIdsConnectedFrom(assetGraph.getNodeIdByContentKey(assetGroupNode.id));
|
|
375
|
+
if (assetGroupAssetNodeIds.length !== 1) {
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
let runtimeAssetNodeId = assetGroupAssetNodeIds[0];
|
|
379
|
+
let runtimeAssetNode = assetGraph.getNode(runtimeAssetNodeId);
|
|
380
|
+
if (!runtimeAssetNode || runtimeAssetNode.type !== 'asset') {
|
|
381
|
+
continue;
|
|
382
|
+
}
|
|
383
|
+
let symbolData = assetGroup.symbolData;
|
|
384
|
+
if (!symbolData) {
|
|
385
|
+
// We completely skip symbol propagation for runtime assets, so symbolData
|
|
386
|
+
// is required
|
|
387
|
+
throw new Error('Runtime asset is missing symbol data');
|
|
388
|
+
}
|
|
389
|
+
if (symbolData.symbols) {
|
|
390
|
+
// Convert from SymbolData format to internal Asset.symbols format
|
|
391
|
+
let internalSymbols = new Map();
|
|
392
|
+
for (let [symbol, data] of symbolData.symbols) {
|
|
393
|
+
internalSymbols.set(symbol, {
|
|
394
|
+
local: data.local,
|
|
395
|
+
loc: data.loc || null,
|
|
396
|
+
meta: data.meta
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
runtimeAssetNode.value.symbols = internalSymbols;
|
|
400
|
+
}
|
|
401
|
+
if (symbolData.dependencies && symbolData.dependencies.length > 0) {
|
|
402
|
+
let outgoingDeps = assetGraph.getNodeIdsConnectedFrom(runtimeAssetNodeId).map(id => assetGraph.getNode(id)).filter(node => (node === null || node === void 0 ? void 0 : node.type) === 'dependency').map(node => node);
|
|
403
|
+
for (let depSymbolData of symbolData.dependencies) {
|
|
404
|
+
let matchingDep = outgoingDeps.find(depNode => depNode.value.specifier === depSymbolData.specifier);
|
|
405
|
+
if (matchingDep) {
|
|
406
|
+
if (depSymbolData.symbols) {
|
|
407
|
+
let internalDepSymbols = new Map();
|
|
408
|
+
for (let [symbol, data] of depSymbolData.symbols) {
|
|
409
|
+
internalDepSymbols.set(symbol, {
|
|
410
|
+
local: data.local,
|
|
411
|
+
loc: data.loc || null,
|
|
412
|
+
isWeak: data.isWeak,
|
|
413
|
+
meta: data.meta
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
matchingDep.value.symbols = internalDepSymbols;
|
|
417
|
+
}
|
|
418
|
+
if (depSymbolData.usedSymbols) {
|
|
419
|
+
matchingDep.usedSymbolsDown = new Set(depSymbolData.usedSymbols);
|
|
420
|
+
// For runtime assets, usedSymbolsUp will be the same as usedSymbolsDown
|
|
421
|
+
// since we know exactly what we're using
|
|
422
|
+
let usedSymbolsUp = new Map();
|
|
423
|
+
for (let symbol of depSymbolData.usedSymbols) {
|
|
424
|
+
// Mark as resolved to external (null) since runtime deps are typically external
|
|
425
|
+
usedSymbolsUp.set(symbol, null);
|
|
426
|
+
}
|
|
427
|
+
matchingDep.usedSymbolsUp = usedSymbolsUp;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
351
434
|
function reconcileNewRuntimes(api, connections, optionsRef) {
|
|
352
435
|
let assetGroups = connections.map(t => t.assetGroup);
|
|
353
436
|
let request = (0, _AssetGraphRequest.default)({
|
|
354
437
|
name: 'Runtimes',
|
|
355
438
|
assetGroups,
|
|
356
|
-
optionsRef
|
|
439
|
+
optionsRef,
|
|
440
|
+
skipSymbolProp: (0, _featureFlags().getFeatureFlag)('skipRuntimeSymbolProp')
|
|
357
441
|
});
|
|
358
442
|
|
|
359
443
|
// rebuild the graph
|
|
@@ -124,6 +124,7 @@ class AssetGraphBuilder {
|
|
|
124
124
|
this.shouldBuildLazily = shouldBuildLazily ?? false;
|
|
125
125
|
this.lazyIncludes = lazyIncludes ?? [];
|
|
126
126
|
this.lazyExcludes = lazyExcludes ?? [];
|
|
127
|
+
this.skipSymbolProp = input.skipSymbolProp ?? false;
|
|
127
128
|
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
128
129
|
const key = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`);
|
|
129
130
|
this.cacheKey = `AssetGraph/${_constants.ATLASPACK_VERSION}/${options.mode}/${key}`;
|
|
@@ -216,34 +217,43 @@ class AssetGraphBuilder {
|
|
|
216
217
|
}
|
|
217
218
|
if (this.assetGraph.nodes.length > 1) {
|
|
218
219
|
await (0, _dumpGraphToGraphViz.default)(this.assetGraph, 'AssetGraph_' + this.name + '_before_prop');
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
previousErrors: this.previousSymbolPropagationErrors
|
|
220
|
+
|
|
221
|
+
// Skip symbol propagation for runtime assets - they have pre-computed symbol data
|
|
222
|
+
if (this.skipSymbolProp) {
|
|
223
|
+
_logger().default.verbose({
|
|
224
|
+
origin: '@atlaspack/core',
|
|
225
|
+
message: 'Skipping symbol propagation for runtime asset graph'
|
|
226
226
|
});
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
} else {
|
|
228
|
+
try {
|
|
229
|
+
let errors = (0, _SymbolPropagation.propagateSymbols)({
|
|
230
|
+
options: this.options,
|
|
230
231
|
assetGraph: this.assetGraph,
|
|
231
|
-
changedAssets: this.changedAssets,
|
|
232
232
|
changedAssetsPropagation: this.changedAssetsPropagation,
|
|
233
233
|
assetGroupsWithRemovedParents: this.assetGroupsWithRemovedParents,
|
|
234
|
-
|
|
235
|
-
assetRequests: []
|
|
236
|
-
}, this.cacheKey);
|
|
237
|
-
|
|
238
|
-
// Just throw the first error. Since errors can bubble (e.g. reexporting a reexported symbol also fails),
|
|
239
|
-
// determining which failing export is the root cause is nontrivial (because of circular dependencies).
|
|
240
|
-
throw new (_diagnostic().default)({
|
|
241
|
-
diagnostic: [...errors.values()][0]
|
|
234
|
+
previousErrors: this.previousSymbolPropagationErrors
|
|
242
235
|
});
|
|
236
|
+
this.changedAssetsPropagation.clear();
|
|
237
|
+
if (errors.size > 0) {
|
|
238
|
+
this.api.storeResult({
|
|
239
|
+
assetGraph: this.assetGraph,
|
|
240
|
+
changedAssets: this.changedAssets,
|
|
241
|
+
changedAssetsPropagation: this.changedAssetsPropagation,
|
|
242
|
+
assetGroupsWithRemovedParents: this.assetGroupsWithRemovedParents,
|
|
243
|
+
previousSymbolPropagationErrors: errors,
|
|
244
|
+
assetRequests: []
|
|
245
|
+
}, this.cacheKey);
|
|
246
|
+
|
|
247
|
+
// Just throw the first error. Since errors can bubble (e.g. reexporting a reexported symbol also fails),
|
|
248
|
+
// determining which failing export is the root cause is nontrivial (because of circular dependencies).
|
|
249
|
+
throw new (_diagnostic().default)({
|
|
250
|
+
diagnostic: [...errors.values()][0]
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
} catch (e) {
|
|
254
|
+
await (0, _dumpGraphToGraphViz.default)(this.assetGraph, 'AssetGraph_' + this.name + '_failed');
|
|
255
|
+
throw e;
|
|
243
256
|
}
|
|
244
|
-
} catch (e) {
|
|
245
|
-
await (0, _dumpGraphToGraphViz.default)(this.assetGraph, 'AssetGraph_' + this.name + '_failed');
|
|
246
|
-
throw e;
|
|
247
257
|
}
|
|
248
258
|
}
|
|
249
259
|
await (0, _dumpGraphToGraphViz.default)(this.assetGraph, 'AssetGraph_' + this.name);
|
|
@@ -412,7 +412,7 @@ class BundlerRunner {
|
|
|
412
412
|
includeInline: true
|
|
413
413
|
});
|
|
414
414
|
await Promise.all(bundles.map(bundle => this.nameBundle(namers, bundle, internalBundleGraph)));
|
|
415
|
-
changedRuntimes = await (0, _applyRuntimes.default)({
|
|
415
|
+
changedRuntimes = await (0, _logger().instrumentAsync)('applyRuntimes', () => (0, _applyRuntimes.default)({
|
|
416
416
|
bundleGraph: internalBundleGraph,
|
|
417
417
|
api: this.api,
|
|
418
418
|
config: this.config,
|
|
@@ -422,7 +422,7 @@ class BundlerRunner {
|
|
|
422
422
|
previousDevDeps: this.previousDevDeps,
|
|
423
423
|
devDepRequests: this.devDepRequests,
|
|
424
424
|
configs: this.configs
|
|
425
|
-
});
|
|
425
|
+
}));
|
|
426
426
|
|
|
427
427
|
// Add dev deps for namers, AFTER running them to account for lazy require().
|
|
428
428
|
for (let namer of namers) {
|
|
@@ -17,6 +17,7 @@ export type AssetGraphRequestInput = {
|
|
|
17
17
|
lazyIncludes?: RegExp[];
|
|
18
18
|
lazyExcludes?: RegExp[];
|
|
19
19
|
requestedAssetIds?: Set<string>;
|
|
20
|
+
skipSymbolProp?: boolean;
|
|
20
21
|
};
|
|
21
22
|
export type AssetGraphRequestResult = {
|
|
22
23
|
assetGraph: AssetGraph;
|
|
@@ -57,6 +58,7 @@ export declare class AssetGraphBuilder {
|
|
|
57
58
|
isSingleChangeRebuild: boolean;
|
|
58
59
|
assetGroupsWithRemovedParents: Set<NodeId>;
|
|
59
60
|
previousSymbolPropagationErrors: Map<NodeId, Array<Diagnostic>>;
|
|
61
|
+
skipSymbolProp: boolean;
|
|
60
62
|
constructor({ input, api, options }: RunInput, prevResult?: AssetGraphRequestResult | null);
|
|
61
63
|
build(): Promise<AssetGraphRequestResult>;
|
|
62
64
|
shouldVisitChild(nodeId: NodeId, childNodeId: NodeId): boolean;
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContentKey } from '@atlaspack/graph';
|
|
2
|
-
import type { ASTGenerator, BuildMode, Engines, EnvironmentContext, EnvMap, FilePath, Glob, LogLevel, Meta, DependencySpecifier, PackageName, ReporterEvent, SemverRange, ServerOptions, SourceType, Stats, TargetSourceMapOptions, ConfigResult, OutputFormat, TargetDescriptor, HMROptions, DetailedReportOptions, Symbol } from '@atlaspack/types';
|
|
2
|
+
import type { ASTGenerator, BuildMode, Engines, EnvironmentContext, EnvMap, FilePath, Glob, LogLevel, Meta, DependencySpecifier, PackageName, ReporterEvent, SemverRange, ServerOptions, SourceType, Stats, TargetSourceMapOptions, ConfigResult, OutputFormat, TargetDescriptor, HMROptions, DetailedReportOptions, Symbol, SymbolData } from '@atlaspack/types';
|
|
3
3
|
import type { SharedReference } from '@atlaspack/workers';
|
|
4
4
|
import type { FileSystem } from '@atlaspack/fs';
|
|
5
5
|
import type { Cache } from '@atlaspack/cache';
|
|
@@ -331,6 +331,7 @@ export type AssetRequestInput = {
|
|
|
331
331
|
isURL?: boolean;
|
|
332
332
|
query?: string | null | undefined;
|
|
333
333
|
isSingleChangeRebuild?: boolean;
|
|
334
|
+
symbolData?: SymbolData;
|
|
334
335
|
};
|
|
335
336
|
export type AssetRequestResult = Array<Asset>;
|
|
336
337
|
export type AssetGroup = Partial<Diff<AssetRequestInput, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.30.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -22,23 +22,23 @@
|
|
|
22
22
|
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@atlaspack/build-cache": "2.13.7-dev-swc44-2ebba71e5.0",
|
|
26
|
-
"@atlaspack/cache": "3.2.37-dev-swc44-2ebba71e5.0",
|
|
27
|
-
"@atlaspack/diagnostic": "2.14.5-dev-swc44-2ebba71e5.0",
|
|
28
|
-
"@atlaspack/events": "2.14.5-dev-swc44-2ebba71e5.0",
|
|
29
|
-
"@atlaspack/feature-flags": "2.27.3-dev-swc44-2ebba71e5.0",
|
|
30
|
-
"@atlaspack/fs": "2.15.37-dev-swc44-2ebba71e5.0",
|
|
31
|
-
"@atlaspack/graph": "3.6.4-dev-swc44-2ebba71e5.0",
|
|
32
|
-
"@atlaspack/logger": "2.14.34-dev-swc44-2ebba71e5.0",
|
|
33
|
-
"@atlaspack/package-manager": "2.14.42-dev-swc44-2ebba71e5.0",
|
|
34
|
-
"@atlaspack/plugin": "2.14.42-dev-swc44-2ebba71e5.0",
|
|
35
|
-
"@atlaspack/profiler": "2.15.3-dev-swc44-2ebba71e5.0",
|
|
36
|
-
"@atlaspack/rust": "3.13.1-dev-swc44-2ebba71e5.0",
|
|
37
|
-
"@atlaspack/source-map": "3.1.3-dev-swc44-2ebba71e5.0",
|
|
38
|
-
"@atlaspack/types": "2.15.32-dev-swc44-2ebba71e5.0",
|
|
39
|
-
"@atlaspack/utils": "3.2.3-dev-swc44-2ebba71e5.0",
|
|
40
|
-
"@atlaspack/workers": "2.14.42-dev-swc44-2ebba71e5.0",
|
|
41
25
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
26
|
+
"@atlaspack/build-cache": "2.13.6",
|
|
27
|
+
"@atlaspack/cache": "3.2.38",
|
|
28
|
+
"@atlaspack/diagnostic": "2.14.4",
|
|
29
|
+
"@atlaspack/events": "2.14.4",
|
|
30
|
+
"@atlaspack/feature-flags": "2.27.3",
|
|
31
|
+
"@atlaspack/fs": "2.15.38",
|
|
32
|
+
"@atlaspack/graph": "3.6.5",
|
|
33
|
+
"@atlaspack/logger": "2.14.35",
|
|
34
|
+
"@atlaspack/package-manager": "2.14.43",
|
|
35
|
+
"@atlaspack/plugin": "2.14.43",
|
|
36
|
+
"@atlaspack/profiler": "2.15.4",
|
|
37
|
+
"@atlaspack/rust": "3.14.0",
|
|
38
|
+
"@atlaspack/types": "2.15.33",
|
|
39
|
+
"@atlaspack/utils": "3.2.4",
|
|
40
|
+
"@atlaspack/workers": "2.14.43",
|
|
41
|
+
"@atlaspack/source-map": "3.1.3",
|
|
42
42
|
"base-x": "^3.0.8",
|
|
43
43
|
"browserslist": "^4.6.6",
|
|
44
44
|
"clone": "^2.1.1",
|
|
@@ -50,16 +50,15 @@
|
|
|
50
50
|
"semver": "^7.5.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@atlaspack/babel-register": "2.14.
|
|
53
|
+
"@atlaspack/babel-register": "2.14.4",
|
|
54
54
|
"@types/node": ">= 18",
|
|
55
|
-
"graphviz": "^0.0.9",
|
|
56
|
-
"jest-diff": "*",
|
|
57
55
|
"rfdc": "1",
|
|
56
|
+
"jest-diff": "*",
|
|
57
|
+
"graphviz": "^0.0.9",
|
|
58
58
|
"tempy": "^0.2.1"
|
|
59
59
|
},
|
|
60
60
|
"browser": {
|
|
61
61
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
62
62
|
},
|
|
63
|
-
"type": "commonjs"
|
|
64
|
-
"gitHead": "2ebba71e58427cb535173d50bb44540671b78c63"
|
|
63
|
+
"type": "commonjs"
|
|
65
64
|
}
|