@atlaspack/core 2.16.2-canary.13 → 2.16.2-canary.131
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 +300 -0
- package/index.d.ts +4 -0
- package/lib/AssetGraph.js +27 -7
- package/lib/Atlaspack.js +35 -27
- package/lib/AtlaspackConfig.schema.js +7 -1
- package/lib/BundleGraph.js +8 -5
- package/lib/Dependency.js +6 -2
- package/lib/Environment.js +5 -3
- package/lib/EnvironmentManager.js +137 -0
- package/lib/InternalConfig.js +3 -2
- package/lib/PackagerRunner.js +54 -16
- package/lib/RequestTracker.js +345 -132
- package/lib/SymbolPropagation.js +14 -0
- package/lib/Transformation.js +2 -2
- package/lib/UncommittedAsset.js +20 -2
- package/lib/applyRuntimes.js +2 -1
- package/lib/assetUtils.js +2 -1
- package/lib/atlaspack-v3/AtlaspackV3.js +16 -3
- 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/index.js +3 -0
- package/lib/atlaspack-v3/worker/worker.js +8 -0
- package/lib/dumpGraphToGraphViz.js +1 -1
- package/lib/index.js +29 -1
- package/lib/public/Asset.js +7 -9
- package/lib/public/Bundle.js +12 -13
- package/lib/public/BundleGraph.js +3 -2
- package/lib/public/BundleGroup.js +2 -3
- package/lib/public/Config.js +95 -8
- package/lib/public/Dependency.js +4 -4
- package/lib/public/Environment.js +2 -3
- package/lib/public/MutableBundleGraph.js +5 -4
- package/lib/public/PluginOptions.js +1 -2
- package/lib/public/Target.js +4 -4
- package/lib/requests/AssetGraphRequest.js +13 -1
- package/lib/requests/AssetGraphRequestRust.js +17 -2
- package/lib/requests/AssetRequest.js +2 -1
- package/lib/requests/BundleGraphRequest.js +13 -1
- package/lib/requests/ConfigRequest.js +27 -4
- package/lib/requests/DevDepRequest.js +11 -1
- package/lib/requests/PathRequest.js +10 -0
- package/lib/requests/TargetRequest.js +18 -16
- package/lib/requests/WriteBundleRequest.js +15 -3
- package/lib/requests/WriteBundlesRequest.js +22 -1
- package/lib/resolveOptions.js +7 -4
- package/lib/worker.js +18 -1
- package/package.json +18 -25
- package/src/AssetGraph.js +30 -7
- package/src/Atlaspack.js +40 -23
- package/src/BundleGraph.js +13 -8
- package/src/Dependency.js +13 -5
- package/src/Environment.js +9 -6
- package/src/EnvironmentManager.js +145 -0
- package/src/InternalConfig.js +6 -5
- package/src/PackagerRunner.js +72 -20
- package/src/RequestTracker.js +526 -157
- package/src/SymbolPropagation.js +13 -1
- package/src/UncommittedAsset.js +23 -3
- package/src/applyRuntimes.js +6 -1
- package/src/assetUtils.js +4 -3
- package/src/atlaspack-v3/AtlaspackV3.js +24 -3
- package/src/atlaspack-v3/worker/compat/plugin-config.js +9 -5
- package/src/atlaspack-v3/worker/index.js +2 -1
- package/src/atlaspack-v3/worker/worker.js +7 -0
- package/src/index.js +5 -1
- package/src/public/Asset.js +13 -6
- package/src/public/Bundle.js +12 -11
- package/src/public/BundleGraph.js +10 -2
- package/src/public/BundleGroup.js +2 -2
- package/src/public/Config.js +132 -18
- package/src/public/Dependency.js +4 -3
- package/src/public/Environment.js +2 -2
- package/src/public/MutableBundleGraph.js +8 -5
- package/src/public/PluginOptions.js +1 -1
- package/src/public/Target.js +4 -3
- package/src/requests/AssetGraphRequest.js +13 -3
- package/src/requests/AssetGraphRequestRust.js +14 -2
- package/src/requests/AssetRequest.js +2 -1
- package/src/requests/BundleGraphRequest.js +13 -3
- package/src/requests/ConfigRequest.js +33 -9
- package/src/requests/DevDepRequest.js +22 -9
- package/src/requests/PathRequest.js +4 -0
- package/src/requests/TargetRequest.js +19 -25
- package/src/requests/WriteBundleRequest.js +14 -8
- package/src/requests/WriteBundlesRequest.js +31 -3
- package/src/resolveOptions.js +4 -2
- package/src/types.js +10 -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 +124 -29
- package/test/public/Config.test.js +108 -0
- package/test/requests/ConfigRequest.test.js +199 -7
- package/test/test-utils.js +4 -9
package/lib/SymbolPropagation.js
CHANGED
|
@@ -4,6 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.propagateSymbols = propagateSymbols;
|
|
7
|
+
function _featureFlags() {
|
|
8
|
+
const data = require("@atlaspack/feature-flags");
|
|
9
|
+
_featureFlags = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
7
14
|
function _assert() {
|
|
8
15
|
const data = _interopRequireDefault(require("assert"));
|
|
9
16
|
_assert = function () {
|
|
@@ -72,6 +79,13 @@ function propagateSymbols({
|
|
|
72
79
|
|
|
73
80
|
// Propagate the requested symbols down from the root to the leaves
|
|
74
81
|
propagateSymbolsDown(assetGraph, changedAssets, assetGroupsWithRemovedParents, (assetNode, incomingDeps, outgoingDeps) => {
|
|
82
|
+
if ((0, _featureFlags().getFeatureFlag)('emptyFileStarRexportFix')) {
|
|
83
|
+
if (assetNode.value.meta.emptyFileStarReexport && incomingDeps.every(d => d.value.specifierType === _types.SpecifierType.esm)) {
|
|
84
|
+
var _assetNode$value$symb;
|
|
85
|
+
(_assetNode$value$symb = assetNode.value.symbols) === null || _assetNode$value$symb === void 0 || _assetNode$value$symb.delete('*');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
75
89
|
// exportSymbol -> identifier
|
|
76
90
|
let assetSymbols = assetNode.value.symbols;
|
|
77
91
|
// identifier -> exportSymbol
|
package/lib/Transformation.js
CHANGED
|
@@ -173,12 +173,12 @@ class Transformation {
|
|
|
173
173
|
});
|
|
174
174
|
|
|
175
175
|
// Prefer `isSource` originating from the AssetRequest.
|
|
176
|
-
|
|
176
|
+
let isSource = isSourceOverride ?? summarizedIsSource;
|
|
177
177
|
return new _UncommittedAsset.default({
|
|
178
178
|
value: (0, _assetUtils.createAsset)(this.options.projectRoot, {
|
|
179
179
|
code,
|
|
180
180
|
filePath,
|
|
181
|
-
isSource
|
|
181
|
+
isSource,
|
|
182
182
|
type: _path().default.extname((0, _projectPath.fromProjectPathRelative)(filePath)).slice(1),
|
|
183
183
|
pipeline,
|
|
184
184
|
env,
|
package/lib/UncommittedAsset.js
CHANGED
|
@@ -53,6 +53,14 @@ var _assetUtils = require("./assetUtils");
|
|
|
53
53
|
var _types = require("./types");
|
|
54
54
|
var _utils2 = require("./utils");
|
|
55
55
|
var _projectPath = require("./projectPath");
|
|
56
|
+
function _featureFlags() {
|
|
57
|
+
const data = require("@atlaspack/feature-flags");
|
|
58
|
+
_featureFlags = function () {
|
|
59
|
+
return data;
|
|
60
|
+
};
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
63
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
56
64
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
57
65
|
class UncommittedAsset {
|
|
58
66
|
constructor({
|
|
@@ -133,6 +141,8 @@ class UncommittedAsset {
|
|
|
133
141
|
hash = (0, _rust().hashBuffer)(content);
|
|
134
142
|
size = content.length;
|
|
135
143
|
}
|
|
144
|
+
|
|
145
|
+
// Maybe we should just store this in a file instead of LMDB
|
|
136
146
|
await this.options.cache.setBlob(contentKey, content);
|
|
137
147
|
return {
|
|
138
148
|
size,
|
|
@@ -184,6 +194,10 @@ class UncommittedAsset {
|
|
|
184
194
|
this.content = buffer;
|
|
185
195
|
this.clearAST();
|
|
186
196
|
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* @deprecated This has been broken on any cache other than FSCache for a long time.
|
|
200
|
+
*/
|
|
187
201
|
setStream(stream) {
|
|
188
202
|
this.content = stream;
|
|
189
203
|
this.clearAST();
|
|
@@ -248,6 +262,10 @@ class UncommittedAsset {
|
|
|
248
262
|
this.value.astGenerator = null;
|
|
249
263
|
}
|
|
250
264
|
getCacheKey(key) {
|
|
265
|
+
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
266
|
+
const filePath = (0, _projectPath.fromProjectPathRelative)(this.value.filePath);
|
|
267
|
+
return `Asset/${_constants.ATLASPACK_VERSION}/${filePath}/${this.value.id}/${key}`;
|
|
268
|
+
}
|
|
251
269
|
return (0, _rust().hashString)(_constants.ATLASPACK_VERSION + key + this.value.id);
|
|
252
270
|
}
|
|
253
271
|
addDependency(opts) {
|
|
@@ -261,7 +279,7 @@ class UncommittedAsset {
|
|
|
261
279
|
...rest,
|
|
262
280
|
// $FlowFixMe "convert" the $ReadOnlyMaps to the interal mutable one
|
|
263
281
|
symbols,
|
|
264
|
-
env: (0, _Environment.mergeEnvironments)(this.options.projectRoot, this.value.env, env),
|
|
282
|
+
env: (0, _Environment.mergeEnvironments)(this.options.projectRoot, (0, _EnvironmentManager.fromEnvironmentId)(this.value.env), env),
|
|
265
283
|
sourceAssetId: this.value.id,
|
|
266
284
|
sourcePath: (0, _projectPath.fromProjectPath)(this.options.projectRoot, this.value.filePath)
|
|
267
285
|
});
|
|
@@ -301,7 +319,7 @@ class UncommittedAsset {
|
|
|
301
319
|
bundleBehavior: result.bundleBehavior ?? (this.value.bundleBehavior == null ? null : _types.BundleBehaviorNames[this.value.bundleBehavior]),
|
|
302
320
|
isBundleSplittable: result.isBundleSplittable ?? this.value.isBundleSplittable,
|
|
303
321
|
isSource: this.value.isSource,
|
|
304
|
-
env: (0, _Environment.mergeEnvironments)(this.options.projectRoot, this.value.env, result.env),
|
|
322
|
+
env: (0, _Environment.mergeEnvironments)(this.options.projectRoot, (0, _EnvironmentManager.fromEnvironmentId)(this.value.env), result.env),
|
|
305
323
|
dependencies: this.value.type === result.type ? new Map(this.value.dependencies) : new Map(),
|
|
306
324
|
meta: {
|
|
307
325
|
...this.value.meta,
|
package/lib/applyRuntimes.js
CHANGED
|
@@ -69,6 +69,7 @@ function _utils() {
|
|
|
69
69
|
};
|
|
70
70
|
return data;
|
|
71
71
|
}
|
|
72
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
72
73
|
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); }
|
|
73
74
|
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; }
|
|
74
75
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -164,7 +165,7 @@ async function applyRuntimes({
|
|
|
164
165
|
let assetGroup = {
|
|
165
166
|
code,
|
|
166
167
|
filePath: (0, _projectPath.toProjectPath)(options.projectRoot, sourceName),
|
|
167
|
-
env: (0, _Environment.mergeEnvironments)(options.projectRoot, bundle.env, env),
|
|
168
|
+
env: (0, _Environment.mergeEnvironments)(options.projectRoot, (0, _EnvironmentManager.fromEnvironmentId)(bundle.env), env),
|
|
168
169
|
// Runtime assets should be considered source, as they should be
|
|
169
170
|
// e.g. compiled to run in the target environment
|
|
170
171
|
isSource: true
|
package/lib/assetUtils.js
CHANGED
|
@@ -66,10 +66,11 @@ function _profiler() {
|
|
|
66
66
|
return data;
|
|
67
67
|
}
|
|
68
68
|
var _IdentifierRegistry = require("./IdentifierRegistry");
|
|
69
|
+
var _EnvironmentManager = require("./EnvironmentManager");
|
|
69
70
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
70
71
|
function createAssetIdFromOptions(options) {
|
|
71
72
|
const data = {
|
|
72
|
-
environmentId: options.env
|
|
73
|
+
environmentId: (0, _EnvironmentManager.toEnvironmentId)(options.env),
|
|
73
74
|
filePath: options.filePath,
|
|
74
75
|
code: options.code,
|
|
75
76
|
pipeline: options.pipeline,
|
|
@@ -21,21 +21,28 @@ function _diagnostic() {
|
|
|
21
21
|
}
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
23
|
class AtlaspackV3 {
|
|
24
|
-
constructor(atlaspack_napi) {
|
|
24
|
+
constructor(atlaspack_napi, napiWorkerPool, isDefaultNapiWorkerPool) {
|
|
25
25
|
this._atlaspack_napi = atlaspack_napi;
|
|
26
|
+
this._napiWorkerPool = napiWorkerPool;
|
|
27
|
+
this._isDefaultNapiWorkerPool = isDefaultNapiWorkerPool;
|
|
26
28
|
}
|
|
27
29
|
static async create({
|
|
28
30
|
fs,
|
|
29
31
|
packageManager,
|
|
30
32
|
threads,
|
|
31
33
|
lmdb,
|
|
32
|
-
napiWorkerPool
|
|
34
|
+
napiWorkerPool,
|
|
33
35
|
...options
|
|
34
36
|
}) {
|
|
35
37
|
options.logLevel = options.logLevel || 'error';
|
|
36
38
|
options.defaultTargetOptions = options.defaultTargetOptions || {};
|
|
37
39
|
// $FlowFixMe "engines" are readonly
|
|
38
40
|
options.defaultTargetOptions.engines = options.defaultTargetOptions.engines || {};
|
|
41
|
+
let isDefaultNapiWorkerPool = false;
|
|
42
|
+
if (!napiWorkerPool) {
|
|
43
|
+
napiWorkerPool = new _NapiWorkerPool.NapiWorkerPool();
|
|
44
|
+
isDefaultNapiWorkerPool = true;
|
|
45
|
+
}
|
|
39
46
|
const [internal, error] = await (0, _rust().atlaspackNapiCreate)({
|
|
40
47
|
fs,
|
|
41
48
|
packageManager,
|
|
@@ -48,7 +55,13 @@ class AtlaspackV3 {
|
|
|
48
55
|
diagnostic: error
|
|
49
56
|
});
|
|
50
57
|
}
|
|
51
|
-
return new AtlaspackV3(internal);
|
|
58
|
+
return new AtlaspackV3(internal, napiWorkerPool, isDefaultNapiWorkerPool);
|
|
59
|
+
}
|
|
60
|
+
end() {
|
|
61
|
+
// If the worker pool was provided to us, don't shut it down, it's up to the provider.
|
|
62
|
+
if (this._isDefaultNapiWorkerPool) {
|
|
63
|
+
this._napiWorkerPool.shutdown();
|
|
64
|
+
}
|
|
52
65
|
}
|
|
53
66
|
async buildAssetGraph() {
|
|
54
67
|
let [graph, error] = await (0, _rust().atlaspackNapiBuildAssetGraph)(this._atlaspack_napi);
|
|
@@ -44,13 +44,13 @@ class Environment {
|
|
|
44
44
|
|
|
45
45
|
// TODO
|
|
46
46
|
// eslint-disable-next-line no-unused-vars
|
|
47
|
-
matchesEngines() {
|
|
47
|
+
matchesEngines(minVersions, defaultValue) {
|
|
48
48
|
return true;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// TODO
|
|
52
52
|
// eslint-disable-next-line no-unused-vars
|
|
53
|
-
supports() {
|
|
53
|
+
supports(feature, defaultValue) {
|
|
54
54
|
return true;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -126,32 +126,32 @@ class MutableAsset {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
// eslint-disable-next-line no-unused-vars
|
|
129
|
-
addDependency() {
|
|
129
|
+
addDependency(options) {
|
|
130
130
|
throw new Error('MutableAsset.addDependency()');
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
// eslint-disable-next-line no-unused-vars
|
|
134
|
-
addURLDependency() {
|
|
134
|
+
addURLDependency(url, opts) {
|
|
135
135
|
throw new Error('MutableAsset.addURLDependency()');
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
// eslint-disable-next-line no-unused-vars
|
|
139
|
-
setEnvironment() {
|
|
139
|
+
setEnvironment(opts) {
|
|
140
140
|
throw new Error('MutableAsset.setEnvironment()');
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
// eslint-disable-next-line no-unused-vars
|
|
144
|
-
invalidateOnFileChange() {
|
|
144
|
+
invalidateOnFileChange(invalidation) {
|
|
145
145
|
// TODO: Forward invalidations to Rust
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
// eslint-disable-next-line no-unused-vars
|
|
149
|
-
invalidateOnFileCreate() {
|
|
149
|
+
invalidateOnFileCreate(invalidation) {
|
|
150
150
|
// TODO: Forward invalidations to Rust
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
// eslint-disable-next-line no-unused-vars
|
|
154
|
-
invalidateOnEnvChange() {
|
|
154
|
+
invalidateOnEnvChange(invalidation) {
|
|
155
155
|
// TODO: Forward invalidations to Rust
|
|
156
156
|
}
|
|
157
157
|
invalidateOnStartup() {
|
|
@@ -40,21 +40,21 @@ class PluginConfig {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
// eslint-disable-next-line no-unused-vars
|
|
43
|
-
invalidateOnFileChange() {}
|
|
43
|
+
invalidateOnFileChange(filePath) {}
|
|
44
44
|
|
|
45
45
|
// eslint-disable-next-line no-unused-vars
|
|
46
|
-
invalidateOnFileCreate() {}
|
|
46
|
+
invalidateOnFileCreate(invalidations) {}
|
|
47
47
|
|
|
48
48
|
// eslint-disable-next-line no-unused-vars
|
|
49
|
-
invalidateOnEnvChange() {}
|
|
49
|
+
invalidateOnEnvChange(invalidation) {}
|
|
50
50
|
invalidateOnStartup() {}
|
|
51
51
|
invalidateOnBuild() {}
|
|
52
52
|
|
|
53
53
|
// eslint-disable-next-line no-unused-vars
|
|
54
|
-
addDevDependency() {}
|
|
54
|
+
addDevDependency(options) {}
|
|
55
55
|
|
|
56
56
|
// eslint-disable-next-line no-unused-vars
|
|
57
|
-
setCacheKey() {}
|
|
57
|
+
setCacheKey(key) {}
|
|
58
58
|
getConfig(
|
|
59
59
|
// eslint-disable-next-line no-unused-vars
|
|
60
60
|
filePaths,
|
|
@@ -47,7 +47,7 @@ const TYPE_COLORS = {
|
|
|
47
47
|
};
|
|
48
48
|
async function dumpGraphToGraphViz(graph, name, edgeTypes) {
|
|
49
49
|
var _globalThis$ATLASPACK;
|
|
50
|
-
if (
|
|
50
|
+
if (process.env.ATLASPACK_BUILD_ENV === 'production' && !process.env.ATLASPACK_BUILD_REPL) {
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
53
|
let mode = process.env.ATLASPACK_BUILD_REPL ? // $FlowFixMe
|
package/lib/index.js
CHANGED
|
@@ -4,13 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
+
EnvironmentManager: true,
|
|
7
8
|
Atlaspack: true,
|
|
8
9
|
Parcel: true,
|
|
9
10
|
BuildError: true,
|
|
10
11
|
createWorkerFarm: true,
|
|
11
12
|
INTERNAL_RESOLVE: true,
|
|
12
|
-
INTERNAL_TRANSFORM: true
|
|
13
|
+
INTERNAL_TRANSFORM: true,
|
|
14
|
+
WORKER_PATH: true,
|
|
15
|
+
ATLASPACK_VERSION: true,
|
|
16
|
+
resolveOptions: true
|
|
13
17
|
};
|
|
18
|
+
Object.defineProperty(exports, "ATLASPACK_VERSION", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _constants.ATLASPACK_VERSION;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
14
24
|
Object.defineProperty(exports, "Atlaspack", {
|
|
15
25
|
enumerable: true,
|
|
16
26
|
get: function () {
|
|
@@ -23,6 +33,7 @@ Object.defineProperty(exports, "BuildError", {
|
|
|
23
33
|
return _Atlaspack.BuildError;
|
|
24
34
|
}
|
|
25
35
|
});
|
|
36
|
+
exports.EnvironmentManager = void 0;
|
|
26
37
|
Object.defineProperty(exports, "INTERNAL_RESOLVE", {
|
|
27
38
|
enumerable: true,
|
|
28
39
|
get: function () {
|
|
@@ -41,6 +52,12 @@ Object.defineProperty(exports, "Parcel", {
|
|
|
41
52
|
return _Atlaspack.default;
|
|
42
53
|
}
|
|
43
54
|
});
|
|
55
|
+
Object.defineProperty(exports, "WORKER_PATH", {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return _Atlaspack.WORKER_PATH;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
44
61
|
Object.defineProperty(exports, "createWorkerFarm", {
|
|
45
62
|
enumerable: true,
|
|
46
63
|
get: function () {
|
|
@@ -53,7 +70,17 @@ Object.defineProperty(exports, "default", {
|
|
|
53
70
|
return _Atlaspack.default;
|
|
54
71
|
}
|
|
55
72
|
});
|
|
73
|
+
Object.defineProperty(exports, "resolveOptions", {
|
|
74
|
+
enumerable: true,
|
|
75
|
+
get: function () {
|
|
76
|
+
return _resolveOptions.default;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
var EnvironmentManager = _interopRequireWildcard(require("./EnvironmentManager"));
|
|
80
|
+
exports.EnvironmentManager = EnvironmentManager;
|
|
56
81
|
var _Atlaspack = _interopRequireWildcard(require("./Atlaspack"));
|
|
82
|
+
var _constants = require("./constants");
|
|
83
|
+
var _resolveOptions = _interopRequireDefault(require("./resolveOptions"));
|
|
57
84
|
var _atlaspackV = require("./atlaspack-v3");
|
|
58
85
|
Object.keys(_atlaspackV).forEach(function (key) {
|
|
59
86
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -66,5 +93,6 @@ Object.keys(_atlaspackV).forEach(function (key) {
|
|
|
66
93
|
}
|
|
67
94
|
});
|
|
68
95
|
});
|
|
96
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
69
97
|
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); }
|
|
70
98
|
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; }
|
package/lib/public/Asset.js
CHANGED
|
@@ -23,6 +23,7 @@ var _Environment2 = require("../Environment");
|
|
|
23
23
|
var _projectPath = require("../projectPath");
|
|
24
24
|
var _types = require("../types");
|
|
25
25
|
var _utils = require("../utils");
|
|
26
|
+
var _EnvironmentManager = require("../EnvironmentManager");
|
|
26
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
28
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
28
29
|
const uncommittedAssetValueToAsset = new WeakMap();
|
|
@@ -44,8 +45,7 @@ function assetFromValue(value, options) {
|
|
|
44
45
|
}
|
|
45
46
|
class BaseAsset {
|
|
46
47
|
#asset;
|
|
47
|
-
#query
|
|
48
|
-
|
|
48
|
+
#query;
|
|
49
49
|
constructor(asset) {
|
|
50
50
|
this.#asset = asset;
|
|
51
51
|
_assetToAssetValue.set(this, asset.value);
|
|
@@ -62,7 +62,7 @@ class BaseAsset {
|
|
|
62
62
|
return this.#asset.value.type;
|
|
63
63
|
}
|
|
64
64
|
get env() {
|
|
65
|
-
return new _Environment.default(this.#asset.value.env, this.#asset.options);
|
|
65
|
+
return new _Environment.default((0, _EnvironmentManager.fromEnvironmentId)(this.#asset.value.env), this.#asset.options);
|
|
66
66
|
}
|
|
67
67
|
get fs() {
|
|
68
68
|
return this.#asset.options.inputFS;
|
|
@@ -127,9 +127,8 @@ class BaseAsset {
|
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
class Asset extends BaseAsset {
|
|
130
|
-
#asset
|
|
131
|
-
#env
|
|
132
|
-
|
|
130
|
+
#asset;
|
|
131
|
+
#env;
|
|
133
132
|
constructor(asset) {
|
|
134
133
|
let assetValueToAsset = asset.value.committed ? committedAssetValueToAsset : uncommittedAssetValueToAsset;
|
|
135
134
|
let existing = assetValueToAsset.get(asset.value);
|
|
@@ -142,7 +141,7 @@ class Asset extends BaseAsset {
|
|
|
142
141
|
return this;
|
|
143
142
|
}
|
|
144
143
|
get env() {
|
|
145
|
-
this.#env ??= new _Environment.default(this.#asset.value.env, this.#asset.options);
|
|
144
|
+
this.#env ??= new _Environment.default((0, _EnvironmentManager.fromEnvironmentId)(this.#asset.value.env), this.#asset.options);
|
|
146
145
|
return this.#env;
|
|
147
146
|
}
|
|
148
147
|
get stats() {
|
|
@@ -151,8 +150,7 @@ class Asset extends BaseAsset {
|
|
|
151
150
|
}
|
|
152
151
|
exports.Asset = Asset;
|
|
153
152
|
class MutableAsset extends BaseAsset {
|
|
154
|
-
#asset
|
|
155
|
-
|
|
153
|
+
#asset;
|
|
156
154
|
constructor(asset) {
|
|
157
155
|
let existing = assetValueToMutableAsset.get(asset.value);
|
|
158
156
|
if (existing != null) {
|
package/lib/public/Bundle.js
CHANGED
|
@@ -40,6 +40,7 @@ var _Dependency = require("./Dependency");
|
|
|
40
40
|
var _Target = _interopRequireDefault(require("./Target"));
|
|
41
41
|
var _types = require("../types");
|
|
42
42
|
var _projectPath = require("../projectPath");
|
|
43
|
+
var _EnvironmentManager = require("../EnvironmentManager");
|
|
43
44
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
44
45
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
45
46
|
const internalBundleToBundle = new (_utils().DefaultWeakMap)(() => new (_utils().DefaultWeakMap)(() => new WeakMap()));
|
|
@@ -61,9 +62,9 @@ function bundleToInternalBundleGraph(bundle) {
|
|
|
61
62
|
// preventing others from using them. They should use the static `get` method.
|
|
62
63
|
let _private = {};
|
|
63
64
|
class Bundle {
|
|
64
|
-
#bundle
|
|
65
|
-
#bundleGraph
|
|
66
|
-
#options
|
|
65
|
+
#bundle;
|
|
66
|
+
#bundleGraph;
|
|
67
|
+
#options;
|
|
67
68
|
|
|
68
69
|
// $FlowFixMe
|
|
69
70
|
[inspect]() {
|
|
@@ -99,7 +100,7 @@ class Bundle {
|
|
|
99
100
|
return this.#bundle.type;
|
|
100
101
|
}
|
|
101
102
|
get env() {
|
|
102
|
-
return new _Environment.default(this.#bundle.env, this.#options);
|
|
103
|
+
return new _Environment.default((0, _EnvironmentManager.fromEnvironmentId)(this.#bundle.env), this.#options);
|
|
103
104
|
}
|
|
104
105
|
get needsStableName() {
|
|
105
106
|
return this.#bundle.needsStableName;
|
|
@@ -158,10 +159,9 @@ class Bundle {
|
|
|
158
159
|
}
|
|
159
160
|
exports.Bundle = Bundle;
|
|
160
161
|
class NamedBundle extends Bundle {
|
|
161
|
-
#bundle
|
|
162
|
-
#bundleGraph
|
|
163
|
-
#options
|
|
164
|
-
|
|
162
|
+
#bundle;
|
|
163
|
+
#bundleGraph;
|
|
164
|
+
#options;
|
|
165
165
|
constructor(sentinel, bundle, bundleGraph, options) {
|
|
166
166
|
super(sentinel, bundle, bundleGraph, options);
|
|
167
167
|
this.#bundle = bundle; // Repeating for flow
|
|
@@ -192,11 +192,10 @@ class NamedBundle extends Bundle {
|
|
|
192
192
|
}
|
|
193
193
|
exports.NamedBundle = NamedBundle;
|
|
194
194
|
class PackagedBundle extends NamedBundle {
|
|
195
|
-
#bundle
|
|
196
|
-
#bundleGraph
|
|
197
|
-
#options
|
|
198
|
-
#bundleInfo
|
|
199
|
-
|
|
195
|
+
#bundle;
|
|
196
|
+
#bundleGraph;
|
|
197
|
+
#options;
|
|
198
|
+
#bundleInfo;
|
|
200
199
|
constructor(sentinel, bundle, bundleGraph, options) {
|
|
201
200
|
super(sentinel, bundle, bundleGraph, options);
|
|
202
201
|
this.#bundle = bundle; // Repeating for flow
|
|
@@ -263,10 +263,11 @@ class BundleGraph {
|
|
|
263
263
|
}
|
|
264
264
|
for (let bundle of bundles) {
|
|
265
265
|
const conditions = bundleConditions.get(bundle.id) ?? new Map();
|
|
266
|
+
const currentCondition = conditions.get(cond.key);
|
|
266
267
|
conditions.set(cond.key, {
|
|
267
268
|
bundle,
|
|
268
|
-
ifTrueBundles,
|
|
269
|
-
ifFalseBundles
|
|
269
|
+
ifTrueBundles: [...((currentCondition === null || currentCondition === void 0 ? void 0 : currentCondition.ifTrueBundles) ?? []), ...ifTrueBundles],
|
|
270
|
+
ifFalseBundles: [...((currentCondition === null || currentCondition === void 0 ? void 0 : currentCondition.ifFalseBundles) ?? []), ...ifFalseBundles]
|
|
270
271
|
});
|
|
271
272
|
bundleConditions.set(bundle.id, conditions);
|
|
272
273
|
}
|
|
@@ -21,9 +21,8 @@ function bundleGroupToInternalBundleGroup(target) {
|
|
|
21
21
|
}
|
|
22
22
|
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
23
23
|
class BundleGroup {
|
|
24
|
-
#bundleGroup
|
|
25
|
-
#options
|
|
26
|
-
|
|
24
|
+
#bundleGroup;
|
|
25
|
+
#options;
|
|
27
26
|
constructor(bundleGroup, options) {
|
|
28
27
|
let existing = internalBundleGroupToBundleGroup.get(bundleGroup);
|
|
29
28
|
if (existing != null) {
|
package/lib/public/Config.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
exports.makeConfigProxy = makeConfigProxy;
|
|
7
8
|
function _assert() {
|
|
8
9
|
const data = _interopRequireDefault(require("assert"));
|
|
9
10
|
_assert = function () {
|
|
@@ -27,14 +28,79 @@ function _utils() {
|
|
|
27
28
|
}
|
|
28
29
|
var _Environment = _interopRequireDefault(require("./Environment"));
|
|
29
30
|
var _projectPath = require("../projectPath");
|
|
31
|
+
var _EnvironmentManager = require("../EnvironmentManager");
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
33
|
const internalConfigToConfig = new (_utils().DefaultWeakMap)(() => new WeakMap());
|
|
32
|
-
class PublicConfig {
|
|
33
|
-
#config /*: Config */;
|
|
34
|
-
#pkg /*: ?PackageJSON */;
|
|
35
|
-
#pkgFilePath /*: ?FilePath */;
|
|
36
|
-
#options /*: AtlaspackOptions */;
|
|
37
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Implements read tracking over an object.
|
|
37
|
+
*
|
|
38
|
+
* Calling this function with a non-trivial object like a class instance will fail to work.
|
|
39
|
+
*
|
|
40
|
+
* We track reads to fields that resolve to:
|
|
41
|
+
*
|
|
42
|
+
* - primitive values
|
|
43
|
+
* - arrays
|
|
44
|
+
*
|
|
45
|
+
* That is, reading a nested field `a.b.c` will make a single call to `onRead` with the path
|
|
46
|
+
* `['a', 'b', 'c']`.
|
|
47
|
+
*
|
|
48
|
+
* In case the value is null or an array, we will track the read as well.
|
|
49
|
+
*
|
|
50
|
+
* Iterating over `Object.keys(obj.field)` will register a read for the `['field']` path.
|
|
51
|
+
* Other reads work normally.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
*
|
|
55
|
+
* const usedPaths = new Set();
|
|
56
|
+
* const onRead = (path) => {
|
|
57
|
+
* usedPaths.add(path);
|
|
58
|
+
* };
|
|
59
|
+
*
|
|
60
|
+
* const config = makeConfigProxy(onRead, {a: {b: {c: 'd'}}})
|
|
61
|
+
* console.log(config.a.b.c);
|
|
62
|
+
* console.log(Array.from(usedPaths));
|
|
63
|
+
* // We get a single read for the path
|
|
64
|
+
* // ['a', 'b', 'c']
|
|
65
|
+
*
|
|
66
|
+
*/
|
|
67
|
+
function makeConfigProxy(onRead, config) {
|
|
68
|
+
const reportedPaths = new Set();
|
|
69
|
+
const reportPath = path => {
|
|
70
|
+
if (reportedPaths.has(path)) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
reportedPaths.add(path);
|
|
74
|
+
onRead(path);
|
|
75
|
+
};
|
|
76
|
+
const makeProxy = (target, path) => {
|
|
77
|
+
return new Proxy(target, {
|
|
78
|
+
ownKeys(target) {
|
|
79
|
+
reportPath(path);
|
|
80
|
+
|
|
81
|
+
// $FlowFixMe
|
|
82
|
+
return Object.getOwnPropertyNames(target);
|
|
83
|
+
},
|
|
84
|
+
get(target, prop) {
|
|
85
|
+
// $FlowFixMe
|
|
86
|
+
const value = target[prop];
|
|
87
|
+
if (typeof value === 'object' && value != null && !Array.isArray(value)) {
|
|
88
|
+
return makeProxy(value, [...path, prop]);
|
|
89
|
+
}
|
|
90
|
+
reportPath([...path, prop]);
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// $FlowFixMe
|
|
97
|
+
return makeProxy(config, []);
|
|
98
|
+
}
|
|
99
|
+
class PublicConfig {
|
|
100
|
+
#config;
|
|
101
|
+
#pkg;
|
|
102
|
+
#pkgFilePath;
|
|
103
|
+
#options;
|
|
38
104
|
constructor(config, options) {
|
|
39
105
|
let existing = internalConfigToConfig.get(options).get(config);
|
|
40
106
|
if (existing != null) {
|
|
@@ -46,7 +112,7 @@ class PublicConfig {
|
|
|
46
112
|
return this;
|
|
47
113
|
}
|
|
48
114
|
get env() {
|
|
49
|
-
return new _Environment.default(this.#config.env, this.#options);
|
|
115
|
+
return new _Environment.default((0, _EnvironmentManager.fromEnvironmentId)(this.#config.env), this.#options);
|
|
50
116
|
}
|
|
51
117
|
get searchPath() {
|
|
52
118
|
return (0, _projectPath.fromProjectPath)(this.#options.projectRoot, this.#config.searchPath);
|
|
@@ -119,13 +185,32 @@ class PublicConfig {
|
|
|
119
185
|
});
|
|
120
186
|
if (pkg && pkg.contents[packageKey]) {
|
|
121
187
|
// Invalidate only when the package key changes
|
|
122
|
-
this.invalidateOnConfigKeyChange(pkg.filePath, packageKey);
|
|
188
|
+
this.invalidateOnConfigKeyChange(pkg.filePath, [packageKey]);
|
|
123
189
|
return {
|
|
124
190
|
contents: pkg.contents[packageKey],
|
|
125
191
|
filePath: pkg.filePath
|
|
126
192
|
};
|
|
127
193
|
}
|
|
128
194
|
}
|
|
195
|
+
const readTracking = options === null || options === void 0 ? void 0 : options.readTracking;
|
|
196
|
+
if (readTracking === true) {
|
|
197
|
+
for (let fileName of fileNames) {
|
|
198
|
+
const config = await this.getConfigFrom(searchPath, [fileName], {
|
|
199
|
+
exclude: true
|
|
200
|
+
});
|
|
201
|
+
if (config != null) {
|
|
202
|
+
return Promise.resolve({
|
|
203
|
+
contents: makeConfigProxy(keyPath => {
|
|
204
|
+
this.invalidateOnConfigKeyChange(config.filePath, keyPath);
|
|
205
|
+
}, config.contents),
|
|
206
|
+
filePath: config.filePath
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// fall through so that file above invalidations are registered
|
|
212
|
+
}
|
|
213
|
+
|
|
129
214
|
if (fileNames.length === 0) {
|
|
130
215
|
return null;
|
|
131
216
|
}
|
|
@@ -190,7 +275,9 @@ class PublicConfig {
|
|
|
190
275
|
if (this.#pkg) {
|
|
191
276
|
return this.#pkg;
|
|
192
277
|
}
|
|
193
|
-
let pkgConfig = await this.getConfig(['package.json']
|
|
278
|
+
let pkgConfig = await this.getConfig(['package.json'], {
|
|
279
|
+
readTracking: true
|
|
280
|
+
});
|
|
194
281
|
if (!pkgConfig) {
|
|
195
282
|
return null;
|
|
196
283
|
}
|