@atlaspack/core 2.12.1-canary.3508 → 2.12.1-canary.3510
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/lib/RequestTracker.js
CHANGED
|
@@ -960,9 +960,7 @@ class RequestTracker {
|
|
|
960
960
|
let node = serialisedGraph.nodes[i];
|
|
961
961
|
let resultCacheKey = node === null || node === void 0 ? void 0 : node.resultCacheKey;
|
|
962
962
|
if ((node === null || node === void 0 ? void 0 : node.type) === REQUEST && resultCacheKey != null && (node === null || node === void 0 ? void 0 : node.result) != null) {
|
|
963
|
-
queue.add(() => serialiseAndSet(resultCacheKey, node.result))
|
|
964
|
-
// Handle promise rejection
|
|
965
|
-
});
|
|
963
|
+
queue.add(() => serialiseAndSet(resultCacheKey, node.result));
|
|
966
964
|
|
|
967
965
|
// eslint-disable-next-line no-unused-vars
|
|
968
966
|
let {
|
|
@@ -985,9 +983,7 @@ class RequestTracker {
|
|
|
985
983
|
queue.add(() => serialiseAndSet(getRequestGraphNodeKey(i, cacheKey), nodesToCache).then(() => {
|
|
986
984
|
// Succeeded in writing to disk, save that we have completed this chunk
|
|
987
985
|
this.graph.setCachedRequestChunk(i);
|
|
988
|
-
}))
|
|
989
|
-
// Handle promise rejection
|
|
990
|
-
});
|
|
986
|
+
}));
|
|
991
987
|
}
|
|
992
988
|
}
|
|
993
989
|
try {
|
|
@@ -193,17 +193,24 @@ class BundleGraph {
|
|
|
193
193
|
// Given a set of dependencies, return any conditions where those dependencies are either
|
|
194
194
|
// the true or false dependency for those conditions. This is currently used to work out which
|
|
195
195
|
// conditions belong to a bundle in packaging.
|
|
196
|
-
getConditionsForDependencies(deps) {
|
|
196
|
+
getConditionsForDependencies(deps, bundle) {
|
|
197
197
|
const conditions = new Set();
|
|
198
198
|
const depIds = deps.map(dep => dep.id);
|
|
199
199
|
for (const condition of this.#graph._conditions.values()) {
|
|
200
200
|
if (depIds.includes(condition.ifTrueDependency.id) || depIds.includes(condition.ifFalseDependency.id)) {
|
|
201
|
-
const [trueAsset, falseAsset] = [condition.ifTrueDependency, condition.ifFalseDependency].map(dep => {
|
|
202
|
-
const
|
|
203
|
-
if (
|
|
204
|
-
|
|
201
|
+
const [[trueAsset, ifTrueBundles], [falseAsset, ifFalseBundles]] = [condition.ifTrueDependency, condition.ifFalseDependency].map(dep => {
|
|
202
|
+
const asset = this.#graph.getResolvedAsset(dep, (0, _Bundle.bundleToInternalBundle)(bundle));
|
|
203
|
+
if (asset && this.#graph.bundleHasAsset((0, _Bundle.bundleToInternalBundle)(bundle), asset)) {
|
|
204
|
+
// Asset is in the same bundle
|
|
205
|
+
return [asset, []];
|
|
206
|
+
}
|
|
207
|
+
const resolvedAsync = (0, _nullthrows().default)(this.#graph.resolveAsyncDependency(dep, (0, _Bundle.bundleToInternalBundle)(bundle)));
|
|
208
|
+
if ((resolvedAsync === null || resolvedAsync === void 0 ? void 0 : resolvedAsync.type) === 'asset') {
|
|
209
|
+
// Single bundle to load dynamically
|
|
210
|
+
return [resolvedAsync.value, [this.#createBundle((0, _nullthrows().default)(this.#graph.getReferencedBundle(dep, (0, _Bundle.bundleToInternalBundle)(bundle))), this.#graph, this.#options)]];
|
|
205
211
|
} else {
|
|
206
|
-
|
|
212
|
+
// Bundle group means we have multiple bundles to load first
|
|
213
|
+
return [this.#graph.getAssetById(resolvedAsync.value.entryAssetId), this.#graph.getBundlesInBundleGroup(resolvedAsync.value).map(b => this.#createBundle(b, this.#graph, this.#options))];
|
|
207
214
|
}
|
|
208
215
|
});
|
|
209
216
|
conditions.add({
|
|
@@ -211,6 +218,8 @@ class BundleGraph {
|
|
|
211
218
|
key: condition.key,
|
|
212
219
|
ifTrueDependency: (0, _nullthrows().default)(deps.find(dep => dep.id === condition.ifTrueDependency.id), 'ifTrueDependency was null'),
|
|
213
220
|
ifFalseDependency: (0, _nullthrows().default)(deps.find(dep => dep.id === condition.ifFalseDependency.id), 'ifFalseDependency was null'),
|
|
221
|
+
ifTrueBundles,
|
|
222
|
+
ifFalseBundles,
|
|
214
223
|
ifTrueAssetId: this.#graph.getAssetPublicId(trueAsset),
|
|
215
224
|
ifFalseAssetId: this.#graph.getAssetPublicId(falseAsset)
|
|
216
225
|
});
|
|
@@ -239,7 +248,11 @@ class BundleGraph {
|
|
|
239
248
|
const assetDeps = this.getDependencies(asset);
|
|
240
249
|
const depToBundles = dep => {
|
|
241
250
|
const publicDep = (0, _nullthrows().default)(assetDeps.find(assetDep => dep.id === assetDep.id));
|
|
242
|
-
const resolved =
|
|
251
|
+
const resolved = this.resolveAsyncDependency(publicDep);
|
|
252
|
+
if (!resolved) {
|
|
253
|
+
// If there's no async dependency, don't list it as required
|
|
254
|
+
return [];
|
|
255
|
+
}
|
|
243
256
|
(0, _assert().default)(resolved.type === 'bundle_group');
|
|
244
257
|
return this.getBundlesInBundleGroup(resolved.value);
|
|
245
258
|
};
|
|
@@ -279,7 +279,8 @@ class AssetGraphBuilder {
|
|
|
279
279
|
node.requested = true;
|
|
280
280
|
} else if (!node.requested) {
|
|
281
281
|
let isAsyncChild = this.assetGraph.getIncomingDependencies(node.value).every(dep => dep.isEntry || dep.priority !== _types.Priority.sync);
|
|
282
|
-
if (isAsyncChild) {
|
|
282
|
+
if (isAsyncChild && childNode.value.priority !== _types.Priority.conditional) {
|
|
283
|
+
// Skip if we're on a conditional import
|
|
283
284
|
node.requested = !isNodeLazy;
|
|
284
285
|
} else {
|
|
285
286
|
delete node.requested;
|
|
@@ -337,7 +338,11 @@ class AssetGraphBuilder {
|
|
|
337
338
|
default:
|
|
338
339
|
throw new Error(`Can not queue corresponding request of node with type ${node.type}`);
|
|
339
340
|
}
|
|
340
|
-
return
|
|
341
|
+
return new Promise(resolve => {
|
|
342
|
+
this.queue.add(() => promise.then(() => {
|
|
343
|
+
resolve(null);
|
|
344
|
+
}, error => errors.push(error)));
|
|
345
|
+
});
|
|
341
346
|
}
|
|
342
347
|
async runEntryRequest(input) {
|
|
343
348
|
let prevEntries = this.assetGraph.safeToIncrementallyBundle ? this.assetGraph.getEntryAssets().map(asset => asset.id).sort() : [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/core",
|
|
3
|
-
"version": "2.12.1-canary.
|
|
3
|
+
"version": "2.12.1-canary.3510+ee6ecd192",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -20,21 +20,21 @@
|
|
|
20
20
|
"check-ts": "tsc --noEmit index.d.ts"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@atlaspack/build-cache": "2.12.1-canary.
|
|
24
|
-
"@atlaspack/cache": "2.12.1-canary.
|
|
25
|
-
"@atlaspack/diagnostic": "2.12.1-canary.
|
|
26
|
-
"@atlaspack/events": "2.12.1-canary.
|
|
27
|
-
"@atlaspack/feature-flags": "2.12.1-canary.
|
|
28
|
-
"@atlaspack/fs": "2.12.1-canary.
|
|
29
|
-
"@atlaspack/graph": "3.2.1-canary.
|
|
30
|
-
"@atlaspack/logger": "2.12.1-canary.
|
|
31
|
-
"@atlaspack/package-manager": "2.12.1-canary.
|
|
32
|
-
"@atlaspack/plugin": "2.12.1-canary.
|
|
33
|
-
"@atlaspack/profiler": "2.12.1-canary.
|
|
34
|
-
"@atlaspack/rust": "2.12.1-canary.
|
|
35
|
-
"@atlaspack/types": "2.12.1-canary.
|
|
36
|
-
"@atlaspack/utils": "2.12.1-canary.
|
|
37
|
-
"@atlaspack/workers": "2.12.1-canary.
|
|
23
|
+
"@atlaspack/build-cache": "2.12.1-canary.3510+ee6ecd192",
|
|
24
|
+
"@atlaspack/cache": "2.12.1-canary.3510+ee6ecd192",
|
|
25
|
+
"@atlaspack/diagnostic": "2.12.1-canary.3510+ee6ecd192",
|
|
26
|
+
"@atlaspack/events": "2.12.1-canary.3510+ee6ecd192",
|
|
27
|
+
"@atlaspack/feature-flags": "2.12.1-canary.3510+ee6ecd192",
|
|
28
|
+
"@atlaspack/fs": "2.12.1-canary.3510+ee6ecd192",
|
|
29
|
+
"@atlaspack/graph": "3.2.1-canary.3510+ee6ecd192",
|
|
30
|
+
"@atlaspack/logger": "2.12.1-canary.3510+ee6ecd192",
|
|
31
|
+
"@atlaspack/package-manager": "2.12.1-canary.3510+ee6ecd192",
|
|
32
|
+
"@atlaspack/plugin": "2.12.1-canary.3510+ee6ecd192",
|
|
33
|
+
"@atlaspack/profiler": "2.12.1-canary.3510+ee6ecd192",
|
|
34
|
+
"@atlaspack/rust": "2.12.1-canary.3510+ee6ecd192",
|
|
35
|
+
"@atlaspack/types": "2.12.1-canary.3510+ee6ecd192",
|
|
36
|
+
"@atlaspack/utils": "2.12.1-canary.3510+ee6ecd192",
|
|
37
|
+
"@atlaspack/workers": "2.12.1-canary.3510+ee6ecd192",
|
|
38
38
|
"@mischnic/json-sourcemap": "^0.1.0",
|
|
39
39
|
"@parcel/source-map": "^2.1.1",
|
|
40
40
|
"base-x": "^3.0.8",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"browser": {
|
|
67
67
|
"./src/serializerCore.js": "./src/serializerCore.browser.js"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "ee6ecd19279313160e412378436fd2bbd502dfa0"
|
|
70
70
|
}
|
package/src/RequestTracker.js
CHANGED
|
@@ -1514,11 +1514,7 @@ export default class RequestTracker {
|
|
|
1514
1514
|
resultCacheKey != null &&
|
|
1515
1515
|
node?.result != null
|
|
1516
1516
|
) {
|
|
1517
|
-
queue
|
|
1518
|
-
.add(() => serialiseAndSet(resultCacheKey, node.result))
|
|
1519
|
-
.catch(() => {
|
|
1520
|
-
// Handle promise rejection
|
|
1521
|
-
});
|
|
1517
|
+
queue.add(() => serialiseAndSet(resultCacheKey, node.result));
|
|
1522
1518
|
|
|
1523
1519
|
// eslint-disable-next-line no-unused-vars
|
|
1524
1520
|
let {result: _, ...newNode} = node;
|
|
@@ -1547,19 +1543,15 @@ export default class RequestTracker {
|
|
|
1547
1543
|
// We assume the request graph nodes are immutable and won't change
|
|
1548
1544
|
let nodesToCache = cacheableNodes.slice(nodesStartIndex, nodesEndIndex);
|
|
1549
1545
|
|
|
1550
|
-
queue
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
)
|
|
1560
|
-
.catch(() => {
|
|
1561
|
-
// Handle promise rejection
|
|
1562
|
-
});
|
|
1546
|
+
queue.add(() =>
|
|
1547
|
+
serialiseAndSet(
|
|
1548
|
+
getRequestGraphNodeKey(i, cacheKey),
|
|
1549
|
+
nodesToCache,
|
|
1550
|
+
).then(() => {
|
|
1551
|
+
// Succeeded in writing to disk, save that we have completed this chunk
|
|
1552
|
+
this.graph.setCachedRequestChunk(i);
|
|
1553
|
+
}),
|
|
1554
|
+
);
|
|
1563
1555
|
}
|
|
1564
1556
|
}
|
|
1565
1557
|
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
FilePath,
|
|
12
12
|
GraphVisitor,
|
|
13
13
|
Symbol,
|
|
14
|
+
NamedBundle,
|
|
14
15
|
SymbolResolution,
|
|
15
16
|
Target,
|
|
16
17
|
} from '@atlaspack/types';
|
|
@@ -336,11 +337,16 @@ export default class BundleGraph<TBundle: IBundle>
|
|
|
336
337
|
// Given a set of dependencies, return any conditions where those dependencies are either
|
|
337
338
|
// the true or false dependency for those conditions. This is currently used to work out which
|
|
338
339
|
// conditions belong to a bundle in packaging.
|
|
339
|
-
getConditionsForDependencies(
|
|
340
|
+
getConditionsForDependencies(
|
|
341
|
+
deps: Array<IDependency>,
|
|
342
|
+
bundle: NamedBundle,
|
|
343
|
+
): Set<{|
|
|
340
344
|
publicId: string,
|
|
341
345
|
key: string,
|
|
342
346
|
ifTrueDependency: IDependency,
|
|
343
347
|
ifFalseDependency: IDependency,
|
|
348
|
+
ifTrueBundles: Array<TBundle>,
|
|
349
|
+
ifFalseBundles: Array<TBundle>,
|
|
344
350
|
ifTrueAssetId: string,
|
|
345
351
|
ifFalseAssetId: string,
|
|
346
352
|
|}> {
|
|
@@ -351,15 +357,53 @@ export default class BundleGraph<TBundle: IBundle>
|
|
|
351
357
|
depIds.includes(condition.ifTrueDependency.id) ||
|
|
352
358
|
depIds.includes(condition.ifFalseDependency.id)
|
|
353
359
|
) {
|
|
354
|
-
const [trueAsset, falseAsset] = [
|
|
360
|
+
const [[trueAsset, ifTrueBundles], [falseAsset, ifFalseBundles]] = [
|
|
355
361
|
condition.ifTrueDependency,
|
|
356
362
|
condition.ifFalseDependency,
|
|
357
363
|
].map((dep) => {
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
|
|
364
|
+
const asset = this.#graph.getResolvedAsset(
|
|
365
|
+
dep,
|
|
366
|
+
bundleToInternalBundle(bundle),
|
|
367
|
+
);
|
|
368
|
+
if (
|
|
369
|
+
asset &&
|
|
370
|
+
this.#graph.bundleHasAsset(bundleToInternalBundle(bundle), asset)
|
|
371
|
+
) {
|
|
372
|
+
// Asset is in the same bundle
|
|
373
|
+
return [asset, []];
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
const resolvedAsync = nullthrows(
|
|
377
|
+
this.#graph.resolveAsyncDependency(
|
|
378
|
+
dep,
|
|
379
|
+
bundleToInternalBundle(bundle),
|
|
380
|
+
),
|
|
381
|
+
);
|
|
382
|
+
if (resolvedAsync?.type === 'asset') {
|
|
383
|
+
// Single bundle to load dynamically
|
|
384
|
+
return [
|
|
385
|
+
resolvedAsync.value,
|
|
386
|
+
[
|
|
387
|
+
this.#createBundle(
|
|
388
|
+
nullthrows(
|
|
389
|
+
this.#graph.getReferencedBundle(
|
|
390
|
+
dep,
|
|
391
|
+
bundleToInternalBundle(bundle),
|
|
392
|
+
),
|
|
393
|
+
),
|
|
394
|
+
this.#graph,
|
|
395
|
+
this.#options,
|
|
396
|
+
),
|
|
397
|
+
],
|
|
398
|
+
];
|
|
361
399
|
} else {
|
|
362
|
-
|
|
400
|
+
// Bundle group means we have multiple bundles to load first
|
|
401
|
+
return [
|
|
402
|
+
this.#graph.getAssetById(resolvedAsync.value.entryAssetId),
|
|
403
|
+
this.#graph
|
|
404
|
+
.getBundlesInBundleGroup(resolvedAsync.value)
|
|
405
|
+
.map((b) => this.#createBundle(b, this.#graph, this.#options)),
|
|
406
|
+
];
|
|
363
407
|
}
|
|
364
408
|
});
|
|
365
409
|
|
|
@@ -374,6 +418,8 @@ export default class BundleGraph<TBundle: IBundle>
|
|
|
374
418
|
deps.find((dep) => dep.id === condition.ifFalseDependency.id),
|
|
375
419
|
'ifFalseDependency was null',
|
|
376
420
|
),
|
|
421
|
+
ifTrueBundles,
|
|
422
|
+
ifFalseBundles,
|
|
377
423
|
ifTrueAssetId: this.#graph.getAssetPublicId(trueAsset),
|
|
378
424
|
ifFalseAssetId: this.#graph.getAssetPublicId(falseAsset),
|
|
379
425
|
});
|
|
@@ -416,7 +462,11 @@ export default class BundleGraph<TBundle: IBundle>
|
|
|
416
462
|
const publicDep = nullthrows(
|
|
417
463
|
assetDeps.find((assetDep) => dep.id === assetDep.id),
|
|
418
464
|
);
|
|
419
|
-
const resolved =
|
|
465
|
+
const resolved = this.resolveAsyncDependency(publicDep);
|
|
466
|
+
if (!resolved) {
|
|
467
|
+
// If there's no async dependency, don't list it as required
|
|
468
|
+
return [];
|
|
469
|
+
}
|
|
420
470
|
invariant(resolved.type === 'bundle_group');
|
|
421
471
|
return this.getBundlesInBundleGroup(resolved.value);
|
|
422
472
|
};
|
|
@@ -382,7 +382,11 @@ export class AssetGraphBuilder {
|
|
|
382
382
|
let isAsyncChild = this.assetGraph
|
|
383
383
|
.getIncomingDependencies(node.value)
|
|
384
384
|
.every((dep) => dep.isEntry || dep.priority !== Priority.sync);
|
|
385
|
-
if (
|
|
385
|
+
if (
|
|
386
|
+
isAsyncChild &&
|
|
387
|
+
childNode.value.priority !== Priority.conditional
|
|
388
|
+
) {
|
|
389
|
+
// Skip if we're on a conditional import
|
|
386
390
|
node.requested = !isNodeLazy;
|
|
387
391
|
} else {
|
|
388
392
|
delete node.requested;
|
|
@@ -434,7 +438,7 @@ export class AssetGraphBuilder {
|
|
|
434
438
|
queueCorrespondingRequest(
|
|
435
439
|
nodeId: NodeId,
|
|
436
440
|
errors: Array<Error>,
|
|
437
|
-
): Promise<
|
|
441
|
+
): Promise<null> {
|
|
438
442
|
let promise;
|
|
439
443
|
let node = nullthrows(this.assetGraph.getNode(nodeId));
|
|
440
444
|
switch (node.type) {
|
|
@@ -455,9 +459,16 @@ export class AssetGraphBuilder {
|
|
|
455
459
|
`Can not queue corresponding request of node with type ${node.type}`,
|
|
456
460
|
);
|
|
457
461
|
}
|
|
458
|
-
return
|
|
459
|
-
|
|
460
|
-
|
|
462
|
+
return new Promise((resolve) => {
|
|
463
|
+
this.queue.add(() =>
|
|
464
|
+
promise.then(
|
|
465
|
+
() => {
|
|
466
|
+
resolve(null);
|
|
467
|
+
},
|
|
468
|
+
(error) => errors.push(error),
|
|
469
|
+
),
|
|
470
|
+
);
|
|
471
|
+
});
|
|
461
472
|
}
|
|
462
473
|
|
|
463
474
|
async runEntryRequest(input: ProjectPath) {
|