@atlaspack/core 2.16.2-canary.431 → 2.16.2-canary.433
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/requests/BundleGraphRequest.js +9 -6
- package/dist/requests/BundleGraphRequestRust.js +1 -0
- package/dist/requests/BundleGraphRequestUtils.js +133 -2
- package/lib/requests/BundleGraphRequest.js +10 -7
- package/lib/requests/BundleGraphRequestRust.js +1 -0
- package/lib/requests/BundleGraphRequestUtils.js +132 -2
- package/lib/types/requests/BundleGraphRequestUtils.d.ts +7 -0
- package/package.json +18 -18
- package/src/requests/BundleGraphRequest.ts +11 -6
- package/src/requests/BundleGraphRequestRust.ts +3 -0
- package/src/requests/BundleGraphRequestUtils.ts +157 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -263,14 +263,17 @@ class BundlerRunner {
|
|
|
263
263
|
measurement = tracer.createMeasurement(plugin.name, 'bundling:bundle', measurementFilename);
|
|
264
264
|
}
|
|
265
265
|
// this the normal bundle workflow (bundle, optimizing, run-times, naming)
|
|
266
|
-
await
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
266
|
+
await (0, logger_1.instrumentAsync)('bundle (V2)', async () => {
|
|
267
|
+
await bundler.bundle({
|
|
268
|
+
bundleGraph: mutableBundleGraph,
|
|
269
|
+
config: this.configs.get(plugin.name)?.result,
|
|
270
|
+
options: this.pluginOptions,
|
|
271
|
+
logger,
|
|
272
|
+
tracer,
|
|
273
|
+
});
|
|
272
274
|
});
|
|
273
275
|
measurement && measurement.end();
|
|
276
|
+
(0, BundleGraphRequestUtils_1.dumpBundleGraphSnapshot)(internalBundleGraph, 'js');
|
|
274
277
|
if (this.pluginOptions.mode === 'production') {
|
|
275
278
|
let optimizeMeasurement;
|
|
276
279
|
try {
|
|
@@ -71,6 +71,7 @@ function createBundleGraphRequestRust(input) {
|
|
|
71
71
|
}
|
|
72
72
|
// Don’t reuse previous JS result yet; we just rebuild from scratch.
|
|
73
73
|
let { bundleGraph, changedAssets } = (0, logger_1.instrument)('atlaspack_v3_getBundleGraph', () => getBundleGraph(serializedBundleGraph));
|
|
74
|
+
(0, BundleGraphRequestUtils_1.dumpBundleGraphSnapshot)(bundleGraph, 'rust');
|
|
74
75
|
const runner = new NativeBundlerRunner({ api, options }, input.optionsRef);
|
|
75
76
|
await runner.loadConfigs();
|
|
76
77
|
// Name all bundles
|
|
@@ -37,15 +37,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.validateBundles = validateBundles;
|
|
40
|
+
exports.dumpBundleGraphSnapshot = dumpBundleGraphSnapshot;
|
|
40
41
|
exports.nameBundle = nameBundle;
|
|
41
42
|
exports.loadPluginConfigWithDevDeps = loadPluginConfigWithDevDeps;
|
|
42
43
|
exports.runDevDepRequest = runDevDepRequest;
|
|
43
44
|
const assert_1 = __importDefault(require("assert"));
|
|
45
|
+
const fs_1 = __importDefault(require("fs"));
|
|
44
46
|
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
47
|
+
const path_1 = __importDefault(require("path"));
|
|
45
48
|
const logger_1 = require("@atlaspack/logger");
|
|
46
49
|
const diagnostic_1 = __importStar(require("@atlaspack/diagnostic"));
|
|
47
50
|
const utils_1 = require("@atlaspack/utils");
|
|
48
|
-
const BundleGraph_1 =
|
|
51
|
+
const BundleGraph_1 = require("../BundleGraph");
|
|
52
|
+
const BundleGraph_2 = __importDefault(require("../public/BundleGraph"));
|
|
49
53
|
const Bundle_1 = require("../public/Bundle");
|
|
50
54
|
const InternalConfig_1 = require("../InternalConfig");
|
|
51
55
|
const DevDepRequest_1 = require("./DevDepRequest");
|
|
@@ -64,12 +68,139 @@ function validateBundles(bundleGraph) {
|
|
|
64
68
|
...(0, utils_1.setSymmetricDifference)(new Set(bundleNames), new Set((0, utils_1.unique)(bundleNames))),
|
|
65
69
|
].join());
|
|
66
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Dump a canonical JSON snapshot of the bundle graph for parity comparison.
|
|
73
|
+
* Gated by ATLASPACK_DUMP_BUNDLE_GRAPH environment variable which specifies the output directory.
|
|
74
|
+
* The snapshot captures bundle identity, type, contained assets, and bundle group structure
|
|
75
|
+
* in a deterministic, sorted format suitable for diffing.
|
|
76
|
+
*/
|
|
77
|
+
function dumpBundleGraphSnapshot(bundleGraph, variant) {
|
|
78
|
+
let outDir = process.env.ATLASPACK_DUMP_BUNDLE_GRAPH;
|
|
79
|
+
if (!outDir)
|
|
80
|
+
return;
|
|
81
|
+
let filename = variant === 'js' ? 'bundle-graph-js.json' : 'bundle-graph-rust.json';
|
|
82
|
+
let outPath = path_1.default.join(outDir, filename);
|
|
83
|
+
fs_1.default.mkdirSync(outDir, { recursive: true });
|
|
84
|
+
let bundles = bundleGraph.getBundles();
|
|
85
|
+
let bundlesSnapshot = bundles
|
|
86
|
+
.map((bundle) => {
|
|
87
|
+
let bundleNodeId = bundleGraph._graph.getNodeIdByContentKey(bundle.id);
|
|
88
|
+
let containedAssetNodeIds = bundleGraph._graph.getNodeIdsConnectedFrom(bundleNodeId, BundleGraph_1.bundleGraphEdgeTypes.contains);
|
|
89
|
+
let containedAssets = containedAssetNodeIds
|
|
90
|
+
.map((nodeId) => bundleGraph._graph.getNode(nodeId))
|
|
91
|
+
.flatMap((node) => {
|
|
92
|
+
if (node?.type !== 'asset')
|
|
93
|
+
return [];
|
|
94
|
+
return [
|
|
95
|
+
{
|
|
96
|
+
id: node.value.id,
|
|
97
|
+
filePath: (0, projectPath_1.fromProjectPathRelative)(node.value.filePath),
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
})
|
|
101
|
+
.sort((a, b) => a.filePath.localeCompare(b.filePath));
|
|
102
|
+
// Resolve mainEntry and entry asset file paths
|
|
103
|
+
let mainEntryPath = null;
|
|
104
|
+
let entryAssetPaths = [];
|
|
105
|
+
if (bundle.mainEntryId) {
|
|
106
|
+
let mainEntryNodeId = bundleGraph._graph.getNodeIdByContentKey(bundle.mainEntryId);
|
|
107
|
+
let mainEntryNode = bundleGraph._graph.getNode(mainEntryNodeId);
|
|
108
|
+
if (mainEntryNode?.type === 'asset') {
|
|
109
|
+
mainEntryPath = (0, projectPath_1.fromProjectPathRelative)(mainEntryNode.value.filePath);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (let entryId of bundle.entryAssetIds) {
|
|
113
|
+
let entryNodeId = bundleGraph._graph.getNodeIdByContentKey(entryId);
|
|
114
|
+
let entryNode = bundleGraph._graph.getNode(entryNodeId);
|
|
115
|
+
if (entryNode?.type === 'asset') {
|
|
116
|
+
entryAssetPaths.push((0, projectPath_1.fromProjectPathRelative)(entryNode.value.filePath));
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
entryAssetPaths.sort();
|
|
120
|
+
return {
|
|
121
|
+
id: bundle.id,
|
|
122
|
+
type: bundle.type,
|
|
123
|
+
bundleBehavior: bundle.bundleBehavior ?? null,
|
|
124
|
+
needsStableName: bundle.needsStableName,
|
|
125
|
+
isSplittable: bundle.isSplittable,
|
|
126
|
+
isPlaceholder: bundle.isPlaceholder,
|
|
127
|
+
mainEntryPath,
|
|
128
|
+
entryAssetPaths,
|
|
129
|
+
assets: containedAssets.map((a) => a.filePath),
|
|
130
|
+
};
|
|
131
|
+
})
|
|
132
|
+
.sort((a, b) => {
|
|
133
|
+
// Sort by mainEntryPath first, then by sorted assets as tiebreaker
|
|
134
|
+
let aKey = a.mainEntryPath || a.assets.join(',');
|
|
135
|
+
let bKey = b.mainEntryPath || b.assets.join(',');
|
|
136
|
+
return aKey.localeCompare(bKey);
|
|
137
|
+
});
|
|
138
|
+
let bundleGroupsSnapshot = bundleGraph._graph.nodes
|
|
139
|
+
.flatMap((node) => {
|
|
140
|
+
if (node?.type !== 'bundle_group')
|
|
141
|
+
return [];
|
|
142
|
+
let bundleGroup = node.value;
|
|
143
|
+
// Resolve entry asset file path
|
|
144
|
+
let entryAssetPath = null;
|
|
145
|
+
try {
|
|
146
|
+
let entryNodeId = bundleGraph._graph.getNodeIdByContentKey(bundleGroup.entryAssetId);
|
|
147
|
+
let entryNode = bundleGraph._graph.getNode(entryNodeId);
|
|
148
|
+
if (entryNode?.type === 'asset') {
|
|
149
|
+
entryAssetPath = (0, projectPath_1.fromProjectPathRelative)(entryNode.value.filePath);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
// Content key not found
|
|
154
|
+
}
|
|
155
|
+
let bundlesInGroup = bundleGraph.getBundlesInBundleGroup(bundleGroup);
|
|
156
|
+
let bundlePaths = bundlesInGroup
|
|
157
|
+
.map((b) => {
|
|
158
|
+
// Use mainEntry file path if available, otherwise bundle id as fallback
|
|
159
|
+
if (b.mainEntryId) {
|
|
160
|
+
try {
|
|
161
|
+
let nodeId = bundleGraph._graph.getNodeIdByContentKey(b.mainEntryId);
|
|
162
|
+
let node = bundleGraph._graph.getNode(nodeId);
|
|
163
|
+
if (node?.type === 'asset') {
|
|
164
|
+
return (0, projectPath_1.fromProjectPathRelative)(node.value.filePath);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
// fallback
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return `[bundle:${b.id}]`;
|
|
172
|
+
})
|
|
173
|
+
.sort();
|
|
174
|
+
return [
|
|
175
|
+
{
|
|
176
|
+
entryAssetPath: entryAssetPath ?? `[unknown:${bundleGroup.entryAssetId}]`,
|
|
177
|
+
bundlePaths,
|
|
178
|
+
},
|
|
179
|
+
];
|
|
180
|
+
})
|
|
181
|
+
.sort((a, b) => a.entryAssetPath.localeCompare(b.entryAssetPath));
|
|
182
|
+
let totalAssets = bundleGraph._graph.nodes.filter((node) => node?.type === 'asset').length;
|
|
183
|
+
let snapshot = {
|
|
184
|
+
version: 1,
|
|
185
|
+
variant,
|
|
186
|
+
stats: {
|
|
187
|
+
totalBundles: bundlesSnapshot.length,
|
|
188
|
+
totalBundleGroups: bundleGroupsSnapshot.length,
|
|
189
|
+
totalAssets,
|
|
190
|
+
},
|
|
191
|
+
bundles: bundlesSnapshot,
|
|
192
|
+
bundleGroups: bundleGroupsSnapshot,
|
|
193
|
+
};
|
|
194
|
+
fs_1.default.writeFileSync(outPath, JSON.stringify(snapshot, null, 2), 'utf8');
|
|
195
|
+
// eslint-disable-next-line no-console
|
|
196
|
+
console.log(`[BundleGraphSnapshot] Wrote ${variant} snapshot to ${outPath}`);
|
|
197
|
+
}
|
|
67
198
|
/**
|
|
68
199
|
* Names a bundle by running through the configured namers until one returns a name.
|
|
69
200
|
*/
|
|
70
201
|
async function nameBundle(namers, internalBundle, internalBundleGraph, options, pluginOptions, configs) {
|
|
71
202
|
const bundle = Bundle_1.Bundle.get(internalBundle, internalBundleGraph, options);
|
|
72
|
-
const bundleGraph = new
|
|
203
|
+
const bundleGraph = new BundleGraph_2.default(internalBundleGraph, Bundle_1.NamedBundle.get.bind(Bundle_1.NamedBundle), options);
|
|
73
204
|
for (const namer of namers) {
|
|
74
205
|
let measurement;
|
|
75
206
|
try {
|
|
@@ -293,7 +293,6 @@ class BundlerRunner {
|
|
|
293
293
|
}
|
|
294
294
|
didIncrementallyBundle = true;
|
|
295
295
|
} else {
|
|
296
|
-
var _this$configs$get;
|
|
297
296
|
internalBundleGraph = _BundleGraph.default.fromAssetGraph(graph, this.options.mode === 'production');
|
|
298
297
|
(0, _assert().default)(internalBundleGraph != null); // ensures the graph was created
|
|
299
298
|
|
|
@@ -309,14 +308,18 @@ class BundlerRunner {
|
|
|
309
308
|
}
|
|
310
309
|
|
|
311
310
|
// this the normal bundle workflow (bundle, optimizing, run-times, naming)
|
|
312
|
-
await
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
311
|
+
await (0, _logger().instrumentAsync)('bundle (V2)', async () => {
|
|
312
|
+
var _this$configs$get;
|
|
313
|
+
await bundler.bundle({
|
|
314
|
+
bundleGraph: mutableBundleGraph,
|
|
315
|
+
config: (_this$configs$get = this.configs.get(plugin.name)) === null || _this$configs$get === void 0 ? void 0 : _this$configs$get.result,
|
|
316
|
+
options: this.pluginOptions,
|
|
317
|
+
logger,
|
|
318
|
+
tracer
|
|
319
|
+
});
|
|
318
320
|
});
|
|
319
321
|
measurement && measurement.end();
|
|
322
|
+
(0, _BundleGraphRequestUtils.dumpBundleGraphSnapshot)(internalBundleGraph, 'js');
|
|
320
323
|
if (this.pluginOptions.mode === 'production') {
|
|
321
324
|
let optimizeMeasurement;
|
|
322
325
|
try {
|
|
@@ -96,6 +96,7 @@ function createBundleGraphRequestRust(input) {
|
|
|
96
96
|
bundleGraph,
|
|
97
97
|
changedAssets
|
|
98
98
|
} = (0, _logger().instrument)('atlaspack_v3_getBundleGraph', () => getBundleGraph(serializedBundleGraph));
|
|
99
|
+
(0, _BundleGraphRequestUtils.dumpBundleGraphSnapshot)(bundleGraph, 'rust');
|
|
99
100
|
const runner = new NativeBundlerRunner({
|
|
100
101
|
api,
|
|
101
102
|
options
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.dumpBundleGraphSnapshot = dumpBundleGraphSnapshot;
|
|
6
7
|
exports.loadPluginConfigWithDevDeps = loadPluginConfigWithDevDeps;
|
|
7
8
|
exports.nameBundle = nameBundle;
|
|
8
9
|
exports.runDevDepRequest = runDevDepRequest;
|
|
@@ -14,6 +15,13 @@ function _assert() {
|
|
|
14
15
|
};
|
|
15
16
|
return data;
|
|
16
17
|
}
|
|
18
|
+
function _fs() {
|
|
19
|
+
const data = _interopRequireDefault(require("fs"));
|
|
20
|
+
_fs = function () {
|
|
21
|
+
return data;
|
|
22
|
+
};
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
17
25
|
function _nullthrows() {
|
|
18
26
|
const data = _interopRequireDefault(require("nullthrows"));
|
|
19
27
|
_nullthrows = function () {
|
|
@@ -21,6 +29,13 @@ function _nullthrows() {
|
|
|
21
29
|
};
|
|
22
30
|
return data;
|
|
23
31
|
}
|
|
32
|
+
function _path() {
|
|
33
|
+
const data = _interopRequireDefault(require("path"));
|
|
34
|
+
_path = function () {
|
|
35
|
+
return data;
|
|
36
|
+
};
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
24
39
|
function _logger() {
|
|
25
40
|
const data = require("@atlaspack/logger");
|
|
26
41
|
_logger = function () {
|
|
@@ -42,7 +57,8 @@ function _utils() {
|
|
|
42
57
|
};
|
|
43
58
|
return data;
|
|
44
59
|
}
|
|
45
|
-
var _BundleGraph =
|
|
60
|
+
var _BundleGraph = require("../BundleGraph");
|
|
61
|
+
var _BundleGraph2 = _interopRequireDefault(require("../public/BundleGraph"));
|
|
46
62
|
var _Bundle = require("../public/Bundle");
|
|
47
63
|
var _InternalConfig = require("../InternalConfig");
|
|
48
64
|
var _DevDepRequest = require("./DevDepRequest");
|
|
@@ -75,12 +91,126 @@ function validateBundles(bundleGraph) {
|
|
|
75
91
|
_assert().default.deepEqual(bundleNames, (0, _utils().unique)(bundleNames), 'Bundles must have unique name. Conflicting names: ' + [...(0, _utils().setSymmetricDifference)(new Set(bundleNames), new Set((0, _utils().unique)(bundleNames)))].join());
|
|
76
92
|
}
|
|
77
93
|
|
|
94
|
+
/**
|
|
95
|
+
* Dump a canonical JSON snapshot of the bundle graph for parity comparison.
|
|
96
|
+
* Gated by ATLASPACK_DUMP_BUNDLE_GRAPH environment variable which specifies the output directory.
|
|
97
|
+
* The snapshot captures bundle identity, type, contained assets, and bundle group structure
|
|
98
|
+
* in a deterministic, sorted format suitable for diffing.
|
|
99
|
+
*/
|
|
100
|
+
function dumpBundleGraphSnapshot(bundleGraph, variant) {
|
|
101
|
+
let outDir = process.env.ATLASPACK_DUMP_BUNDLE_GRAPH;
|
|
102
|
+
if (!outDir) return;
|
|
103
|
+
let filename = variant === 'js' ? 'bundle-graph-js.json' : 'bundle-graph-rust.json';
|
|
104
|
+
let outPath = _path().default.join(outDir, filename);
|
|
105
|
+
_fs().default.mkdirSync(outDir, {
|
|
106
|
+
recursive: true
|
|
107
|
+
});
|
|
108
|
+
let bundles = bundleGraph.getBundles();
|
|
109
|
+
let bundlesSnapshot = bundles.map(bundle => {
|
|
110
|
+
let bundleNodeId = bundleGraph._graph.getNodeIdByContentKey(bundle.id);
|
|
111
|
+
let containedAssetNodeIds = bundleGraph._graph.getNodeIdsConnectedFrom(bundleNodeId, _BundleGraph.bundleGraphEdgeTypes.contains);
|
|
112
|
+
let containedAssets = containedAssetNodeIds.map(nodeId => bundleGraph._graph.getNode(nodeId)).flatMap(node => {
|
|
113
|
+
if ((node === null || node === void 0 ? void 0 : node.type) !== 'asset') return [];
|
|
114
|
+
return [{
|
|
115
|
+
id: node.value.id,
|
|
116
|
+
filePath: (0, _projectPath.fromProjectPathRelative)(node.value.filePath)
|
|
117
|
+
}];
|
|
118
|
+
}).sort((a, b) => a.filePath.localeCompare(b.filePath));
|
|
119
|
+
|
|
120
|
+
// Resolve mainEntry and entry asset file paths
|
|
121
|
+
let mainEntryPath = null;
|
|
122
|
+
let entryAssetPaths = [];
|
|
123
|
+
if (bundle.mainEntryId) {
|
|
124
|
+
let mainEntryNodeId = bundleGraph._graph.getNodeIdByContentKey(bundle.mainEntryId);
|
|
125
|
+
let mainEntryNode = bundleGraph._graph.getNode(mainEntryNodeId);
|
|
126
|
+
if ((mainEntryNode === null || mainEntryNode === void 0 ? void 0 : mainEntryNode.type) === 'asset') {
|
|
127
|
+
mainEntryPath = (0, _projectPath.fromProjectPathRelative)(mainEntryNode.value.filePath);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
for (let entryId of bundle.entryAssetIds) {
|
|
131
|
+
let entryNodeId = bundleGraph._graph.getNodeIdByContentKey(entryId);
|
|
132
|
+
let entryNode = bundleGraph._graph.getNode(entryNodeId);
|
|
133
|
+
if ((entryNode === null || entryNode === void 0 ? void 0 : entryNode.type) === 'asset') {
|
|
134
|
+
entryAssetPaths.push((0, _projectPath.fromProjectPathRelative)(entryNode.value.filePath));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
entryAssetPaths.sort();
|
|
138
|
+
return {
|
|
139
|
+
id: bundle.id,
|
|
140
|
+
type: bundle.type,
|
|
141
|
+
bundleBehavior: bundle.bundleBehavior ?? null,
|
|
142
|
+
needsStableName: bundle.needsStableName,
|
|
143
|
+
isSplittable: bundle.isSplittable,
|
|
144
|
+
isPlaceholder: bundle.isPlaceholder,
|
|
145
|
+
mainEntryPath,
|
|
146
|
+
entryAssetPaths,
|
|
147
|
+
assets: containedAssets.map(a => a.filePath)
|
|
148
|
+
};
|
|
149
|
+
}).sort((a, b) => {
|
|
150
|
+
// Sort by mainEntryPath first, then by sorted assets as tiebreaker
|
|
151
|
+
let aKey = a.mainEntryPath || a.assets.join(',');
|
|
152
|
+
let bKey = b.mainEntryPath || b.assets.join(',');
|
|
153
|
+
return aKey.localeCompare(bKey);
|
|
154
|
+
});
|
|
155
|
+
let bundleGroupsSnapshot = bundleGraph._graph.nodes.flatMap(node => {
|
|
156
|
+
if ((node === null || node === void 0 ? void 0 : node.type) !== 'bundle_group') return [];
|
|
157
|
+
let bundleGroup = node.value;
|
|
158
|
+
|
|
159
|
+
// Resolve entry asset file path
|
|
160
|
+
let entryAssetPath = null;
|
|
161
|
+
try {
|
|
162
|
+
let entryNodeId = bundleGraph._graph.getNodeIdByContentKey(bundleGroup.entryAssetId);
|
|
163
|
+
let entryNode = bundleGraph._graph.getNode(entryNodeId);
|
|
164
|
+
if ((entryNode === null || entryNode === void 0 ? void 0 : entryNode.type) === 'asset') {
|
|
165
|
+
entryAssetPath = (0, _projectPath.fromProjectPathRelative)(entryNode.value.filePath);
|
|
166
|
+
}
|
|
167
|
+
} catch {
|
|
168
|
+
// Content key not found
|
|
169
|
+
}
|
|
170
|
+
let bundlesInGroup = bundleGraph.getBundlesInBundleGroup(bundleGroup);
|
|
171
|
+
let bundlePaths = bundlesInGroup.map(b => {
|
|
172
|
+
// Use mainEntry file path if available, otherwise bundle id as fallback
|
|
173
|
+
if (b.mainEntryId) {
|
|
174
|
+
try {
|
|
175
|
+
let nodeId = bundleGraph._graph.getNodeIdByContentKey(b.mainEntryId);
|
|
176
|
+
let node = bundleGraph._graph.getNode(nodeId);
|
|
177
|
+
if ((node === null || node === void 0 ? void 0 : node.type) === 'asset') {
|
|
178
|
+
return (0, _projectPath.fromProjectPathRelative)(node.value.filePath);
|
|
179
|
+
}
|
|
180
|
+
} catch {
|
|
181
|
+
// fallback
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return `[bundle:${b.id}]`;
|
|
185
|
+
}).sort();
|
|
186
|
+
return [{
|
|
187
|
+
entryAssetPath: entryAssetPath ?? `[unknown:${bundleGroup.entryAssetId}]`,
|
|
188
|
+
bundlePaths
|
|
189
|
+
}];
|
|
190
|
+
}).sort((a, b) => a.entryAssetPath.localeCompare(b.entryAssetPath));
|
|
191
|
+
let totalAssets = bundleGraph._graph.nodes.filter(node => (node === null || node === void 0 ? void 0 : node.type) === 'asset').length;
|
|
192
|
+
let snapshot = {
|
|
193
|
+
version: 1,
|
|
194
|
+
variant,
|
|
195
|
+
stats: {
|
|
196
|
+
totalBundles: bundlesSnapshot.length,
|
|
197
|
+
totalBundleGroups: bundleGroupsSnapshot.length,
|
|
198
|
+
totalAssets
|
|
199
|
+
},
|
|
200
|
+
bundles: bundlesSnapshot,
|
|
201
|
+
bundleGroups: bundleGroupsSnapshot
|
|
202
|
+
};
|
|
203
|
+
_fs().default.writeFileSync(outPath, JSON.stringify(snapshot, null, 2), 'utf8');
|
|
204
|
+
// eslint-disable-next-line no-console
|
|
205
|
+
console.log(`[BundleGraphSnapshot] Wrote ${variant} snapshot to ${outPath}`);
|
|
206
|
+
}
|
|
207
|
+
|
|
78
208
|
/**
|
|
79
209
|
* Names a bundle by running through the configured namers until one returns a name.
|
|
80
210
|
*/
|
|
81
211
|
async function nameBundle(namers, internalBundle, internalBundleGraph, options, pluginOptions, configs) {
|
|
82
212
|
const bundle = _Bundle.Bundle.get(internalBundle, internalBundleGraph, options);
|
|
83
|
-
const bundleGraph = new
|
|
213
|
+
const bundleGraph = new _BundleGraph2.default(internalBundleGraph, _Bundle.NamedBundle.get.bind(_Bundle.NamedBundle), options);
|
|
84
214
|
for (const namer of namers) {
|
|
85
215
|
let measurement;
|
|
86
216
|
try {
|
|
@@ -17,6 +17,13 @@ import type { BundleGraphResult } from './BundleGraphRequest';
|
|
|
17
17
|
* Throws an assertion error if duplicate bundle names are found.
|
|
18
18
|
*/
|
|
19
19
|
export declare function validateBundles(bundleGraph: InternalBundleGraph): void;
|
|
20
|
+
/**
|
|
21
|
+
* Dump a canonical JSON snapshot of the bundle graph for parity comparison.
|
|
22
|
+
* Gated by ATLASPACK_DUMP_BUNDLE_GRAPH environment variable which specifies the output directory.
|
|
23
|
+
* The snapshot captures bundle identity, type, contained assets, and bundle group structure
|
|
24
|
+
* in a deterministic, sorted format suitable for diffing.
|
|
25
|
+
*/
|
|
26
|
+
export declare function dumpBundleGraphSnapshot(bundleGraph: InternalBundleGraph, variant: 'js' | 'rust'): void;
|
|
20
27
|
/**
|
|
21
28
|
* Names a bundle by running through the configured namers until one returns a name.
|
|
22
29
|
*/
|
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.433+f7878b2f1",
|
|
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.11-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.501+f7878b2f1",
|
|
26
|
+
"@atlaspack/cache": "3.1.1-canary.433+f7878b2f1",
|
|
27
|
+
"@atlaspack/diagnostic": "2.14.1-canary.501+f7878b2f1",
|
|
28
|
+
"@atlaspack/events": "2.14.1-canary.501+f7878b2f1",
|
|
29
|
+
"@atlaspack/feature-flags": "2.14.1-canary.501+f7878b2f1",
|
|
30
|
+
"@atlaspack/fs": "2.14.5-canary.433+f7878b2f1",
|
|
31
|
+
"@atlaspack/graph": "3.4.1-canary.501+f7878b2f1",
|
|
32
|
+
"@atlaspack/logger": "2.14.5-canary.433+f7878b2f1",
|
|
33
|
+
"@atlaspack/package-manager": "2.14.5-canary.433+f7878b2f1",
|
|
34
|
+
"@atlaspack/plugin": "2.14.5-canary.433+f7878b2f1",
|
|
35
|
+
"@atlaspack/profiler": "2.14.1-canary.501+f7878b2f1",
|
|
36
|
+
"@atlaspack/rust": "3.2.1-canary.433+f7878b2f1",
|
|
37
|
+
"@atlaspack/source-map": "3.2.11-canary.4212+f7878b2f1",
|
|
38
|
+
"@atlaspack/types": "2.14.5-canary.433+f7878b2f1",
|
|
39
|
+
"@atlaspack/utils": "2.14.5-canary.433+f7878b2f1",
|
|
40
|
+
"@atlaspack/workers": "2.14.5-canary.433+f7878b2f1",
|
|
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": "f7878b2f19a0a3bbd0e79d0b4a4e1479646043b7"
|
|
65
65
|
}
|
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
nameBundle,
|
|
44
44
|
loadPluginConfigWithDevDeps,
|
|
45
45
|
runDevDepRequest as runDevDepRequestShared,
|
|
46
|
+
dumpBundleGraphSnapshot,
|
|
46
47
|
} from './BundleGraphRequestUtils';
|
|
47
48
|
import createAssetGraphRequestJS from './AssetGraphRequest';
|
|
48
49
|
import {createAssetGraphRequestRust} from './AssetGraphRequestRust';
|
|
@@ -396,16 +397,20 @@ class BundlerRunner {
|
|
|
396
397
|
}
|
|
397
398
|
|
|
398
399
|
// this the normal bundle workflow (bundle, optimizing, run-times, naming)
|
|
399
|
-
await
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
400
|
+
await instrumentAsync('bundle (V2)', async () => {
|
|
401
|
+
await bundler.bundle({
|
|
402
|
+
bundleGraph: mutableBundleGraph,
|
|
403
|
+
config: this.configs.get(plugin.name)?.result,
|
|
404
|
+
options: this.pluginOptions,
|
|
405
|
+
logger,
|
|
406
|
+
tracer,
|
|
407
|
+
});
|
|
405
408
|
});
|
|
406
409
|
|
|
407
410
|
measurement && measurement.end();
|
|
408
411
|
|
|
412
|
+
dumpBundleGraphSnapshot(internalBundleGraph, 'js');
|
|
413
|
+
|
|
409
414
|
if (this.pluginOptions.mode === 'production') {
|
|
410
415
|
let optimizeMeasurement;
|
|
411
416
|
try {
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
nameBundle,
|
|
33
33
|
loadPluginConfigWithDevDeps,
|
|
34
34
|
runDevDepRequest,
|
|
35
|
+
dumpBundleGraphSnapshot,
|
|
35
36
|
} from './BundleGraphRequestUtils';
|
|
36
37
|
import {toEnvironmentRef} from '../EnvironmentManager';
|
|
37
38
|
import {getEnvironmentHash} from '../Environment';
|
|
@@ -109,6 +110,8 @@ export default function createBundleGraphRequestRust(
|
|
|
109
110
|
() => getBundleGraph(serializedBundleGraph),
|
|
110
111
|
);
|
|
111
112
|
|
|
113
|
+
dumpBundleGraphSnapshot(bundleGraph, 'rust');
|
|
114
|
+
|
|
112
115
|
const runner = new NativeBundlerRunner(
|
|
113
116
|
{api, options} as any,
|
|
114
117
|
input.optionsRef,
|