@atlaspack/core 2.16.2-dev.55 → 2.16.2-dev.72
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 +49 -0
- package/_empty.js +0 -0
- package/lib/AssetGraph.js +17 -6
- package/lib/Atlaspack.js +2 -5
- package/lib/AtlaspackConfig.schema.js +1 -7
- package/lib/BundleGraph.js +10 -8
- package/lib/Dependency.js +6 -2
- package/lib/Environment.js +4 -3
- package/lib/EnvironmentManager.js +137 -0
- package/lib/InternalConfig.js +3 -2
- package/lib/PackagerRunner.js +15 -9
- package/lib/RequestTracker.js +56 -46
- package/lib/Transformation.js +2 -2
- package/lib/UncommittedAsset.js +3 -2
- package/lib/applyRuntimes.js +2 -1
- package/lib/assetUtils.js +2 -1
- package/lib/atlaspack-v3/AtlaspackV3.js +44 -1
- package/lib/atlaspack-v3/NapiWorkerPool.js +1 -1
- package/lib/atlaspack-v3/worker/compat/environment.js +2 -2
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +6 -6
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +5 -5
- package/lib/atlaspack-v3/worker/napi-worker.js +3 -0
- package/lib/atlaspack-v3/worker/worker.js +11 -4
- package/lib/dumpGraphToGraphViz.js +1 -1
- package/lib/index.js +9 -1
- package/lib/internal-plugins.js +9 -0
- package/lib/isSuperPackage.js +23 -0
- package/lib/loadAtlaspackPlugin.js +15 -0
- package/lib/public/Asset.js +3 -2
- package/lib/public/Bundle.js +2 -1
- package/lib/public/Config.js +86 -19
- package/lib/public/Dependency.js +2 -1
- package/lib/public/MutableBundleGraph.js +2 -1
- package/lib/public/PluginOptions.js +3 -0
- package/lib/public/Target.js +2 -1
- package/lib/requests/AssetRequest.js +2 -1
- package/lib/requests/AtlaspackConfigRequest.js +44 -29
- package/lib/requests/ConfigRequest.js +27 -4
- package/lib/requests/TargetRequest.js +18 -16
- package/lib/requests/WriteBundleRequest.js +5 -2
- package/lib/requests/WriteBundlesRequest.js +1 -0
- package/lib/resolveOptions.js +5 -4
- package/lib/worker.js +9 -26
- package/package.json +21 -18
- package/src/AssetGraph.js +12 -6
- package/src/Atlaspack.js +8 -7
- package/src/BundleGraph.js +21 -9
- package/src/Dependency.js +13 -5
- package/src/Environment.js +8 -5
- package/src/EnvironmentManager.js +145 -0
- package/src/InternalConfig.js +6 -5
- package/src/PackagerRunner.js +17 -11
- package/src/RequestTracker.js +39 -13
- package/src/UncommittedAsset.js +7 -2
- package/src/applyRuntimes.js +6 -1
- package/src/assetUtils.js +4 -3
- package/src/atlaspack-v3/AtlaspackV3.js +53 -2
- package/src/atlaspack-v3/NapiWorkerPool.js +5 -1
- package/src/atlaspack-v3/worker/compat/plugin-config.js +1 -1
- package/src/atlaspack-v3/worker/worker.js +11 -4
- package/src/index.js +2 -0
- package/src/internal-plugins.js +4 -0
- package/src/isSuperPackage.js +28 -0
- package/src/loadAtlaspackPlugin.js +23 -1
- package/src/public/Asset.js +9 -2
- package/src/public/Bundle.js +2 -1
- package/src/public/Config.js +110 -29
- package/src/public/Dependency.js +2 -1
- package/src/public/MutableBundleGraph.js +2 -1
- package/src/public/PluginOptions.js +4 -0
- package/src/public/Target.js +2 -1
- package/src/requests/AssetRequest.js +2 -1
- package/src/requests/AtlaspackConfigRequest.js +77 -31
- package/src/requests/ConfigRequest.js +33 -9
- package/src/requests/TargetRequest.js +19 -25
- package/src/requests/WriteBundleRequest.js +6 -7
- package/src/requests/WriteBundlesRequest.js +1 -0
- package/src/resolveOptions.js +2 -0
- package/src/types.js +10 -7
- package/src/worker.js +8 -7
- package/test/Environment.test.js +43 -34
- package/test/EnvironmentManager.test.js +192 -0
- package/test/PublicEnvironment.test.js +10 -7
- package/test/RequestTracker.test.js +1 -4
- package/test/public/Config.test.js +108 -0
- package/test/requests/ConfigRequest.test.js +187 -3
- package/test/test-utils.js +3 -2
- package/lib/atlaspack-v3/worker/index.js +0 -6
- /package/src/atlaspack-v3/worker/{index.js → napi-worker.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# @atlaspack/core
|
|
2
2
|
|
|
3
|
+
## 2.18.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`73ea3c4`](https://github.com/atlassian-labs/atlaspack/commit/73ea3c4d85d4401fdd15abcbf988237e890e7ad3), [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef)]:
|
|
8
|
+
- @atlaspack/feature-flags@2.17.0
|
|
9
|
+
- @atlaspack/cache@3.2.6
|
|
10
|
+
- @atlaspack/fs@2.15.6
|
|
11
|
+
- @atlaspack/graph@3.5.1
|
|
12
|
+
- @atlaspack/utils@2.14.11
|
|
13
|
+
- @atlaspack/package-manager@2.14.11
|
|
14
|
+
- @atlaspack/profiler@2.14.9
|
|
15
|
+
- @atlaspack/types@2.15.1
|
|
16
|
+
- @atlaspack/workers@2.14.11
|
|
17
|
+
- @atlaspack/plugin@2.14.11
|
|
18
|
+
|
|
19
|
+
## 2.18.1
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`1b52b99`](https://github.com/atlassian-labs/atlaspack/commit/1b52b99db4298b04c1a6eb0f97994d75a2d436f9)]:
|
|
24
|
+
- @atlaspack/graph@3.5.0
|
|
25
|
+
|
|
26
|
+
## 2.18.0
|
|
27
|
+
|
|
28
|
+
### Minor Changes
|
|
29
|
+
|
|
30
|
+
- [#601](https://github.com/atlassian-labs/atlaspack/pull/601) [`1e32d4e`](https://github.com/atlassian-labs/atlaspack/commit/1e32d4eae6b3af3968e8a0ef97d35b4347fd4196) Thanks [@yamadapc](https://github.com/yamadapc)! - Improve granular configuration file invalidations
|
|
31
|
+
|
|
32
|
+
- [#599](https://github.com/atlassian-labs/atlaspack/pull/599) [`0b2f6f5`](https://github.com/atlassian-labs/atlaspack/commit/0b2f6f55794d3ff6e2f5a41f963e7e5dd8ad9f8d) Thanks [@pancaspe87](https://github.com/pancaspe87)! - load and write env to cache - change is feature flagged
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- [#595](https://github.com/atlassian-labs/atlaspack/pull/595) [`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b) Thanks [@yamadapc](https://github.com/yamadapc)! - Add bundleId to write bundle request results
|
|
37
|
+
|
|
38
|
+
- [#572](https://github.com/atlassian-labs/atlaspack/pull/572) [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca) Thanks [@yamadapc](https://github.com/yamadapc)! - Add feature-flagged change which removes all environment duplication around objects
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [[`0999fb7`](https://github.com/atlassian-labs/atlaspack/commit/0999fb78da519a6c7582d212883e515fcf6c1252), [`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b), [`1e32d4e`](https://github.com/atlassian-labs/atlaspack/commit/1e32d4eae6b3af3968e8a0ef97d35b4347fd4196), [`35fdd4b`](https://github.com/atlassian-labs/atlaspack/commit/35fdd4b52da0af20f74667f7b8adfb2f90279b7c), [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca)]:
|
|
41
|
+
- @atlaspack/fs@2.15.5
|
|
42
|
+
- @atlaspack/types@2.15.0
|
|
43
|
+
- @atlaspack/rust@3.3.5
|
|
44
|
+
- @atlaspack/cache@3.2.5
|
|
45
|
+
- @atlaspack/package-manager@2.14.10
|
|
46
|
+
- @atlaspack/profiler@2.14.8
|
|
47
|
+
- @atlaspack/workers@2.14.10
|
|
48
|
+
- @atlaspack/plugin@2.14.10
|
|
49
|
+
- @atlaspack/logger@2.14.10
|
|
50
|
+
- @atlaspack/utils@2.14.10
|
|
51
|
+
|
|
3
52
|
## 2.17.4
|
|
4
53
|
|
|
5
54
|
### Patch Changes
|
package/_empty.js
ADDED
|
File without changes
|
package/lib/AssetGraph.js
CHANGED
|
@@ -46,6 +46,14 @@ function _graph() {
|
|
|
46
46
|
}
|
|
47
47
|
var _Dependency = require("./Dependency");
|
|
48
48
|
var _projectPath = require("./projectPath");
|
|
49
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
50
|
+
function _featureFlags() {
|
|
51
|
+
const data = require("@atlaspack/feature-flags");
|
|
52
|
+
_featureFlags = function () {
|
|
53
|
+
return data;
|
|
54
|
+
};
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
49
57
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
50
58
|
function nodeFromDep(dep) {
|
|
51
59
|
return {
|
|
@@ -63,7 +71,7 @@ function nodeFromDep(dep) {
|
|
|
63
71
|
}
|
|
64
72
|
function nodeFromAssetGroup(assetGroup) {
|
|
65
73
|
return {
|
|
66
|
-
id: (0, _rust().hashString)((0, _projectPath.fromProjectPathRelative)(assetGroup.filePath) + assetGroup.env
|
|
74
|
+
id: (0, _rust().hashString)((0, _projectPath.fromProjectPathRelative)(assetGroup.filePath) + (0, _EnvironmentManager.toEnvironmentId)(assetGroup.env) + String(assetGroup.isSource) + String(assetGroup.sideEffects) + (assetGroup.code ?? '') + ':' + (assetGroup.pipeline ?? '') + ':' + (assetGroup.query ?? '')),
|
|
67
75
|
type: 'asset_group',
|
|
68
76
|
value: assetGroup,
|
|
69
77
|
usedSymbolsDownDirty: true
|
|
@@ -130,16 +138,19 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
130
138
|
|
|
131
139
|
// Deduplicates Environments by making them referentially equal
|
|
132
140
|
normalizeEnvironment(input) {
|
|
141
|
+
if ((0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
133
144
|
let {
|
|
134
145
|
id,
|
|
135
146
|
context
|
|
136
|
-
} = input.env;
|
|
147
|
+
} = (0, _EnvironmentManager.fromEnvironmentId)(input.env);
|
|
137
148
|
let idAndContext = `${id}-${context}`;
|
|
138
149
|
let env = this.envCache.get(idAndContext);
|
|
139
150
|
if (env) {
|
|
140
151
|
input.env = env;
|
|
141
152
|
} else {
|
|
142
|
-
this.envCache.set(idAndContext, input.env);
|
|
153
|
+
this.envCache.set(idAndContext, (0, _EnvironmentManager.fromEnvironmentId)(input.env));
|
|
143
154
|
}
|
|
144
155
|
}
|
|
145
156
|
setRootConnections({
|
|
@@ -199,13 +210,13 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
199
210
|
env: target.env,
|
|
200
211
|
isEntry: true,
|
|
201
212
|
needsStableName: true,
|
|
202
|
-
symbols: target.env.isLibrary ? new Map([['*', {
|
|
213
|
+
symbols: (0, _EnvironmentManager.fromEnvironmentId)(target.env).isLibrary ? new Map([['*', {
|
|
203
214
|
local: '*',
|
|
204
215
|
isWeak: true,
|
|
205
216
|
loc: null
|
|
206
217
|
}]]) : undefined
|
|
207
218
|
}));
|
|
208
|
-
if (node.value.env.isLibrary) {
|
|
219
|
+
if ((0, _EnvironmentManager.fromEnvironmentId)(node.value.env).isLibrary) {
|
|
209
220
|
// in library mode, all of the entry's symbols are "used"
|
|
210
221
|
node.usedSymbolsDown.add('*');
|
|
211
222
|
node.usedSymbolsUp.set('*', undefined);
|
|
@@ -348,7 +359,7 @@ class AssetGraph extends _graph().ContentGraph {
|
|
|
348
359
|
if (this.undeferredDependencies.has(d)) {
|
|
349
360
|
return false;
|
|
350
361
|
}
|
|
351
|
-
let depIsDeferrable = d.symbols && !(d.env.isLibrary && d.isEntry) && !d.symbols.has('*') && ![...d.symbols.keys()].some(symbol => {
|
|
362
|
+
let depIsDeferrable = d.symbols && !((0, _EnvironmentManager.fromEnvironmentId)(d.env).isLibrary && d.isEntry) && !d.symbols.has('*') && ![...d.symbols.keys()].some(symbol => {
|
|
352
363
|
var _resolvedAsset$symbol;
|
|
353
364
|
let assetSymbol = (_resolvedAsset$symbol = resolvedAsset.symbols) === null || _resolvedAsset$symbol === void 0 || (_resolvedAsset$symbol = _resolvedAsset$symbol.get(symbol)) === null || _resolvedAsset$symbol === void 0 ? void 0 : _resolvedAsset$symbol.local;
|
|
354
365
|
return assetSymbol != null && symbols.has(assetSymbol);
|
package/lib/Atlaspack.js
CHANGED
|
@@ -126,7 +126,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
126
126
|
(0, _registerCoreWithSerializer.registerCoreWithSerializer)();
|
|
127
127
|
const INTERNAL_TRANSFORM = exports.INTERNAL_TRANSFORM = Symbol('internal_transform');
|
|
128
128
|
const INTERNAL_RESOLVE = exports.INTERNAL_RESOLVE = Symbol('internal_resolve');
|
|
129
|
-
const WORKER_PATH = exports.WORKER_PATH = _path().default.join(__dirname, 'worker.js');
|
|
129
|
+
const WORKER_PATH = exports.WORKER_PATH = _path().default.join( /*#__ATLASPACK_IGNORE__*/__dirname, 'worker.js');
|
|
130
130
|
class Atlaspack {
|
|
131
131
|
#requestTracker /*: RequestTracker*/;
|
|
132
132
|
#config /*: AtlaspackConfig*/;
|
|
@@ -215,7 +215,6 @@ class Atlaspack {
|
|
|
215
215
|
}
|
|
216
216
|
rustAtlaspack = await _atlaspackV.AtlaspackV3.create({
|
|
217
217
|
...options,
|
|
218
|
-
corePath: _path().default.join(__dirname, '..'),
|
|
219
218
|
threads,
|
|
220
219
|
entries: Array.isArray(entries) ? entries : entries == null ? undefined : [entries],
|
|
221
220
|
env: resolvedOptions.env,
|
|
@@ -510,9 +509,7 @@ class Atlaspack {
|
|
|
510
509
|
if (this.rustAtlaspack) {
|
|
511
510
|
nativeInvalid = await this.rustAtlaspack.respondToFsEvents(events);
|
|
512
511
|
}
|
|
513
|
-
let
|
|
514
|
-
didInvalidate: isInvalid
|
|
515
|
-
} = await this.#requestTracker.respondToFSEvents(events, Number.POSITIVE_INFINITY);
|
|
512
|
+
let isInvalid = await this.#requestTracker.respondToFSEvents(events, Number.POSITIVE_INFINITY);
|
|
516
513
|
if ((nativeInvalid || isInvalid) && this.#watchQueue.getNumWaiting() === 0) {
|
|
517
514
|
if (this.#watchAbortController) {
|
|
518
515
|
this.#watchAbortController.abort();
|
|
@@ -14,13 +14,7 @@ exports.validatePackageName = validatePackageName;
|
|
|
14
14
|
// * We do not care about package names
|
|
15
15
|
// * Validation makes interop between parcel/atlaspack confusing.
|
|
16
16
|
//
|
|
17
|
-
function validatePackageName(
|
|
18
|
-
// eslint-disable-next-line no-unused-vars
|
|
19
|
-
pkg,
|
|
20
|
-
// eslint-disable-next-line no-unused-vars
|
|
21
|
-
pluginType,
|
|
22
|
-
// eslint-disable-next-line no-unused-vars
|
|
23
|
-
key) {}
|
|
17
|
+
function validatePackageName() {}
|
|
24
18
|
const validatePluginName = (pluginType, key) => {
|
|
25
19
|
return val => {
|
|
26
20
|
// allow plugin spread...
|
package/lib/BundleGraph.js
CHANGED
|
@@ -51,6 +51,7 @@ function _featureFlags() {
|
|
|
51
51
|
};
|
|
52
52
|
return data;
|
|
53
53
|
}
|
|
54
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
54
55
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
55
56
|
const bundleGraphEdgeTypes = exports.bundleGraphEdgeTypes = {
|
|
56
57
|
// A lack of an edge type indicates to follow the edge while traversing
|
|
@@ -207,7 +208,7 @@ class BundleGraph {
|
|
|
207
208
|
}
|
|
208
209
|
}
|
|
209
210
|
}
|
|
210
|
-
if (node.type === 'dependency' && node.value.symbols != null && node.value.env.shouldScopeHoist &&
|
|
211
|
+
if (node.type === 'dependency' && node.value.symbols != null && (0, _EnvironmentManager.fromEnvironmentId)(node.value.env).shouldScopeHoist &&
|
|
211
212
|
// Disable in dev mode because this feature is at odds with safeToIncrementallyBundle
|
|
212
213
|
isProduction) {
|
|
213
214
|
let nodeValueSymbols = node.value.symbols;
|
|
@@ -832,7 +833,10 @@ class BundleGraph {
|
|
|
832
833
|
// If this asset is referenced by any async dependency, it's referenced.
|
|
833
834
|
return true;
|
|
834
835
|
}
|
|
835
|
-
let dependencies = this._graph.getNodeIdsConnectedTo(assetNodeId
|
|
836
|
+
let dependencies = this._graph.getNodeIdsConnectedTo(assetNodeId,
|
|
837
|
+
// TODO: This seems like bug with library builds when assets are present
|
|
838
|
+
// in other files. Guarding the fix for now exclusively for super builds
|
|
839
|
+
process.env.ATLASPACK_SUPER_BUILD === 'true' ? _graph().ALL_EDGE_TYPES : undefined).map(id => (0, _nullthrows().default)(this._graph.getNode(id))).filter(node => node.type === 'dependency').map(node => {
|
|
836
840
|
(0, _assert().default)(node.type === 'dependency');
|
|
837
841
|
return node.value;
|
|
838
842
|
});
|
|
@@ -859,14 +863,13 @@ class BundleGraph {
|
|
|
859
863
|
return;
|
|
860
864
|
}
|
|
861
865
|
visitedBundles.add(descendant);
|
|
862
|
-
if (descendant.type !== bundle.type || descendant.env.context !== bundle.env.context) {
|
|
866
|
+
if (descendant.type !== bundle.type || (0, _EnvironmentManager.fromEnvironmentId)(descendant.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) {
|
|
863
867
|
actions.skipChildren();
|
|
864
868
|
return;
|
|
865
869
|
}
|
|
866
870
|
if (bundleHasReference(descendant)) {
|
|
867
871
|
isReferenced = true;
|
|
868
872
|
actions.stop();
|
|
869
|
-
return;
|
|
870
873
|
}
|
|
871
874
|
}, referencer);
|
|
872
875
|
return isReferenced;
|
|
@@ -888,7 +891,7 @@ class BundleGraph {
|
|
|
888
891
|
isAssetReachableFromBundle(asset, bundle) {
|
|
889
892
|
// If a bundle's environment is isolated, it can't access assets present
|
|
890
893
|
// in any ancestor bundles. Don't consider any assets reachable.
|
|
891
|
-
if (_Environment.ISOLATED_ENVS.has(bundle.env.context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline) {
|
|
894
|
+
if (_Environment.ISOLATED_ENVS.has((0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline) {
|
|
892
895
|
return false;
|
|
893
896
|
}
|
|
894
897
|
|
|
@@ -916,7 +919,7 @@ class BundleGraph {
|
|
|
916
919
|
let node = (0, _nullthrows().default)(this._graph.getNode(nodeId));
|
|
917
920
|
// If we've reached the root or a context change without
|
|
918
921
|
// finding this asset in the ancestry, it is not reachable.
|
|
919
|
-
if (node.type === 'root' || node.type === 'bundle' && (node.value.id === bundle.id || node.value.env.context !== bundle.env.context)) {
|
|
922
|
+
if (node.type === 'root' || node.type === 'bundle' && (node.value.id === bundle.id || (0, _EnvironmentManager.fromEnvironmentId)(node.value.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context)) {
|
|
920
923
|
isReachable = false;
|
|
921
924
|
actions.stop();
|
|
922
925
|
return;
|
|
@@ -925,7 +928,6 @@ class BundleGraph {
|
|
|
925
928
|
let childBundles = this.getBundlesInBundleGroup(node.value);
|
|
926
929
|
if (childBundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && this.bundleHasAsset(b, asset))) {
|
|
927
930
|
actions.skipChildren();
|
|
928
|
-
return;
|
|
929
931
|
}
|
|
930
932
|
}
|
|
931
933
|
}, [bundleGraphEdgeTypes.references, bundleGraphEdgeTypes.bundle]);
|
|
@@ -1412,7 +1414,7 @@ class BundleGraph {
|
|
|
1412
1414
|
for (let referencedBundle of this.getReferencedBundles(bundle)) {
|
|
1413
1415
|
hash.writeString(referencedBundle.id);
|
|
1414
1416
|
}
|
|
1415
|
-
hash.writeString(JSON.stringify((0, _utils().objectSortedEntriesDeep)(bundle.env)));
|
|
1417
|
+
hash.writeString(JSON.stringify((0, _utils().objectSortedEntriesDeep)((0, _EnvironmentManager.fromEnvironmentId)(bundle.env))));
|
|
1416
1418
|
return hash.finish();
|
|
1417
1419
|
}
|
|
1418
1420
|
getBundleGraphHash() {
|
package/lib/Dependency.js
CHANGED
|
@@ -24,6 +24,7 @@ function _assert() {
|
|
|
24
24
|
return data;
|
|
25
25
|
}
|
|
26
26
|
var _IdentifierRegistry = require("./IdentifierRegistry");
|
|
27
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
27
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
29
|
function createDependencyId({
|
|
29
30
|
sourceAssetId,
|
|
@@ -41,8 +42,11 @@ function createDependencyId({
|
|
|
41
42
|
const params = {
|
|
42
43
|
sourceAssetId,
|
|
43
44
|
specifier,
|
|
44
|
-
environmentId: env
|
|
45
|
-
target
|
|
45
|
+
environmentId: (0, _EnvironmentManager.toEnvironmentId)(env),
|
|
46
|
+
target: target != null ? {
|
|
47
|
+
...target,
|
|
48
|
+
env: (0, _EnvironmentManager.fromEnvironmentId)(target.env)
|
|
49
|
+
} : null,
|
|
46
50
|
pipeline,
|
|
47
51
|
specifierType: _types.SpecifierType[specifierType],
|
|
48
52
|
bundleBehavior,
|
package/lib/Environment.js
CHANGED
|
@@ -15,6 +15,7 @@ function _rust() {
|
|
|
15
15
|
var _utils = require("./utils");
|
|
16
16
|
var _Environment = _interopRequireWildcard(require("./public/Environment"));
|
|
17
17
|
var _IdentifierRegistry = require("./IdentifierRegistry");
|
|
18
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
18
19
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
20
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
21
|
const DEFAULT_ENGINES = {
|
|
@@ -108,15 +109,15 @@ function createEnvironment({
|
|
|
108
109
|
loc
|
|
109
110
|
};
|
|
110
111
|
res.id = getEnvironmentHash(res);
|
|
111
|
-
return Object.freeze(res);
|
|
112
|
+
return (0, _EnvironmentManager.toEnvironmentRef)(Object.freeze(res));
|
|
112
113
|
}
|
|
113
114
|
function mergeEnvironments(projectRoot, a, b) {
|
|
114
115
|
// If merging the same object, avoid copying.
|
|
115
116
|
if (a === b || !b) {
|
|
116
|
-
return a;
|
|
117
|
+
return (0, _EnvironmentManager.toEnvironmentRef)(a);
|
|
117
118
|
}
|
|
118
119
|
if (b instanceof _Environment.default) {
|
|
119
|
-
return (0, _Environment.environmentToInternalEnvironment)(b);
|
|
120
|
+
return (0, _EnvironmentManager.toEnvironmentRef)((0, _Environment.environmentToInternalEnvironment)(b));
|
|
120
121
|
}
|
|
121
122
|
|
|
122
123
|
// $FlowFixMe - ignore the `id` that is already on a
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fromEnvironmentId = fromEnvironmentId;
|
|
7
|
+
exports.loadEnvironmentsFromCache = loadEnvironmentsFromCache;
|
|
8
|
+
exports.toEnvironmentId = toEnvironmentId;
|
|
9
|
+
exports.toEnvironmentRef = toEnvironmentRef;
|
|
10
|
+
exports.writeEnvironmentsToCache = writeEnvironmentsToCache;
|
|
11
|
+
function _rust() {
|
|
12
|
+
const data = require("@atlaspack/rust");
|
|
13
|
+
_rust = function () {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
function _featureFlags() {
|
|
19
|
+
const data = require("@atlaspack/feature-flags");
|
|
20
|
+
_featureFlags = function () {
|
|
21
|
+
return data;
|
|
22
|
+
};
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
function _logger() {
|
|
26
|
+
const data = require("@atlaspack/logger");
|
|
27
|
+
_logger = function () {
|
|
28
|
+
return data;
|
|
29
|
+
};
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
var _constants = require("./constants");
|
|
33
|
+
/*!
|
|
34
|
+
* At the moment we're doing this change for `CoreEnvironment`,
|
|
35
|
+
* but the same change must be made for `TypesEnvironment` in @atlaspack/types.
|
|
36
|
+
*/
|
|
37
|
+
const localEnvironmentCache = new Map();
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* When deduplication is cleaned-up this will always be a string.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Convert environment to a ref.
|
|
45
|
+
* This is what we should be using to store environments.
|
|
46
|
+
*/
|
|
47
|
+
function toEnvironmentRef(env) {
|
|
48
|
+
if (!(0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
|
|
49
|
+
return env;
|
|
50
|
+
}
|
|
51
|
+
const id = toEnvironmentId(env);
|
|
52
|
+
return id;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Convert environment to a string ID
|
|
57
|
+
*/
|
|
58
|
+
function toEnvironmentId(
|
|
59
|
+
/**
|
|
60
|
+
* Redundant type during roll-out
|
|
61
|
+
*/
|
|
62
|
+
env) {
|
|
63
|
+
if (!(0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
|
|
64
|
+
return typeof env === 'string' ? env : env.id;
|
|
65
|
+
}
|
|
66
|
+
if (typeof env === 'string') {
|
|
67
|
+
return env;
|
|
68
|
+
}
|
|
69
|
+
(0, _rust().addEnvironment)(env);
|
|
70
|
+
return env.id;
|
|
71
|
+
}
|
|
72
|
+
function fromEnvironmentId(id) {
|
|
73
|
+
if (!(0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
|
|
74
|
+
if (typeof id === 'string') {
|
|
75
|
+
throw new Error('This should never happen when environmentDeduplication feature-flag is off');
|
|
76
|
+
} else {
|
|
77
|
+
return id;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (typeof id !== 'string') {
|
|
81
|
+
return id;
|
|
82
|
+
}
|
|
83
|
+
const localEnv = localEnvironmentCache.get(id);
|
|
84
|
+
if (localEnv) {
|
|
85
|
+
return localEnv;
|
|
86
|
+
}
|
|
87
|
+
const env = Object.freeze((0, _rust().getEnvironment)(id));
|
|
88
|
+
localEnvironmentCache.set(id, env);
|
|
89
|
+
return env;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Writes all environments and their IDs to the cache
|
|
94
|
+
* @param {Cache} cache
|
|
95
|
+
* @returns {Promise<void>}
|
|
96
|
+
*/
|
|
97
|
+
async function writeEnvironmentsToCache(cache) {
|
|
98
|
+
const environments = (0, _rust().getAllEnvironments)();
|
|
99
|
+
const environmentIds = new Set();
|
|
100
|
+
|
|
101
|
+
// Store each environment individually
|
|
102
|
+
for (const env of environments) {
|
|
103
|
+
environmentIds.add(env.id);
|
|
104
|
+
const envKey = `Environment/${_constants.ATLASPACK_VERSION}/${env.id}`;
|
|
105
|
+
await (0, _logger().instrument)(`RequestTracker::writeToCache::cache.put(${envKey})`, async () => {
|
|
106
|
+
await cache.set(envKey, env);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Store the list of environment IDs
|
|
111
|
+
await (0, _logger().instrument)(`RequestTracker::writeToCache::cache.put(${`EnvironmentManager/${_constants.ATLASPACK_VERSION}`})`, async () => {
|
|
112
|
+
await cache.set(`EnvironmentManager/${_constants.ATLASPACK_VERSION}`, Array.from(environmentIds));
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Loads all environments and their IDs from the cache
|
|
118
|
+
* @param {Cache} cache
|
|
119
|
+
* @returns {Promise<void>}
|
|
120
|
+
*/
|
|
121
|
+
async function loadEnvironmentsFromCache(cache) {
|
|
122
|
+
const cachedEnvIds = await cache.get(`EnvironmentManager/${_constants.ATLASPACK_VERSION}`);
|
|
123
|
+
if (cachedEnvIds == null) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const environments = [];
|
|
127
|
+
for (const envId of cachedEnvIds) {
|
|
128
|
+
const envKey = `Environment/${_constants.ATLASPACK_VERSION}/${envId}`;
|
|
129
|
+
const cachedEnv = await cache.get(envKey);
|
|
130
|
+
if (cachedEnv != null) {
|
|
131
|
+
environments.push(cachedEnv);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (environments.length > 0) {
|
|
135
|
+
(0, _rust().setAllEnvironments)(environments);
|
|
136
|
+
}
|
|
137
|
+
}
|
package/lib/InternalConfig.js
CHANGED
|
@@ -14,6 +14,7 @@ function _rust() {
|
|
|
14
14
|
return data;
|
|
15
15
|
}
|
|
16
16
|
var _IdentifierRegistry = require("./IdentifierRegistry");
|
|
17
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
17
18
|
function createConfig({
|
|
18
19
|
plugin,
|
|
19
20
|
isSource,
|
|
@@ -30,11 +31,11 @@ function createConfig({
|
|
|
30
31
|
invalidateOnBuild
|
|
31
32
|
}) {
|
|
32
33
|
let environment = env ?? (0, _Environment.createEnvironment)();
|
|
33
|
-
const configId = (0, _rust().hashString)(plugin + (0, _projectPath.fromProjectPathRelative)(searchPath) + environment
|
|
34
|
+
const configId = (0, _rust().hashString)(plugin + (0, _projectPath.fromProjectPathRelative)(searchPath) + (0, _EnvironmentManager.toEnvironmentId)(environment) + String(isSource));
|
|
34
35
|
_IdentifierRegistry.identifierRegistry.addIdentifier('config_request', configId, {
|
|
35
36
|
plugin,
|
|
36
37
|
searchPath,
|
|
37
|
-
environmentId: environment
|
|
38
|
+
environmentId: (0, _EnvironmentManager.toEnvironmentId)(environment),
|
|
38
39
|
isSource
|
|
39
40
|
});
|
|
40
41
|
return {
|
package/lib/PackagerRunner.js
CHANGED
|
@@ -92,6 +92,7 @@ function _profiler() {
|
|
|
92
92
|
};
|
|
93
93
|
return data;
|
|
94
94
|
}
|
|
95
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
95
96
|
function _featureFlags() {
|
|
96
97
|
const data = require("@atlaspack/feature-flags");
|
|
97
98
|
_featureFlags = function () {
|
|
@@ -397,23 +398,28 @@ class PackagerRunner {
|
|
|
397
398
|
let fullPath = (0, _projectPath.fromProjectPath)(this.options.projectRoot, filePath);
|
|
398
399
|
let sourceRoot = _path().default.relative(_path().default.dirname(fullPath), this.options.projectRoot);
|
|
399
400
|
let inlineSources = false;
|
|
401
|
+
const bundleEnv = (0, _EnvironmentManager.fromEnvironmentId)(bundle.env);
|
|
400
402
|
if (bundle.target) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
403
|
+
const bundleTargetEnv = (0, _EnvironmentManager.fromEnvironmentId)(bundle.target.env);
|
|
404
|
+
if (bundleEnv.sourceMap && bundleEnv.sourceMap.sourceRoot !== undefined) {
|
|
405
|
+
sourceRoot = bundleEnv.sourceMap.sourceRoot;
|
|
406
|
+
} else if (this.options.serveOptions && bundleTargetEnv.context === 'browser') {
|
|
404
407
|
sourceRoot = '/__parcel_source_root';
|
|
405
408
|
}
|
|
406
|
-
if (
|
|
407
|
-
inlineSources =
|
|
408
|
-
} else if (
|
|
409
|
+
if (bundleEnv.sourceMap && bundleEnv.sourceMap.inlineSources !== undefined) {
|
|
410
|
+
inlineSources = bundleEnv.sourceMap.inlineSources;
|
|
411
|
+
} else if (bundleTargetEnv.context !== 'node') {
|
|
409
412
|
// inlining should only happen in production for browser targets by default
|
|
410
413
|
inlineSources = this.options.mode === 'production';
|
|
411
414
|
}
|
|
412
415
|
}
|
|
413
|
-
|
|
414
|
-
|
|
416
|
+
if (process.env.ATLASPACK_SUPER_BUILD === 'true') {
|
|
417
|
+
// Set source root to 'atlaspack' so stack traces are clean in Sentry
|
|
418
|
+
sourceRoot = 'atlaspack';
|
|
419
|
+
}
|
|
420
|
+
let isInlineMap = bundleEnv.sourceMap && bundleEnv.sourceMap.inline;
|
|
415
421
|
let stringified = await map.stringify({
|
|
416
|
-
file: _path().default.basename(
|
|
422
|
+
file: _path().default.basename(fullPath + '.map'),
|
|
417
423
|
// $FlowFixMe
|
|
418
424
|
fs: this.options.inputFS,
|
|
419
425
|
rootDir: this.options.projectRoot,
|