@atlaspack/core 2.16.2-dev.14 → 2.16.2-dev.55
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 +86 -0
- package/lib/Atlaspack.js +10 -2
- package/lib/AtlaspackConfig.schema.js +7 -1
- package/lib/BundleGraph.js +2 -100
- package/lib/PackagerRunner.js +44 -9
- package/lib/RequestTracker.js +326 -121
- package/lib/Transformation.js +2 -2
- package/lib/UncommittedAsset.js +17 -0
- 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/public/BundleGraph.js +21 -8
- package/lib/public/Config.js +28 -0
- package/lib/requests/AssetGraphRequest.js +13 -1
- package/lib/requests/BundleGraphRequest.js +13 -1
- package/lib/requests/WriteBundleRequest.js +11 -2
- package/lib/resolveOptions.js +7 -4
- package/lib/worker.js +18 -1
- package/package.json +23 -19
- package/src/Atlaspack.js +13 -5
- package/src/BundleGraph.js +0 -167
- package/src/PackagerRunner.js +60 -9
- package/src/RequestTracker.js +491 -137
- package/src/UncommittedAsset.js +16 -1
- package/src/atlaspack-v3/worker/compat/plugin-config.js +9 -5
- package/src/atlaspack-v3/worker/worker.js +7 -0
- package/src/public/BundleGraph.js +22 -15
- package/src/public/Config.js +39 -5
- package/src/requests/AssetGraphRequest.js +13 -3
- package/src/requests/BundleGraphRequest.js +13 -3
- package/src/requests/WriteBundleRequest.js +9 -2
- package/src/resolveOptions.js +4 -2
- package/test/RequestTracker.test.js +120 -5
- package/test/test-utils.js +1 -7
package/lib/UncommittedAsset.js
CHANGED
|
@@ -53,6 +53,13 @@ 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
|
+
}
|
|
56
63
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
57
64
|
class UncommittedAsset {
|
|
58
65
|
constructor({
|
|
@@ -133,6 +140,8 @@ class UncommittedAsset {
|
|
|
133
140
|
hash = (0, _rust().hashBuffer)(content);
|
|
134
141
|
size = content.length;
|
|
135
142
|
}
|
|
143
|
+
|
|
144
|
+
// Maybe we should just store this in a file instead of LMDB
|
|
136
145
|
await this.options.cache.setBlob(contentKey, content);
|
|
137
146
|
return {
|
|
138
147
|
size,
|
|
@@ -184,6 +193,10 @@ class UncommittedAsset {
|
|
|
184
193
|
this.content = buffer;
|
|
185
194
|
this.clearAST();
|
|
186
195
|
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @deprecated This has been broken on any cache other than FSCache for a long time.
|
|
199
|
+
*/
|
|
187
200
|
setStream(stream) {
|
|
188
201
|
this.content = stream;
|
|
189
202
|
this.clearAST();
|
|
@@ -248,6 +261,10 @@ class UncommittedAsset {
|
|
|
248
261
|
this.value.astGenerator = null;
|
|
249
262
|
}
|
|
250
263
|
getCacheKey(key) {
|
|
264
|
+
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
265
|
+
const filePath = (0, _projectPath.fromProjectPathRelative)(this.value.filePath);
|
|
266
|
+
return `Asset/${_constants.ATLASPACK_VERSION}/${filePath}/${this.value.id}/${key}`;
|
|
267
|
+
}
|
|
251
268
|
return (0, _rust().hashString)(_constants.ATLASPACK_VERSION + key + this.value.id);
|
|
252
269
|
}
|
|
253
270
|
addDependency(opts) {
|
|
@@ -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
|
|
@@ -32,6 +32,13 @@ var _Dependency = _interopRequireWildcard(require("./Dependency"));
|
|
|
32
32
|
var _Target = require("./Target");
|
|
33
33
|
var _utils = require("../utils");
|
|
34
34
|
var _BundleGroup = _interopRequireWildcard(require("./BundleGroup"));
|
|
35
|
+
function _featureFlags() {
|
|
36
|
+
const data = require("@atlaspack/feature-flags");
|
|
37
|
+
_featureFlags = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
35
42
|
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); }
|
|
36
43
|
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; }
|
|
37
44
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -115,9 +122,6 @@ class BundleGraph {
|
|
|
115
122
|
isAssetReferenced(bundle, asset) {
|
|
116
123
|
return this.#graph.isAssetReferenced((0, _Bundle.bundleToInternalBundle)(bundle), (0, _Asset.assetToAssetValue)(asset));
|
|
117
124
|
}
|
|
118
|
-
getReferencedAssets(bundle, cache) {
|
|
119
|
-
return this.#graph.getReferencedAssets((0, _Bundle.bundleToInternalBundle)(bundle), cache);
|
|
120
|
-
}
|
|
121
125
|
hasParentBundleOfType(bundle, type) {
|
|
122
126
|
return this.#graph.hasParentBundleOfType((0, _Bundle.bundleToInternalBundle)(bundle), type);
|
|
123
127
|
}
|
|
@@ -266,11 +270,20 @@ class BundleGraph {
|
|
|
266
270
|
}
|
|
267
271
|
for (let bundle of bundles) {
|
|
268
272
|
const conditions = bundleConditions.get(bundle.id) ?? new Map();
|
|
269
|
-
conditions.
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
273
|
+
const currentCondition = conditions.get(cond.key);
|
|
274
|
+
if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingReporterSameConditionFix')) {
|
|
275
|
+
conditions.set(cond.key, {
|
|
276
|
+
bundle,
|
|
277
|
+
ifTrueBundles: [...((currentCondition === null || currentCondition === void 0 ? void 0 : currentCondition.ifTrueBundles) ?? []), ...ifTrueBundles],
|
|
278
|
+
ifFalseBundles: [...((currentCondition === null || currentCondition === void 0 ? void 0 : currentCondition.ifFalseBundles) ?? []), ...ifFalseBundles]
|
|
279
|
+
});
|
|
280
|
+
} else {
|
|
281
|
+
conditions.set(cond.key, {
|
|
282
|
+
bundle,
|
|
283
|
+
ifTrueBundles,
|
|
284
|
+
ifFalseBundles
|
|
285
|
+
});
|
|
286
|
+
}
|
|
274
287
|
bundleConditions.set(bundle.id, conditions);
|
|
275
288
|
}
|
|
276
289
|
}
|
package/lib/public/Config.js
CHANGED
|
@@ -27,6 +27,13 @@ function _utils() {
|
|
|
27
27
|
}
|
|
28
28
|
var _Environment = _interopRequireDefault(require("./Environment"));
|
|
29
29
|
var _projectPath = require("../projectPath");
|
|
30
|
+
function _featureFlags() {
|
|
31
|
+
const data = require("@atlaspack/feature-flags");
|
|
32
|
+
_featureFlags = function () {
|
|
33
|
+
return data;
|
|
34
|
+
};
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
30
37
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
38
|
const internalConfigToConfig = new (_utils().DefaultWeakMap)(() => new WeakMap());
|
|
32
39
|
class PublicConfig {
|
|
@@ -126,6 +133,27 @@ class PublicConfig {
|
|
|
126
133
|
};
|
|
127
134
|
}
|
|
128
135
|
}
|
|
136
|
+
if ((0, _featureFlags().getFeatureFlag)('granularTsConfigInvalidation')) {
|
|
137
|
+
const configKey = options === null || options === void 0 ? void 0 : options.configKey;
|
|
138
|
+
if (configKey != null) {
|
|
139
|
+
for (let fileName of fileNames) {
|
|
140
|
+
let config = await this.getConfigFrom(searchPath, [fileName], {
|
|
141
|
+
exclude: true
|
|
142
|
+
});
|
|
143
|
+
if (config && config.contents[configKey]) {
|
|
144
|
+
// Invalidate only when the package key changes
|
|
145
|
+
this.invalidateOnConfigKeyChange(config.filePath, configKey);
|
|
146
|
+
return {
|
|
147
|
+
contents: config.contents[configKey],
|
|
148
|
+
filePath: config.filePath
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// fall through so that file above invalidations are registered
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
129
157
|
if (fileNames.length === 0) {
|
|
130
158
|
return null;
|
|
131
159
|
}
|
|
@@ -26,6 +26,13 @@ function _nullthrows() {
|
|
|
26
26
|
};
|
|
27
27
|
return data;
|
|
28
28
|
}
|
|
29
|
+
function _featureFlags() {
|
|
30
|
+
const data = require("@atlaspack/feature-flags");
|
|
31
|
+
_featureFlags = function () {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
return data;
|
|
35
|
+
}
|
|
29
36
|
function _utils() {
|
|
30
37
|
const data = require("@atlaspack/utils");
|
|
31
38
|
_utils = function () {
|
|
@@ -116,7 +123,12 @@ class AssetGraphBuilder {
|
|
|
116
123
|
this.shouldBuildLazily = shouldBuildLazily ?? false;
|
|
117
124
|
this.lazyIncludes = lazyIncludes ?? [];
|
|
118
125
|
this.lazyExcludes = lazyExcludes ?? [];
|
|
119
|
-
|
|
126
|
+
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
127
|
+
const key = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`);
|
|
128
|
+
this.cacheKey = `AssetGraph/${_constants.ATLASPACK_VERSION}/${options.mode}/${key}`;
|
|
129
|
+
} else {
|
|
130
|
+
this.cacheKey = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-AssetGraph';
|
|
131
|
+
}
|
|
120
132
|
this.isSingleChangeRebuild = api.getInvalidSubRequests().filter(req => req.requestType === 'asset_request').length === 1;
|
|
121
133
|
this.queue = new (_utils().PromiseQueue)();
|
|
122
134
|
assetGraph.onNodeRemoved = nodeId => {
|
|
@@ -32,6 +32,13 @@ function _logger() {
|
|
|
32
32
|
};
|
|
33
33
|
return data;
|
|
34
34
|
}
|
|
35
|
+
function _featureFlags() {
|
|
36
|
+
const data = require("@atlaspack/feature-flags");
|
|
37
|
+
_featureFlags = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
35
42
|
function _diagnostic() {
|
|
36
43
|
const data = _interopRequireWildcard(require("@atlaspack/diagnostic"));
|
|
37
44
|
_diagnostic = function () {
|
|
@@ -225,7 +232,12 @@ class BundlerRunner {
|
|
|
225
232
|
this.devDepRequests = new Map();
|
|
226
233
|
this.configs = new Map();
|
|
227
234
|
this.pluginOptions = new _PluginOptions.default((0, _utils2.optionsProxy)(this.options, api.invalidateOnOptionChange));
|
|
228
|
-
|
|
235
|
+
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
236
|
+
const key = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`);
|
|
237
|
+
this.cacheKey = `BundleGraph/${_constants.ATLASPACK_VERSION}/${options.mode}/${key}`;
|
|
238
|
+
} else {
|
|
239
|
+
this.cacheKey = (0, _rust().hashString)(`${_constants.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-BundleGraph';
|
|
240
|
+
}
|
|
229
241
|
}
|
|
230
242
|
async loadConfigs() {
|
|
231
243
|
// Load all configs up front so we can use them in the cache key
|
|
@@ -61,6 +61,13 @@ function _profiler() {
|
|
|
61
61
|
return data;
|
|
62
62
|
}
|
|
63
63
|
var _RequestTracker = require("../RequestTracker");
|
|
64
|
+
function _featureFlags() {
|
|
65
|
+
const data = require("@atlaspack/feature-flags");
|
|
66
|
+
_featureFlags = function () {
|
|
67
|
+
return data;
|
|
68
|
+
};
|
|
69
|
+
return data;
|
|
70
|
+
}
|
|
64
71
|
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); }
|
|
65
72
|
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; }
|
|
66
73
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -145,8 +152,10 @@ async function run({
|
|
|
145
152
|
} = await (0, _DevDepRequest.getDevDepRequests)(api);
|
|
146
153
|
(0, _DevDepRequest.invalidateDevDeps)(invalidDevDeps, options, config);
|
|
147
154
|
await writeFiles(contentStream, info, hashRefToNameHash, options, config, outputFS, filePath, writeOptions, devDeps, api);
|
|
148
|
-
|
|
149
|
-
|
|
155
|
+
const hasSourceMap = (0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements') ? await options.cache.hasLargeBlob(mapKey) : await options.cache.has(mapKey);
|
|
156
|
+
if (mapKey && bundle.env.sourceMap && !bundle.env.sourceMap.inline && hasSourceMap) {
|
|
157
|
+
const mapEntry = (0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements') ? await options.cache.getLargeBlob(mapKey) : await options.cache.getBlob(mapKey);
|
|
158
|
+
await writeFiles((0, _utils().blobToStream)(mapEntry), info, hashRefToNameHash, options, config, outputFS, (0, _projectPath.toProjectPathUnsafe)((0, _projectPath.fromProjectPathRelative)(filePath) + '.map'), writeOptions, devDeps, api);
|
|
150
159
|
}
|
|
151
160
|
let res = {
|
|
152
161
|
filePath,
|
package/lib/resolveOptions.js
CHANGED
|
@@ -139,16 +139,19 @@ async function resolveOptions(initialOptions) {
|
|
|
139
139
|
// where symlinked dependencies outside the project root need to trigger HMR
|
|
140
140
|
// updates. Default to the project root if not provided.
|
|
141
141
|
let watchDir = initialOptions.watchDir != null ? _path().default.resolve(initialOptions.watchDir) : projectRoot;
|
|
142
|
-
|
|
142
|
+
function createCache() {
|
|
143
143
|
if (initialOptions.cache) {
|
|
144
144
|
return initialOptions.cache;
|
|
145
145
|
}
|
|
146
146
|
const needsRustLmdbCache = (0, _featureFlags().getFeatureFlag)('atlaspackV3');
|
|
147
|
-
if (!
|
|
148
|
-
|
|
147
|
+
if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
148
|
+
if (!needsRustLmdbCache && !(outputFS instanceof _fs().NodeFS)) {
|
|
149
|
+
return new (_cache().FSCache)(outputFS, cacheDir);
|
|
150
|
+
}
|
|
149
151
|
}
|
|
150
152
|
return new (_cache().LMDBLiteCache)(cacheDir);
|
|
151
|
-
}
|
|
153
|
+
}
|
|
154
|
+
let cache = createCache();
|
|
152
155
|
let mode = initialOptions.mode ?? 'development';
|
|
153
156
|
let shouldOptimize = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau = initialOptions.defaultTargetOptions) === null || _initialOptions$defau === void 0 ? void 0 : _initialOptions$defau.shouldOptimize) ?? mode === 'production';
|
|
154
157
|
let publicUrl = (initialOptions === null || initialOptions === void 0 || (_initialOptions$defau2 = initialOptions.defaultTargetOptions) === null || _initialOptions$defau2 === void 0 ? void 0 : _initialOptions$defau2.publicUrl) ?? '/';
|
package/lib/worker.js
CHANGED
|
@@ -172,7 +172,24 @@ async function childInit() {
|
|
|
172
172
|
await (_rust().init === null || _rust().init === void 0 ? void 0 : (0, _rust().init)());
|
|
173
173
|
}
|
|
174
174
|
const PKG_RE = /node_modules[/\\]((?:@[^/\\]+[/\\][^/\\]+)|[^/\\]+)(?!.*[/\\]node_modules[/\\])/;
|
|
175
|
-
function invalidateRequireCache() {
|
|
175
|
+
function invalidateRequireCache(workerApi, file) {
|
|
176
|
+
if (process.env.ATLASPACK_BUILD_ENV === 'test') {
|
|
177
|
+
// Delete this module and all children in the same node_modules folder
|
|
178
|
+
let module = require.cache[file];
|
|
179
|
+
if (module) {
|
|
180
|
+
var _file$match;
|
|
181
|
+
delete require.cache[file];
|
|
182
|
+
let pkg = (_file$match = file.match(PKG_RE)) === null || _file$match === void 0 ? void 0 : _file$match[1];
|
|
183
|
+
for (let child of module.children) {
|
|
184
|
+
var _child$id$match;
|
|
185
|
+
if (pkg === ((_child$id$match = child.id.match(PKG_RE)) === null || _child$id$match === void 0 ? void 0 : _child$id$match[1])) {
|
|
186
|
+
invalidateRequireCache(workerApi, child.id);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
atlaspackConfigCache.clear();
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
176
193
|
throw new Error('invalidateRequireCache is only for tests');
|
|
177
194
|
}
|
|
178
195
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.16.2-dev.
|
|
3
|
+
"version": "2.16.2-dev.55+5a11f33c5",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"url": "https://github.com/atlassian-labs/atlaspack.git"
|
|
11
11
|
},
|
|
12
12
|
"main": "lib/index.js",
|
|
13
|
+
"types": "index.d.ts",
|
|
13
14
|
"source": "src/index.js",
|
|
14
15
|
"engines": {
|
|
15
16
|
"node": ">= 16.0.0"
|
|
@@ -17,24 +18,24 @@
|
|
|
17
18
|
"scripts": {
|
|
18
19
|
"test": "mocha",
|
|
19
20
|
"test-ci": "mocha",
|
|
20
|
-
"check-ts": "tsc --noEmit index.d.ts"
|
|
21
|
+
"check-ts": "tsc --module node16 --moduleResolution node16 --noEmit index.d.ts"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@atlaspack/build-cache": "2.13.3-dev.
|
|
24
|
-
"@atlaspack/cache": "3.1.1-dev.
|
|
25
|
-
"@atlaspack/diagnostic": "2.14.1-dev.
|
|
26
|
-
"@atlaspack/events": "2.14.1-dev.
|
|
27
|
-
"@atlaspack/feature-flags": "2.14.1-dev.
|
|
28
|
-
"@atlaspack/fs": "2.14.5-dev.
|
|
29
|
-
"@atlaspack/graph": "3.4.1-dev.
|
|
30
|
-
"@atlaspack/logger": "2.14.5-dev.
|
|
31
|
-
"@atlaspack/package-manager": "2.14.5-dev.
|
|
32
|
-
"@atlaspack/plugin": "2.14.5-dev.
|
|
33
|
-
"@atlaspack/profiler": "2.14.1-dev.
|
|
34
|
-
"@atlaspack/rust": "3.2.1-dev.
|
|
35
|
-
"@atlaspack/types": "2.14.5-dev.
|
|
36
|
-
"@atlaspack/utils": "2.14.5-dev.
|
|
37
|
-
"@atlaspack/workers": "2.14.5-dev.
|
|
24
|
+
"@atlaspack/build-cache": "2.13.3-dev.123+5a11f33c5",
|
|
25
|
+
"@atlaspack/cache": "3.1.1-dev.55+5a11f33c5",
|
|
26
|
+
"@atlaspack/diagnostic": "2.14.1-dev.123+5a11f33c5",
|
|
27
|
+
"@atlaspack/events": "2.14.1-dev.123+5a11f33c5",
|
|
28
|
+
"@atlaspack/feature-flags": "2.14.1-dev.123+5a11f33c5",
|
|
29
|
+
"@atlaspack/fs": "2.14.5-dev.55+5a11f33c5",
|
|
30
|
+
"@atlaspack/graph": "3.4.1-dev.123+5a11f33c5",
|
|
31
|
+
"@atlaspack/logger": "2.14.5-dev.55+5a11f33c5",
|
|
32
|
+
"@atlaspack/package-manager": "2.14.5-dev.55+5a11f33c5",
|
|
33
|
+
"@atlaspack/plugin": "2.14.5-dev.55+5a11f33c5",
|
|
34
|
+
"@atlaspack/profiler": "2.14.1-dev.123+5a11f33c5",
|
|
35
|
+
"@atlaspack/rust": "3.2.1-dev.55+5a11f33c5",
|
|
36
|
+
"@atlaspack/types": "2.14.5-dev.55+5a11f33c5",
|
|
37
|
+
"@atlaspack/utils": "2.14.5-dev.55+5a11f33c5",
|
|
38
|
+
"@atlaspack/workers": "2.14.5-dev.55+5a11f33c5",
|
|
38
39
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
39
40
|
"@parcel/source-map": "^2.1.1",
|
|
40
41
|
"base-x": "^3.0.8",
|
|
@@ -57,7 +58,10 @@
|
|
|
57
58
|
},
|
|
58
59
|
"exports": {
|
|
59
60
|
"./*": "./*",
|
|
60
|
-
".":
|
|
61
|
+
".": {
|
|
62
|
+
"types": "./index.d.ts",
|
|
63
|
+
"default": "./lib/index.js"
|
|
64
|
+
},
|
|
61
65
|
"./worker": {
|
|
62
66
|
"@atlaspack::sources": "./src/worker.js",
|
|
63
67
|
"default": "./lib/worker.js"
|
|
@@ -67,5 +71,5 @@
|
|
|
67
71
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
68
72
|
},
|
|
69
73
|
"type": "commonjs",
|
|
70
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "5a11f33c51ff74d1cf8d4b72cfa0fda833aa980a"
|
|
71
75
|
}
|
package/src/Atlaspack.js
CHANGED
|
@@ -165,10 +165,17 @@ export default class Atlaspack {
|
|
|
165
165
|
const version = require('../package.json').version;
|
|
166
166
|
await lmdb.put('current_session_version', Buffer.from(version));
|
|
167
167
|
|
|
168
|
+
let threads = undefined;
|
|
169
|
+
if (process.env.ATLASPACK_NATIVE_THREADS !== undefined) {
|
|
170
|
+
threads = parseInt(process.env.ATLASPACK_NATIVE_THREADS, 10);
|
|
171
|
+
} else if (process.env.NODE_ENV === 'test') {
|
|
172
|
+
threads = 2;
|
|
173
|
+
}
|
|
174
|
+
|
|
168
175
|
rustAtlaspack = await AtlaspackV3.create({
|
|
169
176
|
...options,
|
|
170
177
|
corePath: path.join(__dirname, '..'),
|
|
171
|
-
threads
|
|
178
|
+
threads,
|
|
172
179
|
entries: Array.isArray(entries)
|
|
173
180
|
? entries
|
|
174
181
|
: entries == null
|
|
@@ -526,10 +533,11 @@ export default class Atlaspack {
|
|
|
526
533
|
nativeInvalid = await this.rustAtlaspack.respondToFsEvents(events);
|
|
527
534
|
}
|
|
528
535
|
|
|
529
|
-
let isInvalid =
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
536
|
+
let {didInvalidate: isInvalid} =
|
|
537
|
+
await this.#requestTracker.respondToFSEvents(
|
|
538
|
+
events,
|
|
539
|
+
Number.POSITIVE_INFINITY,
|
|
540
|
+
);
|
|
533
541
|
|
|
534
542
|
if (
|
|
535
543
|
(nativeInvalid || isInvalid) &&
|