@atlaspack/core 2.32.0 → 2.32.1
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 +24 -0
- package/dist/BundleGraph.js +78 -8
- package/dist/atlaspack-v3/AtlaspackV3.js +4 -4
- package/dist/requests/PackageRequest.js +27 -10
- package/lib/BundleGraph.js +85 -8
- package/lib/atlaspack-v3/AtlaspackV3.js +6 -4
- package/lib/requests/PackageRequest.js +38 -10
- package/lib/types/BundleGraph.d.ts +34 -4
- package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +3 -1
- package/package.json +13 -13
- package/src/BundleGraph.ts +83 -8
- package/src/atlaspack-v3/AtlaspackV3.ts +12 -5
- package/src/requests/PackageRequest.ts +20 -5
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaspack/core
|
|
2
2
|
|
|
3
|
+
## 2.32.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#988](https://github.com/atlassian-labs/atlaspack/pull/988) [`a631dcd`](https://github.com/atlassian-labs/atlaspack/commit/a631dcd961112db072b0f8de0831efd178f355a7) Thanks [@marcins](https://github.com/marcins)! - Implement a basic package() method for the native packager
|
|
8
|
+
|
|
9
|
+
- [#990](https://github.com/atlassian-labs/atlaspack/pull/990) [`5755a11`](https://github.com/atlassian-labs/atlaspack/commit/5755a114903bbf660e2ada3ae2e7ff6ceac7565b) Thanks [@vykimnguyen](https://github.com/vykimnguyen)! - changes conditional bundleGraphEdgeType value
|
|
10
|
+
|
|
11
|
+
- [#987](https://github.com/atlassian-labs/atlaspack/pull/987) [`fcaf517`](https://github.com/atlassian-labs/atlaspack/commit/fcaf517010d15c9300393bcad3f9b465689d9d16) Thanks [@vykimnguyen](https://github.com/vykimnguyen)! - add get_bundle_assets
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`a631dcd`](https://github.com/atlassian-labs/atlaspack/commit/a631dcd961112db072b0f8de0831efd178f355a7), [`e9dce31`](https://github.com/atlassian-labs/atlaspack/commit/e9dce3168a8e6727a994bf2a6ac6041eb29f6027), [`59e1345`](https://github.com/atlassian-labs/atlaspack/commit/59e1345f84f43e0632d434ab42c06bf748241985), [`783118c`](https://github.com/atlassian-labs/atlaspack/commit/783118c772f45a0cf6a3b6b447fb9a0e225b25a6), [`fcaf517`](https://github.com/atlassian-labs/atlaspack/commit/fcaf517010d15c9300393bcad3f9b465689d9d16)]:
|
|
14
|
+
- @atlaspack/rust@3.21.0
|
|
15
|
+
- @atlaspack/cache@3.2.46
|
|
16
|
+
- @atlaspack/fs@2.15.46
|
|
17
|
+
- @atlaspack/logger@2.14.43
|
|
18
|
+
- @atlaspack/source-map@3.2.6
|
|
19
|
+
- @atlaspack/utils@3.3.3
|
|
20
|
+
- @atlaspack/package-manager@2.14.51
|
|
21
|
+
- @atlaspack/profiler@2.15.12
|
|
22
|
+
- @atlaspack/workers@2.14.51
|
|
23
|
+
- @atlaspack/types@2.15.41
|
|
24
|
+
- @atlaspack/graph@3.6.13
|
|
25
|
+
- @atlaspack/plugin@2.14.51
|
|
26
|
+
|
|
3
27
|
## 2.32.0
|
|
4
28
|
|
|
5
29
|
### Minor Changes
|
package/dist/BundleGraph.js
CHANGED
|
@@ -43,7 +43,7 @@ exports.bundleGraphEdgeTypes = {
|
|
|
43
43
|
internal_async: 5,
|
|
44
44
|
// This type is used to mark an edge between a bundle and a conditional bundle.
|
|
45
45
|
// This allows efficient discovery of conditional bundles in packaging
|
|
46
|
-
conditional:
|
|
46
|
+
conditional: 6,
|
|
47
47
|
};
|
|
48
48
|
function makeReadOnlySet(set) {
|
|
49
49
|
return new Proxy(set, {
|
|
@@ -383,7 +383,7 @@ class BundleGraph {
|
|
|
383
383
|
}
|
|
384
384
|
/**
|
|
385
385
|
* Serialize the bundle graph for efficient transfer to native Rust code.
|
|
386
|
-
* Returns a JSON string of nodes
|
|
386
|
+
* Returns a JSON string of nodes, an array of edges, and a map of asset IDs to public IDs.
|
|
387
387
|
*/
|
|
388
388
|
serializeForNative() {
|
|
389
389
|
const start = performance.now();
|
|
@@ -396,16 +396,58 @@ class BundleGraph {
|
|
|
396
396
|
edges.push([edge.from, edge.to, edge.type]);
|
|
397
397
|
next = edgeIterator.next();
|
|
398
398
|
}
|
|
399
|
+
// Extract and deduplicate environments
|
|
400
|
+
const environmentMap = new Map();
|
|
401
|
+
const extractEnvironment = (envRef) => {
|
|
402
|
+
const env = (0, EnvironmentManager_1.fromEnvironmentId)(envRef);
|
|
403
|
+
const envId = env.id;
|
|
404
|
+
if (!environmentMap.has(envId)) {
|
|
405
|
+
environmentMap.set(envId, env);
|
|
406
|
+
}
|
|
407
|
+
return envId;
|
|
408
|
+
};
|
|
409
|
+
// Replace env objects with env IDs in nodes
|
|
410
|
+
const processedNodes = nodes.map((node) => {
|
|
411
|
+
const processedNode = { ...node };
|
|
412
|
+
if (node.type === 'asset' && node.value?.env) {
|
|
413
|
+
processedNode.value = {
|
|
414
|
+
...node.value,
|
|
415
|
+
env: extractEnvironment(node.value.env),
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
else if (node.type === 'dependency' && node.value?.env) {
|
|
419
|
+
processedNode.value = {
|
|
420
|
+
...node.value,
|
|
421
|
+
env: extractEnvironment(node.value.env),
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
else if (node.type === 'bundle' && node.value?.env) {
|
|
425
|
+
processedNode.value = {
|
|
426
|
+
...node.value,
|
|
427
|
+
env: extractEnvironment(node.value.env),
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
return processedNode;
|
|
431
|
+
});
|
|
399
432
|
// Optimize nodes by omitting null/undefined values to reduce JSON size
|
|
400
|
-
const optimizedNodes =
|
|
433
|
+
const optimizedNodes = processedNodes.map((node) => this._omitNulls(node));
|
|
401
434
|
const nodesJson = JSON.stringify(optimizedNodes);
|
|
435
|
+
// Serialize environments as array
|
|
436
|
+
const environments = Array.from(environmentMap.values());
|
|
437
|
+
const environmentsJson = JSON.stringify(environments);
|
|
438
|
+
// Convert Map to plain object for serialization
|
|
439
|
+
const publicIdByAssetId = {};
|
|
440
|
+
for (const [assetId, publicId] of this._publicIdByAssetId) {
|
|
441
|
+
publicIdByAssetId[assetId] = publicId;
|
|
442
|
+
}
|
|
402
443
|
const duration = performance.now() - start;
|
|
403
|
-
const
|
|
444
|
+
const nodesSizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
|
|
445
|
+
const envsSizeMB = (environmentsJson.length / (1024 * 1024)).toFixed(2);
|
|
404
446
|
logger_1.default.verbose({
|
|
405
447
|
origin: '@atlaspack/core',
|
|
406
|
-
message: `serializeForNative: ${duration.toFixed(1)}ms, ${
|
|
448
|
+
message: `serializeForNative: ${duration.toFixed(1)}ms, ${nodesSizeMB}MB nodes, ${envsSizeMB}MB envs (${environmentMap.size} unique), ${nodes.length} nodes, ${edges.length} edges`,
|
|
407
449
|
});
|
|
408
|
-
return { nodesJson, edges };
|
|
450
|
+
return { nodesJson, edges, publicIdByAssetId, environmentsJson };
|
|
409
451
|
}
|
|
410
452
|
/**
|
|
411
453
|
* Remove null and undefined values from an object to reduce JSON size.
|
|
@@ -1164,8 +1206,36 @@ class BundleGraph {
|
|
|
1164
1206
|
});
|
|
1165
1207
|
}
|
|
1166
1208
|
/**
|
|
1167
|
-
*
|
|
1168
|
-
*
|
|
1209
|
+
* Performs a depth-first traversal of all assets and dependencies contained
|
|
1210
|
+
* within a bundle. Only visits nodes that are directly contained in the bundle
|
|
1211
|
+
* (connected via a `contains` edge).
|
|
1212
|
+
*
|
|
1213
|
+
* Entry Asset Ordering:
|
|
1214
|
+
* The traversal guarantees that entry assets are visited in the exact order they
|
|
1215
|
+
* appear in `bundle.entryAssetIds`. This ordering is critical for several reasons:
|
|
1216
|
+
*
|
|
1217
|
+
* 1. **Code Execution Order in Packagers**: Packagers (ScopeHoistingPackager,
|
|
1218
|
+
* DevPackager) use this traversal to concatenate assets into the final bundle.
|
|
1219
|
+
* The traversal order determines the execution order of code in the output.
|
|
1220
|
+
* Entry assets must be processed in their defined order to ensure correct
|
|
1221
|
+
* initialization sequences.
|
|
1222
|
+
*
|
|
1223
|
+
* 2. **Runtime Injection**: Runtime assets (HMR, bundle manifests) are prepended
|
|
1224
|
+
* to `entryAssetIds` via `unshift()` in `applyRuntimes.ts`. By honoring the
|
|
1225
|
+
* array order, runtimes are guaranteed to be visited (and thus output) before
|
|
1226
|
+
* application entry points, ensuring the runtime infrastructure is available
|
|
1227
|
+
* when application code executes.
|
|
1228
|
+
*
|
|
1229
|
+
* 3. **Deterministic Builds**: Consistent traversal order ensures reproducible
|
|
1230
|
+
* bundle output, which is essential for caching and build verification.
|
|
1231
|
+
*
|
|
1232
|
+
* The sorting only applies at the first traversal level (direct children of the
|
|
1233
|
+
* start node). Subsequent levels follow standard DFS order based on the graph's
|
|
1234
|
+
* edge structure.
|
|
1235
|
+
*
|
|
1236
|
+
* @param bundle - The bundle to traverse
|
|
1237
|
+
* @param visit - Visitor callback receiving asset or dependency nodes
|
|
1238
|
+
* @param startAsset - Optional asset to start traversal from (defaults to bundle root)
|
|
1169
1239
|
*/
|
|
1170
1240
|
traverseBundle(bundle, visit, startAsset) {
|
|
1171
1241
|
let entries = !startAsset;
|
|
@@ -52,11 +52,11 @@ class AtlaspackV3 {
|
|
|
52
52
|
return (0, rust_1.atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
|
|
53
53
|
}
|
|
54
54
|
loadBundleGraph(bundleGraph) {
|
|
55
|
-
const { nodesJson, edges } = bundleGraph.serializeForNative();
|
|
56
|
-
return (0, rust_1.atlaspackNapiLoadBundleGraph)(this._atlaspack_napi, nodesJson, edges);
|
|
55
|
+
const { nodesJson, edges, publicIdByAssetId, environmentsJson } = bundleGraph.serializeForNative();
|
|
56
|
+
return (0, rust_1.atlaspackNapiLoadBundleGraph)(this._atlaspack_napi, nodesJson, edges, publicIdByAssetId, environmentsJson);
|
|
57
57
|
}
|
|
58
|
-
package() {
|
|
59
|
-
return (0, rust_1.atlaspackNapiPackage)(this._atlaspack_napi);
|
|
58
|
+
package(bundleId) {
|
|
59
|
+
return (0, rust_1.atlaspackNapiPackage)(this._atlaspack_napi, bundleId);
|
|
60
60
|
}
|
|
61
61
|
async respondToFsEvents(events) {
|
|
62
62
|
// @ts-expect-error TS2488
|
|
@@ -11,6 +11,8 @@ const DevDepRequest_1 = require("./DevDepRequest");
|
|
|
11
11
|
const AtlaspackConfigRequest_1 = __importDefault(require("./AtlaspackConfigRequest"));
|
|
12
12
|
const EnvironmentManager_1 = require("../EnvironmentManager");
|
|
13
13
|
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
14
|
+
const logger_1 = __importDefault(require("@atlaspack/logger"));
|
|
15
|
+
const diagnostic_1 = __importDefault(require("@atlaspack/diagnostic"));
|
|
14
16
|
function createPackageRequest(input) {
|
|
15
17
|
return {
|
|
16
18
|
type: RequestTracker_1.requestTypes.package_request,
|
|
@@ -25,23 +27,38 @@ async function run({ input, api, farm, rustAtlaspack }) {
|
|
|
25
27
|
let start = Date.now();
|
|
26
28
|
let { devDeps, invalidDevDeps } = await (0, DevDepRequest_1.getDevDepRequests)(api);
|
|
27
29
|
let { cachePath } = (0, nullthrows_1.default)(await api.runRequest((0, AtlaspackConfigRequest_1.default)()));
|
|
30
|
+
let packagingResult;
|
|
28
31
|
if ((0, feature_flags_1.getFeatureFlag)('nativePackager') &&
|
|
29
32
|
(0, feature_flags_1.getFeatureFlag)('nativePackagerSSRDev') &&
|
|
30
33
|
rustAtlaspack &&
|
|
31
34
|
(0, EnvironmentManager_1.fromEnvironmentId)(bundle.env).context === 'tesseract' &&
|
|
32
35
|
bundle.type === 'js') {
|
|
33
36
|
// Once this actually does something, the code below will be in an `else` block (i.e. we'll only run one or the other)
|
|
34
|
-
await rustAtlaspack.package();
|
|
37
|
+
let result = await rustAtlaspack.package(bundle.id);
|
|
38
|
+
let error = null;
|
|
39
|
+
[packagingResult, error] = result;
|
|
40
|
+
if (error) {
|
|
41
|
+
throw new diagnostic_1.default({
|
|
42
|
+
diagnostic: error,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
logger_1.default.verbose({
|
|
46
|
+
message: JSON.stringify(packagingResult, null, 2),
|
|
47
|
+
origin: '@atlaspack/core',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
packagingResult = (await runPackage({
|
|
52
|
+
bundle,
|
|
53
|
+
bundleGraphReference,
|
|
54
|
+
optionsRef,
|
|
55
|
+
configCachePath: cachePath,
|
|
56
|
+
previousDevDeps: devDeps,
|
|
57
|
+
invalidDevDeps,
|
|
58
|
+
previousInvalidations: api.getInvalidations(),
|
|
59
|
+
}));
|
|
35
60
|
}
|
|
36
|
-
let { devDepRequests, configRequests, bundleInfo, invalidations } =
|
|
37
|
-
bundle,
|
|
38
|
-
bundleGraphReference,
|
|
39
|
-
optionsRef,
|
|
40
|
-
configCachePath: cachePath,
|
|
41
|
-
previousDevDeps: devDeps,
|
|
42
|
-
invalidDevDeps,
|
|
43
|
-
previousInvalidations: api.getInvalidations(),
|
|
44
|
-
}));
|
|
61
|
+
let { devDepRequests, configRequests, bundleInfo, invalidations } = packagingResult;
|
|
45
62
|
for (let devDepRequest of devDepRequests) {
|
|
46
63
|
await (0, DevDepRequest_1.runDevDepRequest)(api, devDepRequest);
|
|
47
64
|
}
|
package/lib/BundleGraph.js
CHANGED
|
@@ -85,7 +85,7 @@ const bundleGraphEdgeTypes = exports.bundleGraphEdgeTypes = {
|
|
|
85
85
|
internal_async: 5,
|
|
86
86
|
// This type is used to mark an edge between a bundle and a conditional bundle.
|
|
87
87
|
// This allows efficient discovery of conditional bundles in packaging
|
|
88
|
-
conditional:
|
|
88
|
+
conditional: 6
|
|
89
89
|
};
|
|
90
90
|
function makeReadOnlySet(set) {
|
|
91
91
|
return new Proxy(set, {
|
|
@@ -438,7 +438,7 @@ class BundleGraph {
|
|
|
438
438
|
|
|
439
439
|
/**
|
|
440
440
|
* Serialize the bundle graph for efficient transfer to native Rust code.
|
|
441
|
-
* Returns a JSON string of nodes
|
|
441
|
+
* Returns a JSON string of nodes, an array of edges, and a map of asset IDs to public IDs.
|
|
442
442
|
*/
|
|
443
443
|
serializeForNative() {
|
|
444
444
|
const start = performance.now();
|
|
@@ -452,18 +452,67 @@ class BundleGraph {
|
|
|
452
452
|
next = edgeIterator.next();
|
|
453
453
|
}
|
|
454
454
|
|
|
455
|
+
// Extract and deduplicate environments
|
|
456
|
+
const environmentMap = new Map();
|
|
457
|
+
const extractEnvironment = envRef => {
|
|
458
|
+
const env = (0, _EnvironmentManager.fromEnvironmentId)(envRef);
|
|
459
|
+
const envId = env.id;
|
|
460
|
+
if (!environmentMap.has(envId)) {
|
|
461
|
+
environmentMap.set(envId, env);
|
|
462
|
+
}
|
|
463
|
+
return envId;
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
// Replace env objects with env IDs in nodes
|
|
467
|
+
const processedNodes = nodes.map(node => {
|
|
468
|
+
var _node$value, _node$value2, _node$value3;
|
|
469
|
+
const processedNode = {
|
|
470
|
+
...node
|
|
471
|
+
};
|
|
472
|
+
if (node.type === 'asset' && (_node$value = node.value) !== null && _node$value !== void 0 && _node$value.env) {
|
|
473
|
+
processedNode.value = {
|
|
474
|
+
...node.value,
|
|
475
|
+
env: extractEnvironment(node.value.env)
|
|
476
|
+
};
|
|
477
|
+
} else if (node.type === 'dependency' && (_node$value2 = node.value) !== null && _node$value2 !== void 0 && _node$value2.env) {
|
|
478
|
+
processedNode.value = {
|
|
479
|
+
...node.value,
|
|
480
|
+
env: extractEnvironment(node.value.env)
|
|
481
|
+
};
|
|
482
|
+
} else if (node.type === 'bundle' && (_node$value3 = node.value) !== null && _node$value3 !== void 0 && _node$value3.env) {
|
|
483
|
+
processedNode.value = {
|
|
484
|
+
...node.value,
|
|
485
|
+
env: extractEnvironment(node.value.env)
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
return processedNode;
|
|
489
|
+
});
|
|
490
|
+
|
|
455
491
|
// Optimize nodes by omitting null/undefined values to reduce JSON size
|
|
456
|
-
const optimizedNodes =
|
|
492
|
+
const optimizedNodes = processedNodes.map(node => this._omitNulls(node));
|
|
457
493
|
const nodesJson = JSON.stringify(optimizedNodes);
|
|
494
|
+
|
|
495
|
+
// Serialize environments as array
|
|
496
|
+
const environments = Array.from(environmentMap.values());
|
|
497
|
+
const environmentsJson = JSON.stringify(environments);
|
|
498
|
+
|
|
499
|
+
// Convert Map to plain object for serialization
|
|
500
|
+
const publicIdByAssetId = {};
|
|
501
|
+
for (const [assetId, publicId] of this._publicIdByAssetId) {
|
|
502
|
+
publicIdByAssetId[assetId] = publicId;
|
|
503
|
+
}
|
|
458
504
|
const duration = performance.now() - start;
|
|
459
|
-
const
|
|
505
|
+
const nodesSizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
|
|
506
|
+
const envsSizeMB = (environmentsJson.length / (1024 * 1024)).toFixed(2);
|
|
460
507
|
_logger().default.verbose({
|
|
461
508
|
origin: '@atlaspack/core',
|
|
462
|
-
message: `serializeForNative: ${duration.toFixed(1)}ms, ${
|
|
509
|
+
message: `serializeForNative: ${duration.toFixed(1)}ms, ${nodesSizeMB}MB nodes, ${envsSizeMB}MB envs (${environmentMap.size} unique), ${nodes.length} nodes, ${edges.length} edges`
|
|
463
510
|
});
|
|
464
511
|
return {
|
|
465
512
|
nodesJson,
|
|
466
|
-
edges
|
|
513
|
+
edges,
|
|
514
|
+
publicIdByAssetId,
|
|
515
|
+
environmentsJson
|
|
467
516
|
};
|
|
468
517
|
}
|
|
469
518
|
|
|
@@ -1152,8 +1201,36 @@ class BundleGraph {
|
|
|
1152
1201
|
}
|
|
1153
1202
|
|
|
1154
1203
|
/**
|
|
1155
|
-
*
|
|
1156
|
-
*
|
|
1204
|
+
* Performs a depth-first traversal of all assets and dependencies contained
|
|
1205
|
+
* within a bundle. Only visits nodes that are directly contained in the bundle
|
|
1206
|
+
* (connected via a `contains` edge).
|
|
1207
|
+
*
|
|
1208
|
+
* Entry Asset Ordering:
|
|
1209
|
+
* The traversal guarantees that entry assets are visited in the exact order they
|
|
1210
|
+
* appear in `bundle.entryAssetIds`. This ordering is critical for several reasons:
|
|
1211
|
+
*
|
|
1212
|
+
* 1. **Code Execution Order in Packagers**: Packagers (ScopeHoistingPackager,
|
|
1213
|
+
* DevPackager) use this traversal to concatenate assets into the final bundle.
|
|
1214
|
+
* The traversal order determines the execution order of code in the output.
|
|
1215
|
+
* Entry assets must be processed in their defined order to ensure correct
|
|
1216
|
+
* initialization sequences.
|
|
1217
|
+
*
|
|
1218
|
+
* 2. **Runtime Injection**: Runtime assets (HMR, bundle manifests) are prepended
|
|
1219
|
+
* to `entryAssetIds` via `unshift()` in `applyRuntimes.ts`. By honoring the
|
|
1220
|
+
* array order, runtimes are guaranteed to be visited (and thus output) before
|
|
1221
|
+
* application entry points, ensuring the runtime infrastructure is available
|
|
1222
|
+
* when application code executes.
|
|
1223
|
+
*
|
|
1224
|
+
* 3. **Deterministic Builds**: Consistent traversal order ensures reproducible
|
|
1225
|
+
* bundle output, which is essential for caching and build verification.
|
|
1226
|
+
*
|
|
1227
|
+
* The sorting only applies at the first traversal level (direct children of the
|
|
1228
|
+
* start node). Subsequent levels follow standard DFS order based on the graph's
|
|
1229
|
+
* edge structure.
|
|
1230
|
+
*
|
|
1231
|
+
* @param bundle - The bundle to traverse
|
|
1232
|
+
* @param visit - Visitor callback receiving asset or dependency nodes
|
|
1233
|
+
* @param startAsset - Optional asset to start traversal from (defaults to bundle root)
|
|
1157
1234
|
*/
|
|
1158
1235
|
traverseBundle(bundle, visit, startAsset) {
|
|
1159
1236
|
let entries = !startAsset;
|
|
@@ -75,12 +75,14 @@ class AtlaspackV3 {
|
|
|
75
75
|
loadBundleGraph(bundleGraph) {
|
|
76
76
|
const {
|
|
77
77
|
nodesJson,
|
|
78
|
-
edges
|
|
78
|
+
edges,
|
|
79
|
+
publicIdByAssetId,
|
|
80
|
+
environmentsJson
|
|
79
81
|
} = bundleGraph.serializeForNative();
|
|
80
|
-
return (0, _rust().atlaspackNapiLoadBundleGraph)(this._atlaspack_napi, nodesJson, edges);
|
|
82
|
+
return (0, _rust().atlaspackNapiLoadBundleGraph)(this._atlaspack_napi, nodesJson, edges, publicIdByAssetId, environmentsJson);
|
|
81
83
|
}
|
|
82
|
-
package() {
|
|
83
|
-
return (0, _rust().atlaspackNapiPackage)(this._atlaspack_napi);
|
|
84
|
+
package(bundleId) {
|
|
85
|
+
return (0, _rust().atlaspackNapiPackage)(this._atlaspack_napi, bundleId);
|
|
84
86
|
}
|
|
85
87
|
async respondToFsEvents(events) {
|
|
86
88
|
// @ts-expect-error TS2488
|
|
@@ -23,6 +23,20 @@ function _featureFlags() {
|
|
|
23
23
|
};
|
|
24
24
|
return data;
|
|
25
25
|
}
|
|
26
|
+
function _logger() {
|
|
27
|
+
const data = _interopRequireDefault(require("@atlaspack/logger"));
|
|
28
|
+
_logger = function () {
|
|
29
|
+
return data;
|
|
30
|
+
};
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
function _diagnostic() {
|
|
34
|
+
const data = _interopRequireDefault(require("@atlaspack/diagnostic"));
|
|
35
|
+
_diagnostic = function () {
|
|
36
|
+
return data;
|
|
37
|
+
};
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
26
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
41
|
function createPackageRequest(input) {
|
|
28
42
|
return {
|
|
@@ -53,24 +67,38 @@ async function run({
|
|
|
53
67
|
let {
|
|
54
68
|
cachePath
|
|
55
69
|
} = (0, _nullthrows().default)(await api.runRequest((0, _AtlaspackConfigRequest.default)()));
|
|
70
|
+
let packagingResult;
|
|
56
71
|
if ((0, _featureFlags().getFeatureFlag)('nativePackager') && (0, _featureFlags().getFeatureFlag)('nativePackagerSSRDev') && rustAtlaspack && (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context === 'tesseract' && bundle.type === 'js') {
|
|
57
72
|
// Once this actually does something, the code below will be in an `else` block (i.e. we'll only run one or the other)
|
|
58
|
-
await rustAtlaspack.package();
|
|
73
|
+
let result = await rustAtlaspack.package(bundle.id);
|
|
74
|
+
let error = null;
|
|
75
|
+
[packagingResult, error] = result;
|
|
76
|
+
if (error) {
|
|
77
|
+
throw new (_diagnostic().default)({
|
|
78
|
+
diagnostic: error
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
_logger().default.verbose({
|
|
82
|
+
message: JSON.stringify(packagingResult, null, 2),
|
|
83
|
+
origin: '@atlaspack/core'
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
packagingResult = await runPackage({
|
|
87
|
+
bundle,
|
|
88
|
+
bundleGraphReference,
|
|
89
|
+
optionsRef,
|
|
90
|
+
configCachePath: cachePath,
|
|
91
|
+
previousDevDeps: devDeps,
|
|
92
|
+
invalidDevDeps,
|
|
93
|
+
previousInvalidations: api.getInvalidations()
|
|
94
|
+
});
|
|
59
95
|
}
|
|
60
96
|
let {
|
|
61
97
|
devDepRequests,
|
|
62
98
|
configRequests,
|
|
63
99
|
bundleInfo,
|
|
64
100
|
invalidations
|
|
65
|
-
} =
|
|
66
|
-
bundle,
|
|
67
|
-
bundleGraphReference,
|
|
68
|
-
optionsRef,
|
|
69
|
-
configCachePath: cachePath,
|
|
70
|
-
previousDevDeps: devDeps,
|
|
71
|
-
invalidDevDeps,
|
|
72
|
-
previousInvalidations: api.getInvalidations()
|
|
73
|
-
});
|
|
101
|
+
} = packagingResult;
|
|
74
102
|
for (let devDepRequest of devDepRequests) {
|
|
75
103
|
await (0, _DevDepRequest.runDevDepRequest)(api, devDepRequest);
|
|
76
104
|
}
|
|
@@ -11,7 +11,7 @@ export declare const bundleGraphEdgeTypes: {
|
|
|
11
11
|
readonly bundle: 3;
|
|
12
12
|
readonly references: 4;
|
|
13
13
|
readonly internal_async: 5;
|
|
14
|
-
readonly conditional:
|
|
14
|
+
readonly conditional: 6;
|
|
15
15
|
};
|
|
16
16
|
export type BundleGraphEdgeType = (typeof bundleGraphEdgeTypes)[keyof typeof bundleGraphEdgeTypes];
|
|
17
17
|
type InternalSymbolResolution = {
|
|
@@ -79,11 +79,13 @@ export default class BundleGraph {
|
|
|
79
79
|
static deserialize(serialized: BundleGraphOpts): BundleGraph;
|
|
80
80
|
/**
|
|
81
81
|
* Serialize the bundle graph for efficient transfer to native Rust code.
|
|
82
|
-
* Returns a JSON string of nodes
|
|
82
|
+
* Returns a JSON string of nodes, an array of edges, and a map of asset IDs to public IDs.
|
|
83
83
|
*/
|
|
84
84
|
serializeForNative(): {
|
|
85
85
|
nodesJson: string;
|
|
86
86
|
edges: [number, number, BundleGraphEdgeType][];
|
|
87
|
+
publicIdByAssetId: Record<string, string>;
|
|
88
|
+
environmentsJson: string;
|
|
87
89
|
};
|
|
88
90
|
/**
|
|
89
91
|
* Remove null and undefined values from an object to reduce JSON size.
|
|
@@ -148,8 +150,36 @@ export default class BundleGraph {
|
|
|
148
150
|
getParentBundles(bundle: Bundle): Array<Bundle>;
|
|
149
151
|
isAssetReachableFromBundle(asset: Asset, bundle: Bundle): boolean;
|
|
150
152
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
+
* Performs a depth-first traversal of all assets and dependencies contained
|
|
154
|
+
* within a bundle. Only visits nodes that are directly contained in the bundle
|
|
155
|
+
* (connected via a `contains` edge).
|
|
156
|
+
*
|
|
157
|
+
* Entry Asset Ordering:
|
|
158
|
+
* The traversal guarantees that entry assets are visited in the exact order they
|
|
159
|
+
* appear in `bundle.entryAssetIds`. This ordering is critical for several reasons:
|
|
160
|
+
*
|
|
161
|
+
* 1. **Code Execution Order in Packagers**: Packagers (ScopeHoistingPackager,
|
|
162
|
+
* DevPackager) use this traversal to concatenate assets into the final bundle.
|
|
163
|
+
* The traversal order determines the execution order of code in the output.
|
|
164
|
+
* Entry assets must be processed in their defined order to ensure correct
|
|
165
|
+
* initialization sequences.
|
|
166
|
+
*
|
|
167
|
+
* 2. **Runtime Injection**: Runtime assets (HMR, bundle manifests) are prepended
|
|
168
|
+
* to `entryAssetIds` via `unshift()` in `applyRuntimes.ts`. By honoring the
|
|
169
|
+
* array order, runtimes are guaranteed to be visited (and thus output) before
|
|
170
|
+
* application entry points, ensuring the runtime infrastructure is available
|
|
171
|
+
* when application code executes.
|
|
172
|
+
*
|
|
173
|
+
* 3. **Deterministic Builds**: Consistent traversal order ensures reproducible
|
|
174
|
+
* bundle output, which is essential for caching and build verification.
|
|
175
|
+
*
|
|
176
|
+
* The sorting only applies at the first traversal level (direct children of the
|
|
177
|
+
* start node). Subsequent levels follow standard DFS order based on the graph's
|
|
178
|
+
* edge structure.
|
|
179
|
+
*
|
|
180
|
+
* @param bundle - The bundle to traverse
|
|
181
|
+
* @param visit - Visitor callback receiving asset or dependency nodes
|
|
182
|
+
* @param startAsset - Optional asset to start traversal from (defaults to bundle root)
|
|
153
183
|
*/
|
|
154
184
|
traverseBundle<TContext>(bundle: Bundle, visit: GraphVisitor<AssetNode | DependencyNode, TContext>, startAsset?: Asset): TContext | null | undefined;
|
|
155
185
|
traverse<TContext>(visit: GraphVisitor<AssetNode | DependencyNode, TContext>, start?: Asset): TContext | null | undefined;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AtlaspackNapi, Lmdb, AtlaspackNapiOptions, CacheStats } from '@atlaspack/rust';
|
|
2
|
+
import { Diagnostic } from '@atlaspack/diagnostic';
|
|
2
3
|
import type { Event } from '@parcel/watcher';
|
|
3
4
|
import type { NapiWorkerPool as INapiWorkerPool } from '@atlaspack/types';
|
|
4
5
|
import type BundleGraph from '../BundleGraph';
|
|
6
|
+
import { RunPackagerRunnerResult } from '../PackagerRunner';
|
|
5
7
|
export type AtlaspackV3Options = {
|
|
6
8
|
fs?: AtlaspackNapiOptions['fs'];
|
|
7
9
|
packageManager?: AtlaspackNapiOptions['packageManager'];
|
|
@@ -24,7 +26,7 @@ export declare class AtlaspackV3 {
|
|
|
24
26
|
end(): void;
|
|
25
27
|
buildAssetGraph(): Promise<any>;
|
|
26
28
|
loadBundleGraph(bundleGraph: BundleGraph): Promise<void>;
|
|
27
|
-
package(): Promise<
|
|
29
|
+
package(bundleId: string): Promise<[RunPackagerRunnerResult, Diagnostic | null]>;
|
|
28
30
|
respondToFsEvents(events: Array<Event>): Promise<boolean>;
|
|
29
31
|
completeCacheSession(): Promise<CacheStats>;
|
|
30
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.32.
|
|
3
|
+
"version": "2.32.1",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
26
26
|
"@atlaspack/build-cache": "2.13.9",
|
|
27
|
-
"@atlaspack/cache": "3.2.
|
|
27
|
+
"@atlaspack/cache": "3.2.46",
|
|
28
28
|
"@atlaspack/diagnostic": "2.14.4",
|
|
29
29
|
"@atlaspack/events": "2.14.4",
|
|
30
30
|
"@atlaspack/feature-flags": "2.28.0",
|
|
31
|
-
"@atlaspack/fs": "2.15.
|
|
32
|
-
"@atlaspack/graph": "3.6.
|
|
33
|
-
"@atlaspack/logger": "2.14.
|
|
34
|
-
"@atlaspack/package-manager": "2.14.
|
|
35
|
-
"@atlaspack/plugin": "2.14.
|
|
36
|
-
"@atlaspack/profiler": "2.15.
|
|
37
|
-
"@atlaspack/rust": "3.
|
|
38
|
-
"@atlaspack/types": "2.15.
|
|
39
|
-
"@atlaspack/utils": "3.3.
|
|
40
|
-
"@atlaspack/workers": "2.14.
|
|
41
|
-
"@atlaspack/source-map": "3.2.
|
|
31
|
+
"@atlaspack/fs": "2.15.46",
|
|
32
|
+
"@atlaspack/graph": "3.6.13",
|
|
33
|
+
"@atlaspack/logger": "2.14.43",
|
|
34
|
+
"@atlaspack/package-manager": "2.14.51",
|
|
35
|
+
"@atlaspack/plugin": "2.14.51",
|
|
36
|
+
"@atlaspack/profiler": "2.15.12",
|
|
37
|
+
"@atlaspack/rust": "3.21.0",
|
|
38
|
+
"@atlaspack/types": "2.15.41",
|
|
39
|
+
"@atlaspack/utils": "3.3.3",
|
|
40
|
+
"@atlaspack/workers": "2.14.51",
|
|
41
|
+
"@atlaspack/source-map": "3.2.6",
|
|
42
42
|
"base-x": "^3.0.8",
|
|
43
43
|
"browserslist": "^4.6.6",
|
|
44
44
|
"clone": "^2.1.1",
|