@atlaspack/core 2.27.0 → 2.29.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 +60 -0
- package/dist/Atlaspack.js +5 -1
- package/dist/AtlaspackConfig.schema.js +9 -0
- package/dist/BundleGraph.js +105 -0
- package/dist/CommittedAsset.js +1 -1
- package/dist/Transformation.js +3 -2
- package/dist/UncommittedAsset.js +3 -3
- package/dist/assetUtils.js +2 -1
- package/dist/atlaspack-v3/AtlaspackV3.js +2 -9
- package/dist/atlaspack-v3/NapiWorkerPool.js +5 -1
- package/dist/atlaspack-v3/worker/compat/mutable-asset.js +1 -1
- package/dist/atlaspack-v3/worker/worker.js +1 -1
- package/dist/public/BundleGraph.js +12 -0
- package/dist/requests/AssetGraphRequestRust.js +17 -6
- package/dist/requests/BundleGraphRequest.js +5 -3
- package/dist/resolveOptions.js +1 -0
- package/dist/worker.js +1 -1
- package/lib/Atlaspack.js +5 -1
- package/lib/AtlaspackConfig.schema.js +9 -0
- package/lib/BundleGraph.js +107 -0
- package/lib/CommittedAsset.js +1 -1
- package/lib/Transformation.js +9 -4
- package/lib/UncommittedAsset.js +3 -3
- package/lib/assetUtils.js +8 -1
- package/lib/atlaspack-v3/AtlaspackV3.js +2 -9
- package/lib/atlaspack-v3/NapiWorkerPool.js +4 -1
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +1 -1
- package/lib/atlaspack-v3/worker/worker.js +1 -1
- package/lib/public/BundleGraph.js +13 -0
- package/lib/requests/AssetGraphRequestRust.js +20 -8
- package/lib/requests/BundleGraphRequest.js +4 -2
- package/lib/resolveOptions.js +1 -0
- package/lib/types/AtlaspackConfig.schema.d.ts +7 -0
- package/lib/types/BundleGraph.d.ts +2 -0
- package/lib/types/CommittedAsset.d.ts +1 -1
- package/lib/types/PackagerRunner.d.ts +1 -1
- package/lib/types/UncommittedAsset.d.ts +1 -1
- package/lib/types/atlaspack-v3/worker/compat/mutable-asset.d.ts +1 -1
- package/lib/types/public/Asset.d.ts +1 -1
- package/lib/types/public/BundleGraph.d.ts +2 -0
- package/lib/types/types.d.ts +1 -0
- package/lib/worker.js +1 -1
- package/package.json +14 -14
- package/src/Atlaspack.ts +6 -2
- package/src/AtlaspackConfig.schema.ts +9 -0
- package/src/BundleGraph.ts +152 -0
- package/src/CommittedAsset.ts +1 -1
- package/src/PackagerRunner.ts +1 -1
- package/src/Transformation.ts +3 -2
- package/src/UncommittedAsset.ts +3 -3
- package/src/assetUtils.ts +2 -1
- package/src/atlaspack-v3/AtlaspackV3.ts +2 -13
- package/src/atlaspack-v3/NapiWorkerPool.ts +5 -1
- package/src/atlaspack-v3/worker/compat/mutable-asset.ts +1 -1
- package/src/atlaspack-v3/worker/worker.ts +1 -1
- package/src/public/Asset.ts +1 -1
- package/src/public/BundleGraph.ts +21 -0
- package/src/requests/AssetGraphRequestRust.ts +23 -11
- package/src/requests/BundleGraphRequest.ts +9 -7
- package/src/resolveOptions.ts +1 -0
- package/src/types.ts +1 -0
- package/src/worker.ts +1 -1
- package/test/AtlaspackConfigRequest.test.ts +1 -1
- package/test/requests/AssetGraphRequestRust.test.ts +278 -276
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
# @atlaspack/core
|
|
2
2
|
|
|
3
|
+
## 2.29.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#898](https://github.com/atlassian-labs/atlaspack/pull/898) [`a884bd2`](https://github.com/atlassian-labs/atlaspack/commit/a884bd2a6bd6f37d088fb886dd9b88e85328501b) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Add `unstable_alias` feature to .parcelrc V3 builds for configuring build specific aliases
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#899](https://github.com/atlassian-labs/atlaspack/pull/899) [`5710532`](https://github.com/atlassian-labs/atlaspack/commit/57105322b26ce42af2cbfcc0506cff929e50b630) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Fix v3 environment ids not being consistent with v2
|
|
12
|
+
|
|
13
|
+
- [#901](https://github.com/atlassian-labs/atlaspack/pull/901) [`6fac01d`](https://github.com/atlassian-labs/atlaspack/commit/6fac01dbb1bfc5b971176c1a1c008297bf4b8f91) Thanks [@benjervis](https://github.com/benjervis)! - Makes the serialization and LMDB write steps into separate Promises, so that we can return them separately and parallelise some work.
|
|
14
|
+
|
|
15
|
+
- [#905](https://github.com/atlassian-labs/atlaspack/pull/905) [`432d571`](https://github.com/atlassian-labs/atlaspack/commit/432d571ea4e9fc67be12304fcafe8c445e844174) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Decrease max V3 JS workers to 4
|
|
16
|
+
|
|
17
|
+
- [#899](https://github.com/atlassian-labs/atlaspack/pull/899) [`5710532`](https://github.com/atlassian-labs/atlaspack/commit/57105322b26ce42af2cbfcc0506cff929e50b630) Thanks [@mattcompiles](https://github.com/mattcompiles)! - Add HMR and react-refresh support to v3
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`a884bd2`](https://github.com/atlassian-labs/atlaspack/commit/a884bd2a6bd6f37d088fb886dd9b88e85328501b), [`25fee72`](https://github.com/atlassian-labs/atlaspack/commit/25fee723d2228d0482ec8a8f1b8379ccd2977ce7), [`6fac01d`](https://github.com/atlassian-labs/atlaspack/commit/6fac01dbb1bfc5b971176c1a1c008297bf4b8f91), [`2f3af93`](https://github.com/atlassian-labs/atlaspack/commit/2f3af9374bcc082e6f4835f6f5a2b98e32ea45b4), [`432d571`](https://github.com/atlassian-labs/atlaspack/commit/432d571ea4e9fc67be12304fcafe8c445e844174), [`042cd95`](https://github.com/atlassian-labs/atlaspack/commit/042cd95a32ad38cd02d57aa3344c36d4e7ab8f9c), [`28f5424`](https://github.com/atlassian-labs/atlaspack/commit/28f5424f7e2080dd4fbbeb1bc5314a530197a23e), [`a884bd2`](https://github.com/atlassian-labs/atlaspack/commit/a884bd2a6bd6f37d088fb886dd9b88e85328501b), [`5710532`](https://github.com/atlassian-labs/atlaspack/commit/57105322b26ce42af2cbfcc0506cff929e50b630), [`44eb8c3`](https://github.com/atlassian-labs/atlaspack/commit/44eb8c388d3e63f1ef5d835aee7aee5d1bb0620f)]:
|
|
20
|
+
- @atlaspack/rust@3.12.0
|
|
21
|
+
- @atlaspack/feature-flags@2.27.1
|
|
22
|
+
- @atlaspack/cache@3.2.35
|
|
23
|
+
- @atlaspack/fs@2.15.35
|
|
24
|
+
- @atlaspack/logger@2.14.32
|
|
25
|
+
- @atlaspack/source-map@3.1.1
|
|
26
|
+
- @atlaspack/utils@3.2.1
|
|
27
|
+
- @atlaspack/graph@3.6.2
|
|
28
|
+
- @atlaspack/package-manager@2.14.40
|
|
29
|
+
- @atlaspack/profiler@2.15.1
|
|
30
|
+
- @atlaspack/workers@2.14.40
|
|
31
|
+
- @atlaspack/plugin@2.14.40
|
|
32
|
+
- @atlaspack/types@2.15.30
|
|
33
|
+
|
|
34
|
+
## 2.28.0
|
|
35
|
+
|
|
36
|
+
### Minor Changes
|
|
37
|
+
|
|
38
|
+
- [#858](https://github.com/atlassian-labs/atlaspack/pull/858) [`8eb84ee`](https://github.com/atlassian-labs/atlaspack/commit/8eb84ee61a42bfe87c58079b610802b07a6a13e4) Thanks [@marcins](https://github.com/marcins)! - Introduce a new `getReferencedAssets(bundle)` method to the BundleGraph to pre-compute referenced assets, this is used by the scope hoisting packager behind a new `precomputeReferencedAssets` feature flag.
|
|
39
|
+
|
|
40
|
+
- [#789](https://github.com/atlassian-labs/atlaspack/pull/789) [`73168c2`](https://github.com/atlassian-labs/atlaspack/commit/73168c275a5d9abff9907bcf536b340bca1ed5f0) Thanks [@marcins](https://github.com/marcins)! - Use an in-sourced version of @parcel/source-map, as @atlaspack/source-map
|
|
41
|
+
|
|
42
|
+
- [#892](https://github.com/atlassian-labs/atlaspack/pull/892) [`617a318`](https://github.com/atlassian-labs/atlaspack/commit/617a318ddc9419b38360257353fec50b9051ee13) Thanks [@marcins](https://github.com/marcins)! - Added a new `shouldProfileNative` option that provides a way to pause and connect a native profiler to Atlaspack.
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- [#890](https://github.com/atlassian-labs/atlaspack/pull/890) [`7dd5bd8`](https://github.com/atlassian-labs/atlaspack/commit/7dd5bd89ff60c7b324347d772729eb4c3314f01e) Thanks [@matt-koko](https://github.com/matt-koko)! - fix sideEffects not defaulting to true correctly in v3
|
|
47
|
+
|
|
48
|
+
- Updated dependencies [[`7dd5bd8`](https://github.com/atlassian-labs/atlaspack/commit/7dd5bd89ff60c7b324347d772729eb4c3314f01e), [`c8a0e51`](https://github.com/atlassian-labs/atlaspack/commit/c8a0e51b1096d038a64644ad02fe68383f58682a), [`8eb84ee`](https://github.com/atlassian-labs/atlaspack/commit/8eb84ee61a42bfe87c58079b610802b07a6a13e4), [`71900f3`](https://github.com/atlassian-labs/atlaspack/commit/71900f3508d53c3882ca8ea71501ba3069687d4e), [`73168c2`](https://github.com/atlassian-labs/atlaspack/commit/73168c275a5d9abff9907bcf536b340bca1ed5f0), [`617a318`](https://github.com/atlassian-labs/atlaspack/commit/617a318ddc9419b38360257353fec50b9051ee13), [`2c4953e`](https://github.com/atlassian-labs/atlaspack/commit/2c4953e20dc1a6b012792081667aefeb9340505e), [`3fe7d4e`](https://github.com/atlassian-labs/atlaspack/commit/3fe7d4e821bee162fcbbaf9278b107a5eead944f)]:
|
|
49
|
+
- @atlaspack/rust@3.11.0
|
|
50
|
+
- @atlaspack/feature-flags@2.27.0
|
|
51
|
+
- @atlaspack/source-map@3.1.0
|
|
52
|
+
- @atlaspack/utils@3.2.0
|
|
53
|
+
- @atlaspack/profiler@2.15.0
|
|
54
|
+
- @atlaspack/cache@3.2.34
|
|
55
|
+
- @atlaspack/fs@2.15.34
|
|
56
|
+
- @atlaspack/logger@2.14.31
|
|
57
|
+
- @atlaspack/graph@3.6.1
|
|
58
|
+
- @atlaspack/plugin@2.14.39
|
|
59
|
+
- @atlaspack/types@2.15.29
|
|
60
|
+
- @atlaspack/workers@2.14.39
|
|
61
|
+
- @atlaspack/package-manager@2.14.39
|
|
62
|
+
|
|
3
63
|
## 2.27.0
|
|
4
64
|
|
|
5
65
|
### Minor Changes
|
package/dist/Atlaspack.js
CHANGED
|
@@ -76,7 +76,7 @@ const PathRequest_1 = __importDefault(require("./requests/PathRequest"));
|
|
|
76
76
|
const Environment_1 = require("./Environment");
|
|
77
77
|
const Dependency_1 = require("./Dependency");
|
|
78
78
|
const events_2 = require("@atlaspack/events");
|
|
79
|
-
const source_map_1 = require("@
|
|
79
|
+
const source_map_1 = require("@atlaspack/source-map");
|
|
80
80
|
const cache_1 = require("@atlaspack/cache");
|
|
81
81
|
const rust_1 = require("@atlaspack/rust");
|
|
82
82
|
const projectPath_1 = require("./projectPath");
|
|
@@ -356,6 +356,10 @@ class Atlaspack {
|
|
|
356
356
|
if (options.shouldProfile) {
|
|
357
357
|
await this.startProfiling();
|
|
358
358
|
}
|
|
359
|
+
if (options.nativeProfiler) {
|
|
360
|
+
const nativeProfiler = new profiler_1.NativeProfiler();
|
|
361
|
+
await nativeProfiler.startProfiling(options.nativeProfiler);
|
|
362
|
+
}
|
|
359
363
|
if (options.shouldTrace) {
|
|
360
364
|
profiler_1.tracer.enable();
|
|
361
365
|
// We need to ensure the tracer is disabled when Atlaspack is disposed as it is a module level object.
|
|
@@ -97,6 +97,15 @@ exports.default = {
|
|
|
97
97
|
compressors: mapPipelineSchema('compressor', 'compressors'),
|
|
98
98
|
reporters: pipelineSchema('reporter', 'reporters'),
|
|
99
99
|
runtimes: pipelineSchema('runtime', 'runtimes'),
|
|
100
|
+
// This isn't currently supported in V2, however we need to allow it to
|
|
101
|
+
// parse as even V3 builds need the AtlaspackConfigRequest
|
|
102
|
+
unstable_alias: {
|
|
103
|
+
type: 'object',
|
|
104
|
+
properties: {},
|
|
105
|
+
additionalProperties: {
|
|
106
|
+
type: 'string',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
100
109
|
filePath: {
|
|
101
110
|
type: 'string',
|
|
102
111
|
},
|
package/dist/BundleGraph.js
CHANGED
|
@@ -920,6 +920,111 @@ class BundleGraph {
|
|
|
920
920
|
return isReferenced;
|
|
921
921
|
});
|
|
922
922
|
}
|
|
923
|
+
// New method: Fast checks only (no caching of results)
|
|
924
|
+
isAssetReferencedFastCheck(bundle, asset) {
|
|
925
|
+
// Fast Check #1: If asset is in multiple bundles in same target, it's referenced
|
|
926
|
+
let bundlesWithAsset = this.getBundlesWithAsset(asset).filter((b) => b.target.name === bundle.target.name &&
|
|
927
|
+
b.target.distDir === bundle.target.distDir);
|
|
928
|
+
if (bundlesWithAsset.length > 1) {
|
|
929
|
+
return true;
|
|
930
|
+
}
|
|
931
|
+
// Fast Check #2: If asset is referenced by any async/conditional dependency, it's referenced
|
|
932
|
+
let assetNodeId = (0, nullthrows_1.default)(this._graph.getNodeIdByContentKey(asset.id));
|
|
933
|
+
if (this._graph
|
|
934
|
+
.getNodeIdsConnectedTo(assetNodeId, exports.bundleGraphEdgeTypes.references)
|
|
935
|
+
.map((id) => this._graph.getNode(id))
|
|
936
|
+
.some((node) => node?.type === 'dependency' &&
|
|
937
|
+
(node.value.priority === types_1.Priority.lazy ||
|
|
938
|
+
node.value.priority === types_1.Priority.conditional) &&
|
|
939
|
+
node.value.specifierType !== types_1.SpecifierType.url)) {
|
|
940
|
+
return true;
|
|
941
|
+
}
|
|
942
|
+
// Fast checks failed - return null to indicate expensive computation needed
|
|
943
|
+
return null;
|
|
944
|
+
}
|
|
945
|
+
getReferencedAssets(bundle) {
|
|
946
|
+
let referencedAssets = new Set();
|
|
947
|
+
// Build a map of all assets in this bundle with their dependencies
|
|
948
|
+
// This allows us to check all assets in a single traversal
|
|
949
|
+
let assetDependenciesMap = new Map();
|
|
950
|
+
this.traverseAssets(bundle, (asset) => {
|
|
951
|
+
// Always do fast checks (no caching)
|
|
952
|
+
let fastCheckResult = this.isAssetReferencedFastCheck(bundle, asset);
|
|
953
|
+
if (fastCheckResult === true) {
|
|
954
|
+
referencedAssets.add(asset);
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
// Fast checks failed (fastCheckResult === null), need expensive computation
|
|
958
|
+
// Check if it's actually referenced via traversal
|
|
959
|
+
// Store dependencies for later batch checking
|
|
960
|
+
let dependencies = this._graph
|
|
961
|
+
.getNodeIdsConnectedTo((0, nullthrows_1.default)(this._graph.getNodeIdByContentKey(asset.id)))
|
|
962
|
+
.map((id) => (0, nullthrows_1.default)(this._graph.getNode(id)))
|
|
963
|
+
.filter((node) => node.type === 'dependency')
|
|
964
|
+
.map((node) => {
|
|
965
|
+
(0, assert_2.default)(node.type === 'dependency');
|
|
966
|
+
return node.value;
|
|
967
|
+
});
|
|
968
|
+
if (dependencies.length > 0) {
|
|
969
|
+
assetDependenciesMap.set(asset, dependencies);
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
// If no assets need the expensive check, return early
|
|
973
|
+
if (assetDependenciesMap.size === 0) {
|
|
974
|
+
return referencedAssets;
|
|
975
|
+
}
|
|
976
|
+
// Get the assets we need to check once
|
|
977
|
+
let assetsToCheck = Array.from(assetDependenciesMap.keys());
|
|
978
|
+
// Helper function to check if all assets from assetDependenciesMap are in referencedAssets
|
|
979
|
+
const allAssetsReferenced = () => assetsToCheck.length <= referencedAssets.size &&
|
|
980
|
+
assetsToCheck.every((asset) => referencedAssets.has(asset));
|
|
981
|
+
// Do ONE traversal to check all remaining assets
|
|
982
|
+
// We can share visitedBundles across all assets because we check every asset
|
|
983
|
+
// against every visited bundle, which matches the original per-asset behavior
|
|
984
|
+
let siblingBundles = new Set(this.getBundleGroupsContainingBundle(bundle).flatMap((bundleGroup) => this.getBundlesInBundleGroup(bundleGroup, { includeInline: true })));
|
|
985
|
+
let visitedBundles = new Set();
|
|
986
|
+
// Single traversal from all referencers
|
|
987
|
+
for (let referencer of siblingBundles) {
|
|
988
|
+
this.traverseBundles((descendant, _, actions) => {
|
|
989
|
+
if (descendant.id === bundle.id) {
|
|
990
|
+
return;
|
|
991
|
+
}
|
|
992
|
+
if (visitedBundles.has(descendant)) {
|
|
993
|
+
actions.skipChildren();
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
visitedBundles.add(descendant);
|
|
997
|
+
if (descendant.type !== bundle.type ||
|
|
998
|
+
(0, EnvironmentManager_1.fromEnvironmentId)(descendant.env).context !==
|
|
999
|
+
(0, EnvironmentManager_1.fromEnvironmentId)(bundle.env).context) {
|
|
1000
|
+
// Don't skip children - they might be the right type!
|
|
1001
|
+
return;
|
|
1002
|
+
}
|
|
1003
|
+
// Check ALL assets at once in this descendant bundle
|
|
1004
|
+
for (let [asset, dependencies] of assetDependenciesMap) {
|
|
1005
|
+
// Skip if already marked as referenced
|
|
1006
|
+
if (referencedAssets.has(asset)) {
|
|
1007
|
+
continue;
|
|
1008
|
+
}
|
|
1009
|
+
// Check if this descendant bundle references the asset
|
|
1010
|
+
if (!this.bundleHasAsset(descendant, asset) &&
|
|
1011
|
+
dependencies.some((dependency) => this.bundleHasDependency(descendant, dependency))) {
|
|
1012
|
+
referencedAssets.add(asset);
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
// If all assets from assetDependenciesMap are now marked as referenced, we can stop early
|
|
1016
|
+
if (allAssetsReferenced()) {
|
|
1017
|
+
actions.stop();
|
|
1018
|
+
return;
|
|
1019
|
+
}
|
|
1020
|
+
}, referencer);
|
|
1021
|
+
// If all assets from assetDependenciesMap are referenced, no need to check more sibling bundles
|
|
1022
|
+
if (allAssetsReferenced()) {
|
|
1023
|
+
break;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
return referencedAssets;
|
|
1027
|
+
}
|
|
923
1028
|
hasParentBundleOfType(bundle, type) {
|
|
924
1029
|
let parents = this.getParentBundles(bundle);
|
|
925
1030
|
return (parents.length > 0 && parents.every((parent) => parent.type === type));
|
package/dist/CommittedAsset.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const stream_1 = require("stream");
|
|
7
7
|
const build_cache_1 = require("@atlaspack/build-cache");
|
|
8
8
|
const utils_1 = require("@atlaspack/utils");
|
|
9
|
-
const source_map_1 = __importDefault(require("@
|
|
9
|
+
const source_map_1 = __importDefault(require("@atlaspack/source-map"));
|
|
10
10
|
const assetUtils_1 = require("./assetUtils");
|
|
11
11
|
class CommittedAsset {
|
|
12
12
|
constructor(value, options) {
|
package/dist/Transformation.js
CHANGED
|
@@ -58,6 +58,7 @@ const projectPath_1 = require("./projectPath");
|
|
|
58
58
|
const utils_3 = require("./utils");
|
|
59
59
|
const assert_1 = __importDefault(require("assert"));
|
|
60
60
|
const profiler_1 = require("@atlaspack/profiler");
|
|
61
|
+
const source_map_1 = __importDefault(require("@atlaspack/source-map"));
|
|
61
62
|
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
62
63
|
class Transformation {
|
|
63
64
|
constructor({ request, options, config, workerApi }) {
|
|
@@ -316,7 +317,7 @@ class Transformation {
|
|
|
316
317
|
if (asset.isASTDirty && asset.generate) {
|
|
317
318
|
let output = await asset.generate();
|
|
318
319
|
asset.content = output.content;
|
|
319
|
-
asset.mapBuffer = output.map
|
|
320
|
+
asset.mapBuffer = source_map_1.default.safeToBuffer(output.map);
|
|
320
321
|
}
|
|
321
322
|
asset.clearAST();
|
|
322
323
|
}));
|
|
@@ -415,7 +416,7 @@ class Transformation {
|
|
|
415
416
|
asset.generate) {
|
|
416
417
|
let output = await asset.generate();
|
|
417
418
|
asset.content = output.content;
|
|
418
|
-
asset.mapBuffer = output.map
|
|
419
|
+
asset.mapBuffer = source_map_1.default.safeToBuffer(output.map);
|
|
419
420
|
}
|
|
420
421
|
// Load config for the transformer.
|
|
421
422
|
let config = preloadedConfig;
|
package/dist/UncommittedAsset.js
CHANGED
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const assert_1 = __importDefault(require("assert"));
|
|
7
7
|
const stream_1 = require("stream");
|
|
8
|
-
const source_map_1 = __importDefault(require("@
|
|
8
|
+
const source_map_1 = __importDefault(require("@atlaspack/source-map"));
|
|
9
9
|
const build_cache_1 = require("@atlaspack/build-cache");
|
|
10
10
|
const utils_1 = require("@atlaspack/utils");
|
|
11
11
|
const rust_1 = require("@atlaspack/rust");
|
|
@@ -163,7 +163,7 @@ class UncommittedAsset {
|
|
|
163
163
|
});
|
|
164
164
|
if (map) {
|
|
165
165
|
this.map = map;
|
|
166
|
-
this.mapBuffer =
|
|
166
|
+
this.mapBuffer = source_map_1.default.safeToBuffer(map);
|
|
167
167
|
this.setCode(code.replace(utils_1.SOURCEMAP_RE, ''));
|
|
168
168
|
}
|
|
169
169
|
return this.map;
|
|
@@ -295,7 +295,7 @@ class UncommittedAsset {
|
|
|
295
295
|
content,
|
|
296
296
|
ast: result.ast,
|
|
297
297
|
isASTDirty: result.ast === this.ast ? this.isASTDirty : true,
|
|
298
|
-
mapBuffer:
|
|
298
|
+
mapBuffer: source_map_1.default.safeToBuffer(result.map),
|
|
299
299
|
code: this.code,
|
|
300
300
|
invalidations: this.invalidations,
|
|
301
301
|
});
|
package/dist/assetUtils.js
CHANGED
|
@@ -23,6 +23,7 @@ const types_1 = require("./types");
|
|
|
23
23
|
const profiler_1 = require("@atlaspack/profiler");
|
|
24
24
|
const IdentifierRegistry_1 = require("./IdentifierRegistry");
|
|
25
25
|
const EnvironmentManager_1 = require("./EnvironmentManager");
|
|
26
|
+
const source_map_1 = __importDefault(require("@atlaspack/source-map"));
|
|
26
27
|
function createAssetIdFromOptions(options) {
|
|
27
28
|
const data = {
|
|
28
29
|
environmentId: (0, EnvironmentManager_1.toEnvironmentId)(options.env),
|
|
@@ -102,7 +103,7 @@ async function _generateFromAST(asset) {
|
|
|
102
103
|
logger: new logger_1.PluginLogger({ origin: pluginName }),
|
|
103
104
|
tracer: new profiler_1.PluginTracer({ origin: pluginName, category: 'asset-generate' }),
|
|
104
105
|
});
|
|
105
|
-
let mapBuffer = map
|
|
106
|
+
let mapBuffer = source_map_1.default.safeToBuffer(map);
|
|
106
107
|
// Store the results in the cache so we can avoid generating again next time
|
|
107
108
|
await Promise.all([
|
|
108
109
|
asset.options.cache.setStream((0, nullthrows_1.default)(asset.value.contentKey), (0, utils_1.blobToStream)(content)),
|
|
@@ -48,15 +48,8 @@ class AtlaspackV3 {
|
|
|
48
48
|
this._napiWorkerPool.shutdown();
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
let [graph, error] = await (0, rust_1.atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
|
|
54
|
-
if (error !== null) {
|
|
55
|
-
throw new diagnostic_1.default({
|
|
56
|
-
diagnostic: error,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return graph;
|
|
51
|
+
buildAssetGraph() {
|
|
52
|
+
return (0, rust_1.atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
|
|
60
53
|
}
|
|
61
54
|
async respondToFsEvents(events) {
|
|
62
55
|
// @ts-expect-error TS2488
|
|
@@ -29,7 +29,11 @@ class NapiWorkerPool {
|
|
|
29
29
|
_NapiWorkerPool_napiWorkers.set(this, void 0);
|
|
30
30
|
_NapiWorkerPool_workerCount.set(this, void 0);
|
|
31
31
|
// @ts-expect-error TS2322
|
|
32
|
-
__classPrivateFieldSet(this, _NapiWorkerPool_workerCount, workerCount ??
|
|
32
|
+
__classPrivateFieldSet(this, _NapiWorkerPool_workerCount, workerCount ??
|
|
33
|
+
ATLASPACK_NAPI_WORKERS ??
|
|
34
|
+
// Default to a maximum of 4 workers as performance worsens beyond that
|
|
35
|
+
// point in most cases
|
|
36
|
+
Math.min((0, rust_1.getAvailableThreads)(), 4), "f");
|
|
33
37
|
if (!__classPrivateFieldGet(this, _NapiWorkerPool_workerCount, "f")) {
|
|
34
38
|
// TODO use main thread if workerCount is 0
|
|
35
39
|
}
|
|
@@ -16,7 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
16
16
|
var _MutableAsset_astDirty, _MutableAsset_ast, _MutableAsset_contents, _MutableAsset_inner, _MutableAsset_map, _MutableAsset_projectRoot, _MutableAsset_sourceMap;
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.MutableAsset = void 0;
|
|
19
|
-
const source_map_1 = __importDefault(require("@
|
|
19
|
+
const source_map_1 = __importDefault(require("@atlaspack/source-map"));
|
|
20
20
|
const stream_1 = require("stream");
|
|
21
21
|
const bitflags_1 = require("./bitflags");
|
|
22
22
|
const asset_symbols_1 = require("./asset-symbols");
|
|
@@ -162,7 +162,7 @@ class AtlaspackWorker {
|
|
|
162
162
|
type: 'resolved',
|
|
163
163
|
filePath: result.filePath || '',
|
|
164
164
|
canDefer: result.canDefer || false,
|
|
165
|
-
sideEffects: result.sideEffects
|
|
165
|
+
sideEffects: result.sideEffects ?? true,
|
|
166
166
|
code: result.code || undefined,
|
|
167
167
|
meta: result.meta || undefined,
|
|
168
168
|
pipeline: result.pipeline || undefined,
|
|
@@ -148,6 +148,18 @@ class BundleGraph {
|
|
|
148
148
|
isAssetReferenced(bundle, asset) {
|
|
149
149
|
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").isAssetReferenced((0, Bundle_1.bundleToInternalBundle)(bundle), (0, Asset_1.assetToAssetValue)(asset));
|
|
150
150
|
}
|
|
151
|
+
isAssetReferencedFastCheck(bundle, asset) {
|
|
152
|
+
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").isAssetReferencedFastCheck((0, Bundle_1.bundleToInternalBundle)(bundle), (0, Asset_1.assetToAssetValue)(asset));
|
|
153
|
+
}
|
|
154
|
+
getReferencedAssets(bundle) {
|
|
155
|
+
let internalReferencedAssets = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getReferencedAssets((0, Bundle_1.bundleToInternalBundle)(bundle));
|
|
156
|
+
// Convert internal assets to public assets
|
|
157
|
+
let publicReferencedAssets = new Set();
|
|
158
|
+
for (let internalAsset of internalReferencedAssets) {
|
|
159
|
+
publicReferencedAssets.add((0, Asset_1.assetFromValue)(internalAsset, __classPrivateFieldGet(this, _BundleGraph_options, "f")));
|
|
160
|
+
}
|
|
161
|
+
return publicReferencedAssets;
|
|
162
|
+
}
|
|
151
163
|
hasParentBundleOfType(bundle, type) {
|
|
152
164
|
return __classPrivateFieldGet(this, _BundleGraph_graph, "f").hasParentBundleOfType((0, Bundle_1.bundleToInternalBundle)(bundle), type);
|
|
153
165
|
}
|
|
@@ -22,11 +22,13 @@ function createAssetGraphRequestRust(rustAtlaspack) {
|
|
|
22
22
|
id: input.name,
|
|
23
23
|
run: async (input) => {
|
|
24
24
|
let options = input.options;
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
let { assetGraphPromise, commitPromise } = await rustAtlaspack.buildAssetGraph();
|
|
26
|
+
let [serializedAssetGraph, assetGraphError] = (await assetGraphPromise);
|
|
27
|
+
if (assetGraphError) {
|
|
28
|
+
throw new diagnostic_1.default({
|
|
29
|
+
diagnostic: assetGraphError,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
30
32
|
// Don't reuse a previous asset graph result if Rust didn't have one too
|
|
31
33
|
let prevResult = null;
|
|
32
34
|
if (serializedAssetGraph.hadPreviousGraph) {
|
|
@@ -58,6 +60,14 @@ function createAssetGraphRequestRust(rustAtlaspack) {
|
|
|
58
60
|
changedAssetsPropagation,
|
|
59
61
|
previousSymbolPropagationErrors: undefined,
|
|
60
62
|
};
|
|
63
|
+
let [_commitResult, commitError] = await commitPromise;
|
|
64
|
+
if (commitError) {
|
|
65
|
+
throw new diagnostic_1.default({
|
|
66
|
+
diagnostic: {
|
|
67
|
+
message: 'Error committing asset graph in Rust: ' + commitError.message,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
61
71
|
await input.api.storeResult(result);
|
|
62
72
|
input.api.invalidateOnBuild();
|
|
63
73
|
return result;
|
|
@@ -146,7 +156,7 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
|
|
|
146
156
|
].join(':');
|
|
147
157
|
let envId = envs.get(envKey);
|
|
148
158
|
if (envId == null) {
|
|
149
|
-
envId =
|
|
159
|
+
envId = (0, Environment_1.getEnvironmentHash)(env);
|
|
150
160
|
envs.set(envKey, envId);
|
|
151
161
|
}
|
|
152
162
|
return envId;
|
|
@@ -168,6 +178,7 @@ function getAssetGraph(serializedGraph, prevAssetGraph) {
|
|
|
168
178
|
let node = isUpdateNode
|
|
169
179
|
? serializedGraph.updates[index - nodeTypeSwitchoverIndex]
|
|
170
180
|
: serializedGraph.nodes[index];
|
|
181
|
+
node = JSON.parse(node);
|
|
171
182
|
if (node.type === 'entry') {
|
|
172
183
|
let id = 'entry:' + ++entry;
|
|
173
184
|
graph.addNodeByContentKey(id, {
|
|
@@ -116,9 +116,11 @@ function createBundleGraphRequest(input) {
|
|
|
116
116
|
lazyExcludes: options.lazyExcludes,
|
|
117
117
|
requestedAssetIds,
|
|
118
118
|
});
|
|
119
|
-
let { assetGraph, changedAssets, assetRequests } = await
|
|
120
|
-
|
|
121
|
-
(
|
|
119
|
+
let { assetGraph, changedAssets, assetRequests } = await (0, logger_1.instrumentAsync)('asset-graph-request', () => {
|
|
120
|
+
return api.runRequest(request, {
|
|
121
|
+
force: Boolean(input.rustAtlaspack) ||
|
|
122
|
+
(options.shouldBuildLazily && requestedAssetIds.size > 0),
|
|
123
|
+
});
|
|
122
124
|
});
|
|
123
125
|
if (input.options.featureFlags?.loadableSideEffects) {
|
|
124
126
|
applySideEffectsForLoadableImports(assetGraph);
|
package/dist/resolveOptions.js
CHANGED
|
@@ -190,6 +190,7 @@ async function resolveOptions(initialOptions) {
|
|
|
190
190
|
: false,
|
|
191
191
|
shouldDisableCache: initialOptions.shouldDisableCache ?? false,
|
|
192
192
|
shouldProfile: initialOptions.shouldProfile ?? false,
|
|
193
|
+
nativeProfiler: initialOptions.nativeProfiler,
|
|
193
194
|
shouldTrace: initialOptions.shouldTrace ?? false,
|
|
194
195
|
cacheDir,
|
|
195
196
|
watchDir,
|
package/dist/worker.js
CHANGED
|
@@ -21,7 +21,7 @@ const Validation_1 = __importDefault(require("./Validation"));
|
|
|
21
21
|
const AtlaspackConfig_1 = require("./AtlaspackConfig");
|
|
22
22
|
const registerCoreWithSerializer_1 = require("./registerCoreWithSerializer");
|
|
23
23
|
const build_cache_1 = require("@atlaspack/build-cache");
|
|
24
|
-
const source_map_1 = require("@
|
|
24
|
+
const source_map_1 = require("@atlaspack/source-map");
|
|
25
25
|
// @ts-expect-error TS2305
|
|
26
26
|
const rust_1 = require("@atlaspack/rust");
|
|
27
27
|
const workers_1 = __importDefault(require("@atlaspack/workers"));
|
package/lib/Atlaspack.js
CHANGED
|
@@ -80,7 +80,7 @@ var _PathRequest = _interopRequireDefault(require("./requests/PathRequest"));
|
|
|
80
80
|
var _Environment = require("./Environment");
|
|
81
81
|
var _Dependency = require("./Dependency");
|
|
82
82
|
function _sourceMap() {
|
|
83
|
-
const data = require("@
|
|
83
|
+
const data = require("@atlaspack/source-map");
|
|
84
84
|
_sourceMap = function () {
|
|
85
85
|
return data;
|
|
86
86
|
};
|
|
@@ -410,6 +410,10 @@ class Atlaspack {
|
|
|
410
410
|
if (options.shouldProfile) {
|
|
411
411
|
await this.startProfiling();
|
|
412
412
|
}
|
|
413
|
+
if (options.nativeProfiler) {
|
|
414
|
+
const nativeProfiler = new (_profiler().NativeProfiler)();
|
|
415
|
+
await nativeProfiler.startProfiling(options.nativeProfiler);
|
|
416
|
+
}
|
|
413
417
|
if (options.shouldTrace) {
|
|
414
418
|
_profiler().tracer.enable();
|
|
415
419
|
// We need to ensure the tracer is disabled when Atlaspack is disposed as it is a module level object.
|
|
@@ -94,6 +94,15 @@ var _default = exports.default = {
|
|
|
94
94
|
compressors: mapPipelineSchema('compressor', 'compressors'),
|
|
95
95
|
reporters: pipelineSchema('reporter', 'reporters'),
|
|
96
96
|
runtimes: pipelineSchema('runtime', 'runtimes'),
|
|
97
|
+
// This isn't currently supported in V2, however we need to allow it to
|
|
98
|
+
// parse as even V3 builds need the AtlaspackConfigRequest
|
|
99
|
+
unstable_alias: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {},
|
|
102
|
+
additionalProperties: {
|
|
103
|
+
type: 'string'
|
|
104
|
+
}
|
|
105
|
+
},
|
|
97
106
|
filePath: {
|
|
98
107
|
type: 'string'
|
|
99
108
|
},
|
package/lib/BundleGraph.js
CHANGED
|
@@ -914,6 +914,113 @@ class BundleGraph {
|
|
|
914
914
|
return isReferenced;
|
|
915
915
|
});
|
|
916
916
|
}
|
|
917
|
+
|
|
918
|
+
// New method: Fast checks only (no caching of results)
|
|
919
|
+
isAssetReferencedFastCheck(bundle, asset) {
|
|
920
|
+
// Fast Check #1: If asset is in multiple bundles in same target, it's referenced
|
|
921
|
+
let bundlesWithAsset = this.getBundlesWithAsset(asset).filter(b => b.target.name === bundle.target.name && b.target.distDir === bundle.target.distDir);
|
|
922
|
+
if (bundlesWithAsset.length > 1) {
|
|
923
|
+
return true;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
// Fast Check #2: If asset is referenced by any async/conditional dependency, it's referenced
|
|
927
|
+
let assetNodeId = (0, _nullthrows().default)(this._graph.getNodeIdByContentKey(asset.id));
|
|
928
|
+
if (this._graph.getNodeIdsConnectedTo(assetNodeId, bundleGraphEdgeTypes.references).map(id => this._graph.getNode(id)).some(node => (node === null || node === void 0 ? void 0 : node.type) === 'dependency' && (node.value.priority === _types.Priority.lazy || node.value.priority === _types.Priority.conditional) && node.value.specifierType !== _types.SpecifierType.url)) {
|
|
929
|
+
return true;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
// Fast checks failed - return null to indicate expensive computation needed
|
|
933
|
+
return null;
|
|
934
|
+
}
|
|
935
|
+
getReferencedAssets(bundle) {
|
|
936
|
+
let referencedAssets = new Set();
|
|
937
|
+
|
|
938
|
+
// Build a map of all assets in this bundle with their dependencies
|
|
939
|
+
// This allows us to check all assets in a single traversal
|
|
940
|
+
let assetDependenciesMap = new Map();
|
|
941
|
+
this.traverseAssets(bundle, asset => {
|
|
942
|
+
// Always do fast checks (no caching)
|
|
943
|
+
let fastCheckResult = this.isAssetReferencedFastCheck(bundle, asset);
|
|
944
|
+
if (fastCheckResult === true) {
|
|
945
|
+
referencedAssets.add(asset);
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// Fast checks failed (fastCheckResult === null), need expensive computation
|
|
950
|
+
// Check if it's actually referenced via traversal
|
|
951
|
+
|
|
952
|
+
// Store dependencies for later batch checking
|
|
953
|
+
let dependencies = this._graph.getNodeIdsConnectedTo((0, _nullthrows().default)(this._graph.getNodeIdByContentKey(asset.id))).map(id => (0, _nullthrows().default)(this._graph.getNode(id))).filter(node => node.type === 'dependency').map(node => {
|
|
954
|
+
(0, _assert().default)(node.type === 'dependency');
|
|
955
|
+
return node.value;
|
|
956
|
+
});
|
|
957
|
+
if (dependencies.length > 0) {
|
|
958
|
+
assetDependenciesMap.set(asset, dependencies);
|
|
959
|
+
}
|
|
960
|
+
});
|
|
961
|
+
|
|
962
|
+
// If no assets need the expensive check, return early
|
|
963
|
+
if (assetDependenciesMap.size === 0) {
|
|
964
|
+
return referencedAssets;
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
// Get the assets we need to check once
|
|
968
|
+
let assetsToCheck = Array.from(assetDependenciesMap.keys());
|
|
969
|
+
|
|
970
|
+
// Helper function to check if all assets from assetDependenciesMap are in referencedAssets
|
|
971
|
+
const allAssetsReferenced = () => assetsToCheck.length <= referencedAssets.size && assetsToCheck.every(asset => referencedAssets.has(asset));
|
|
972
|
+
|
|
973
|
+
// Do ONE traversal to check all remaining assets
|
|
974
|
+
// We can share visitedBundles across all assets because we check every asset
|
|
975
|
+
// against every visited bundle, which matches the original per-asset behavior
|
|
976
|
+
let siblingBundles = new Set(this.getBundleGroupsContainingBundle(bundle).flatMap(bundleGroup => this.getBundlesInBundleGroup(bundleGroup, {
|
|
977
|
+
includeInline: true
|
|
978
|
+
})));
|
|
979
|
+
let visitedBundles = new Set();
|
|
980
|
+
|
|
981
|
+
// Single traversal from all referencers
|
|
982
|
+
for (let referencer of siblingBundles) {
|
|
983
|
+
this.traverseBundles((descendant, _, actions) => {
|
|
984
|
+
if (descendant.id === bundle.id) {
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
if (visitedBundles.has(descendant)) {
|
|
988
|
+
actions.skipChildren();
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
visitedBundles.add(descendant);
|
|
992
|
+
if (descendant.type !== bundle.type || (0, _EnvironmentManager.fromEnvironmentId)(descendant.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) {
|
|
993
|
+
// Don't skip children - they might be the right type!
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
// Check ALL assets at once in this descendant bundle
|
|
998
|
+
for (let [asset, dependencies] of assetDependenciesMap) {
|
|
999
|
+
// Skip if already marked as referenced
|
|
1000
|
+
if (referencedAssets.has(asset)) {
|
|
1001
|
+
continue;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
// Check if this descendant bundle references the asset
|
|
1005
|
+
if (!this.bundleHasAsset(descendant, asset) && dependencies.some(dependency => this.bundleHasDependency(descendant, dependency))) {
|
|
1006
|
+
referencedAssets.add(asset);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
// If all assets from assetDependenciesMap are now marked as referenced, we can stop early
|
|
1011
|
+
if (allAssetsReferenced()) {
|
|
1012
|
+
actions.stop();
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
}, referencer);
|
|
1016
|
+
|
|
1017
|
+
// If all assets from assetDependenciesMap are referenced, no need to check more sibling bundles
|
|
1018
|
+
if (allAssetsReferenced()) {
|
|
1019
|
+
break;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
return referencedAssets;
|
|
1023
|
+
}
|
|
917
1024
|
hasParentBundleOfType(bundle, type) {
|
|
918
1025
|
let parents = this.getParentBundles(bundle);
|
|
919
1026
|
return parents.length > 0 && parents.every(parent => parent.type === type);
|
package/lib/CommittedAsset.js
CHANGED
|
@@ -26,7 +26,7 @@ function _utils() {
|
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
28
|
function _sourceMap() {
|
|
29
|
-
const data = _interopRequireDefault(require("@
|
|
29
|
+
const data = _interopRequireDefault(require("@atlaspack/source-map"));
|
|
30
30
|
_sourceMap = function () {
|
|
31
31
|
return data;
|
|
32
32
|
};
|