@atlaspack/core 2.26.3-dev-compiled-hash-e5f8a1735.0 → 2.28.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 +61 -0
- package/dist/Atlaspack.js +5 -1
- 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/worker/compat/bitflags.js +24 -20
- package/dist/atlaspack-v3/worker/compat/dependency.js +1 -1
- package/dist/atlaspack-v3/worker/compat/mutable-asset.js +1 -1
- package/dist/atlaspack-v3/worker/worker.js +14 -7
- package/dist/public/BundleGraph.js +12 -0
- package/dist/requests/AssetGraphRequest.js +1 -1
- package/dist/requests/AssetGraphRequestRust.js +99 -36
- package/dist/requests/AtlaspackConfigRequest.js +10 -21
- 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/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/worker/compat/bitflags.js +25 -20
- package/lib/atlaspack-v3/worker/compat/dependency.js +1 -1
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +1 -1
- package/lib/atlaspack-v3/worker/worker.js +13 -5
- package/lib/public/BundleGraph.js +13 -0
- package/lib/requests/AssetGraphRequest.js +1 -1
- package/lib/requests/AssetGraphRequestRust.js +96 -35
- package/lib/requests/AtlaspackConfigRequest.js +14 -24
- package/lib/requests/BundleGraphRequest.js +4 -2
- package/lib/resolveOptions.js +1 -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/bitflags.d.ts +11 -12
- 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/requests/AssetGraphRequestRust.d.ts +1 -1
- package/lib/types/types.d.ts +1 -0
- package/lib/worker.js +1 -1
- package/package.json +21 -22
- package/src/Atlaspack.ts +6 -2
- 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/worker/compat/bitflags.ts +44 -41
- package/src/atlaspack-v3/worker/compat/dependency.ts +1 -1
- package/src/atlaspack-v3/worker/compat/mutable-asset.ts +1 -1
- package/src/atlaspack-v3/worker/worker.ts +15 -5
- package/src/public/Asset.ts +1 -1
- package/src/public/BundleGraph.ts +21 -0
- package/src/requests/AssetGraphRequest.ts +1 -1
- package/src/requests/AssetGraphRequestRust.ts +138 -40
- package/src/requests/AtlaspackConfigRequest.ts +10 -20
- 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/requests/AssetGraphRequestRust.test.ts +1 -0
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/LICENSE +0 -201
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# @atlaspack/core
|
|
2
2
|
|
|
3
|
+
## 2.28.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#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.
|
|
8
|
+
|
|
9
|
+
- [#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
|
|
10
|
+
|
|
11
|
+
- [#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.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#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
|
|
16
|
+
|
|
17
|
+
- 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)]:
|
|
18
|
+
- @atlaspack/rust@3.11.0
|
|
19
|
+
- @atlaspack/feature-flags@2.27.0
|
|
20
|
+
- @atlaspack/source-map@3.1.0
|
|
21
|
+
- @atlaspack/utils@3.2.0
|
|
22
|
+
- @atlaspack/profiler@2.15.0
|
|
23
|
+
- @atlaspack/cache@3.2.34
|
|
24
|
+
- @atlaspack/fs@2.15.34
|
|
25
|
+
- @atlaspack/logger@2.14.31
|
|
26
|
+
- @atlaspack/graph@3.6.1
|
|
27
|
+
- @atlaspack/plugin@2.14.39
|
|
28
|
+
- @atlaspack/types@2.15.29
|
|
29
|
+
- @atlaspack/workers@2.14.39
|
|
30
|
+
- @atlaspack/package-manager@2.14.39
|
|
31
|
+
|
|
32
|
+
## 2.27.0
|
|
33
|
+
|
|
34
|
+
### Minor Changes
|
|
35
|
+
|
|
36
|
+
- [#869](https://github.com/atlassian-labs/atlaspack/pull/869) [`cfb4707`](https://github.com/atlassian-labs/atlaspack/commit/cfb4707087498e4fa4dcf10753fe984a248d196b) Thanks [@benjervis](https://github.com/benjervis)! - Adds a feature to the V3 devloop that will minimise the amount of work done if the change is only a content change.
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- [#873](https://github.com/atlassian-labs/atlaspack/pull/873) [`ec3abe4`](https://github.com/atlassian-labs/atlaspack/commit/ec3abe4dffc98560a850fd2f71fb566577e6c99c) Thanks [@vykimnguyen](https://github.com/vykimnguyen)! - cleanup deduplicateReporters flag
|
|
41
|
+
|
|
42
|
+
- [#870](https://github.com/atlassian-labs/atlaspack/pull/870) [`33d4c26`](https://github.com/atlassian-labs/atlaspack/commit/33d4c261ceb8d585d56b0a446ed6e28cf7f1126d) Thanks [@matt-koko](https://github.com/matt-koko)! - Support Loading TypeScript Plugin Files in v3
|
|
43
|
+
|
|
44
|
+
- [#856](https://github.com/atlassian-labs/atlaspack/pull/856) [`f31b041`](https://github.com/atlassian-labs/atlaspack/commit/f31b04107e9077c9946aadb99f6f91bb69703bb7) Thanks [@matt-koko](https://github.com/matt-koko)! - Handle Directory Entry Points in v3
|
|
45
|
+
|
|
46
|
+
- [#859](https://github.com/atlassian-labs/atlaspack/pull/859) [`8180981`](https://github.com/atlassian-labs/atlaspack/commit/8180981be14c00f9570adb70d3f350bd91d6ec0a) Thanks [@benjervis](https://github.com/benjervis)! - Re-use asset graphs when building in Native, if we have one left over from a previous incremental build
|
|
47
|
+
|
|
48
|
+
- [#883](https://github.com/atlassian-labs/atlaspack/pull/883) [`119210b`](https://github.com/atlassian-labs/atlaspack/commit/119210b597eb993c50445df87a36b70bd49cd414) Thanks [@matt-koko](https://github.com/matt-koko)! - Fix bitflags rust/js interop
|
|
49
|
+
|
|
50
|
+
- Updated dependencies [[`ec3abe4`](https://github.com/atlassian-labs/atlaspack/commit/ec3abe4dffc98560a850fd2f71fb566577e6c99c), [`c7fe3f7`](https://github.com/atlassian-labs/atlaspack/commit/c7fe3f76f247e9e20299e205e2df0a16c418eaf2), [`cfb4707`](https://github.com/atlassian-labs/atlaspack/commit/cfb4707087498e4fa4dcf10753fe984a248d196b), [`1468695`](https://github.com/atlassian-labs/atlaspack/commit/1468695fc0c9d06f060a6da9e9b0e154f11dff34), [`f31b041`](https://github.com/atlassian-labs/atlaspack/commit/f31b04107e9077c9946aadb99f6f91bb69703bb7), [`8180981`](https://github.com/atlassian-labs/atlaspack/commit/8180981be14c00f9570adb70d3f350bd91d6ec0a), [`ae77e74`](https://github.com/atlassian-labs/atlaspack/commit/ae77e7452a466b43b3fa5bed24d4ba26345ed765), [`f0a496f`](https://github.com/atlassian-labs/atlaspack/commit/f0a496f70fc8652e090cf1b3f6260e8cfbb796e2), [`7d7a55d`](https://github.com/atlassian-labs/atlaspack/commit/7d7a55dd6395ec391a2e4c33b3dec0d1ea477d4c), [`540f253`](https://github.com/atlassian-labs/atlaspack/commit/540f253dfdcd1a5caebbdc0b197319d439404aae)]:
|
|
51
|
+
- @atlaspack/feature-flags@2.26.2
|
|
52
|
+
- @atlaspack/rust@3.10.0
|
|
53
|
+
- @atlaspack/graph@3.6.0
|
|
54
|
+
- @atlaspack/utils@3.1.2
|
|
55
|
+
- @atlaspack/cache@3.2.33
|
|
56
|
+
- @atlaspack/fs@2.15.33
|
|
57
|
+
- @atlaspack/logger@2.14.30
|
|
58
|
+
- @atlaspack/package-manager@2.14.38
|
|
59
|
+
- @atlaspack/workers@2.14.38
|
|
60
|
+
- @atlaspack/plugin@2.14.38
|
|
61
|
+
- @atlaspack/profiler@2.14.35
|
|
62
|
+
- @atlaspack/types@2.15.28
|
|
63
|
+
|
|
3
64
|
## 2.26.2
|
|
4
65
|
|
|
5
66
|
### Patch 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.
|
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)),
|
|
@@ -19,7 +19,6 @@ class BitFlags {
|
|
|
19
19
|
constructor(source) {
|
|
20
20
|
// @ts-expect-error TS2344
|
|
21
21
|
_BitFlags_kv.set(this, void 0);
|
|
22
|
-
// @ts-expect-error TS2344
|
|
23
22
|
_BitFlags_vk.set(this, void 0);
|
|
24
23
|
__classPrivateFieldSet(this, _BitFlags_kv, source, "f");
|
|
25
24
|
__classPrivateFieldSet(this, _BitFlags_vk, Object.fromEntries(Object.entries(source).map((a) => a.reverse())), "f");
|
|
@@ -37,9 +36,6 @@ class BitFlags {
|
|
|
37
36
|
}
|
|
38
37
|
return this.into(key);
|
|
39
38
|
}
|
|
40
|
-
intoArray(keys) {
|
|
41
|
-
return keys.map((key) => this.into(key));
|
|
42
|
-
}
|
|
43
39
|
from(key) {
|
|
44
40
|
const found = __classPrivateFieldGet(this, _BitFlags_vk, "f")[key];
|
|
45
41
|
if (found === undefined) {
|
|
@@ -53,8 +49,14 @@ class BitFlags {
|
|
|
53
49
|
}
|
|
54
50
|
return this.from(key);
|
|
55
51
|
}
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
toArray(keys) {
|
|
53
|
+
let values = [];
|
|
54
|
+
for (let [key, value] of Object.entries(__classPrivateFieldGet(this, _BitFlags_kv, "f"))) {
|
|
55
|
+
if ((keys & value) !== 0) {
|
|
56
|
+
values.push(key);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return values;
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
exports.BitFlags = BitFlags;
|
|
@@ -70,21 +72,23 @@ exports.dependencyPriorityMap = new BitFlags({
|
|
|
70
72
|
lazy: 2,
|
|
71
73
|
conditional: 3,
|
|
72
74
|
});
|
|
75
|
+
// Note: The bitflags must match the bitflags in the Rust code.
|
|
76
|
+
// crates/atlaspack_core/src/types/package_json.rs
|
|
73
77
|
exports.packageConditionsMap = new BitFlags({
|
|
74
|
-
import: 0,
|
|
75
|
-
require: 1,
|
|
76
|
-
module: 2,
|
|
77
|
-
node: 3,
|
|
78
|
-
browser: 4,
|
|
79
|
-
worker: 5,
|
|
80
|
-
worklet: 6,
|
|
81
|
-
electron: 7,
|
|
82
|
-
development: 8,
|
|
83
|
-
production: 9,
|
|
84
|
-
types: 10,
|
|
85
|
-
default: 11,
|
|
86
|
-
style: 12,
|
|
87
|
-
sass: 13,
|
|
78
|
+
import: 1 << 0,
|
|
79
|
+
require: 1 << 1,
|
|
80
|
+
module: 1 << 2,
|
|
81
|
+
node: 1 << 3,
|
|
82
|
+
browser: 1 << 4,
|
|
83
|
+
worker: 1 << 5,
|
|
84
|
+
worklet: 1 << 6,
|
|
85
|
+
electron: 1 << 7,
|
|
86
|
+
development: 1 << 8,
|
|
87
|
+
production: 1 << 9,
|
|
88
|
+
types: 1 << 10,
|
|
89
|
+
default: 1 << 11,
|
|
90
|
+
style: 1 << 12,
|
|
91
|
+
sass: 1 << 13,
|
|
88
92
|
});
|
|
89
93
|
exports.specifierTypeMap = new BitFlags({
|
|
90
94
|
esm: 0,
|
|
@@ -31,7 +31,7 @@ class Dependency {
|
|
|
31
31
|
this.isOptional = inner.isOptional;
|
|
32
32
|
this.isEntry = inner.isEntry;
|
|
33
33
|
this.loc = inner.loc;
|
|
34
|
-
this.packageConditions = bitflags_1.packageConditionsMap.
|
|
34
|
+
this.packageConditions = bitflags_1.packageConditionsMap.toArray(inner.packageConditions || []);
|
|
35
35
|
this.sourceAssetId = inner.sourceAssetId;
|
|
36
36
|
this.sourcePath = inner.sourcePath;
|
|
37
37
|
this.sourceAssetType = inner.sourceAssetType;
|
|
@@ -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");
|
|
@@ -46,7 +46,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
46
46
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
47
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
48
|
};
|
|
49
|
-
var _AtlaspackWorker_resolvers, _AtlaspackWorker_transformers, _AtlaspackWorker_fs;
|
|
49
|
+
var _AtlaspackWorker_resolvers, _AtlaspackWorker_transformers, _AtlaspackWorker_fs, _AtlaspackWorker_packageManager;
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
51
|
exports.AtlaspackWorker = void 0;
|
|
52
52
|
const assert_1 = __importDefault(require("assert"));
|
|
@@ -63,17 +63,23 @@ class AtlaspackWorker {
|
|
|
63
63
|
_AtlaspackWorker_resolvers.set(this, void 0);
|
|
64
64
|
_AtlaspackWorker_transformers.set(this, void 0);
|
|
65
65
|
_AtlaspackWorker_fs.set(this, void 0);
|
|
66
|
+
_AtlaspackWorker_packageManager.set(this, void 0);
|
|
66
67
|
this.loadPlugin = (0, jsCallable_1.jsCallable)(async ({ kind, specifier, resolveFrom, featureFlags }) => {
|
|
67
|
-
|
|
68
|
-
let
|
|
69
|
-
let resolvedModule = await import(resolvedPath);
|
|
68
|
+
// Use packageManager.require() instead of dynamic import() to support TypeScript plugins
|
|
69
|
+
let resolvedModule = await __classPrivateFieldGet(this, _AtlaspackWorker_packageManager, "f").require(specifier, resolveFrom, { shouldAutoInstall: false });
|
|
70
70
|
let instance = undefined;
|
|
71
|
-
|
|
71
|
+
// Check for CommonJS export (module.exports = new Plugin(...))
|
|
72
|
+
if (resolvedModule[CONFIG]) {
|
|
73
|
+
instance = resolvedModule[CONFIG];
|
|
74
|
+
}
|
|
75
|
+
else if (resolvedModule.default && resolvedModule.default[CONFIG]) {
|
|
76
|
+
// ESM default export
|
|
72
77
|
instance = resolvedModule.default[CONFIG];
|
|
73
78
|
}
|
|
74
79
|
else if (resolvedModule.default &&
|
|
75
80
|
resolvedModule.default.default &&
|
|
76
81
|
resolvedModule.default.default[CONFIG]) {
|
|
82
|
+
// Double-wrapped default export
|
|
77
83
|
instance = resolvedModule.default.default[CONFIG];
|
|
78
84
|
}
|
|
79
85
|
else {
|
|
@@ -156,7 +162,7 @@ class AtlaspackWorker {
|
|
|
156
162
|
type: 'resolved',
|
|
157
163
|
filePath: result.filePath || '',
|
|
158
164
|
canDefer: result.canDefer || false,
|
|
159
|
-
sideEffects: result.sideEffects
|
|
165
|
+
sideEffects: result.sideEffects ?? true,
|
|
160
166
|
code: result.code || undefined,
|
|
161
167
|
meta: result.meta || undefined,
|
|
162
168
|
pipeline: result.pipeline || undefined,
|
|
@@ -287,10 +293,11 @@ class AtlaspackWorker {
|
|
|
287
293
|
__classPrivateFieldSet(this, _AtlaspackWorker_resolvers, new Map(), "f");
|
|
288
294
|
__classPrivateFieldSet(this, _AtlaspackWorker_transformers, new Map(), "f");
|
|
289
295
|
__classPrivateFieldSet(this, _AtlaspackWorker_fs, new fs_1.NodeFS(), "f");
|
|
296
|
+
__classPrivateFieldSet(this, _AtlaspackWorker_packageManager, new package_manager_1.NodePackageManager(__classPrivateFieldGet(this, _AtlaspackWorker_fs, "f"), '/'), "f");
|
|
290
297
|
}
|
|
291
298
|
}
|
|
292
299
|
exports.AtlaspackWorker = AtlaspackWorker;
|
|
293
|
-
_AtlaspackWorker_resolvers = new WeakMap(), _AtlaspackWorker_transformers = new WeakMap(), _AtlaspackWorker_fs = new WeakMap();
|
|
300
|
+
_AtlaspackWorker_resolvers = new WeakMap(), _AtlaspackWorker_transformers = new WeakMap(), _AtlaspackWorker_fs = new WeakMap(), _AtlaspackWorker_packageManager = new WeakMap();
|
|
294
301
|
// Create napi worker and send it back to main thread
|
|
295
302
|
const worker = new AtlaspackWorker();
|
|
296
303
|
const napiWorker = napi.newNodejsWorker(worker);
|
|
@@ -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
|
}
|
|
@@ -30,7 +30,7 @@ function createAssetGraphRequest(requestInput) {
|
|
|
30
30
|
run: async (input) => {
|
|
31
31
|
let prevResult = await input.api.getPreviousResult();
|
|
32
32
|
let builder = new AssetGraphBuilder(input, prevResult);
|
|
33
|
-
let assetGraphRequest = await
|
|
33
|
+
let assetGraphRequest = await builder.build();
|
|
34
34
|
// early break for incremental bundling if production or flag is off;
|
|
35
35
|
assetGraphRequest.assetGraph.setDisableIncrementalBundling(!input.options.shouldBundleIncrementally ||
|
|
36
36
|
input.options.mode === 'production');
|