@atlaspack/core 2.16.2-canary.416 → 2.16.2-canary.418
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 +26 -0
- package/dist/PackagerRunner.js +8 -53
- package/dist/RequestTracker.js +17 -80
- package/dist/UncommittedAsset.js +0 -5
- package/dist/requests/AssetGraphRequest.js +2 -9
- package/dist/requests/BundleGraphRequest.js +2 -8
- package/dist/requests/WriteBundleRequest.js +3 -9
- package/dist/resolveOptions.js +2 -4
- package/lib/PackagerRunner.js +8 -42
- package/lib/RequestTracker.js +15 -69
- package/lib/UncommittedAsset.js +0 -11
- package/lib/requests/AssetGraphRequest.js +1 -13
- package/lib/requests/BundleGraphRequest.js +1 -6
- package/lib/requests/WriteBundleRequest.js +3 -3
- package/lib/resolveOptions.js +2 -4
- package/package.json +18 -18
- package/src/PackagerRunner.ts +9 -55
- package/src/RequestTracker.ts +24 -110
- package/src/UncommittedAsset.ts +1 -11
- package/src/requests/AssetGraphRequest.ts +3 -13
- package/src/requests/BundleGraphRequest.ts +3 -12
- package/src/requests/WriteBundleRequest.ts +3 -9
- package/src/resolveOptions.ts +2 -4
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @atlaspack/core
|
|
2
2
|
|
|
3
|
+
## 2.34.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1010](https://github.com/atlassian-labs/atlaspack/pull/1010) [`45a0dc5`](https://github.com/atlassian-labs/atlaspack/commit/45a0dc530fd9472dbfdebcbb05f1aad812ab3b23) Thanks [@benjervis](https://github.com/benjervis)! - Add initial implementation of native symbol propagation
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#1027](https://github.com/atlassian-labs/atlaspack/pull/1027) [`d8e984b`](https://github.com/atlassian-labs/atlaspack/commit/d8e984b7f6d04fa03707fa299bfd8b8bf9f58280) Thanks [@marcins](https://github.com/marcins)! - Improve source map quality through various accuracy fixes.
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`c4082ba`](https://github.com/atlassian-labs/atlaspack/commit/c4082ba3fc1a9328a2e5f23195d5972fbc5d10c8), [`d8e984b`](https://github.com/atlassian-labs/atlaspack/commit/d8e984b7f6d04fa03707fa299bfd8b8bf9f58280), [`ca78e1d`](https://github.com/atlassian-labs/atlaspack/commit/ca78e1d2007bfecd267b283d66a73f3695da4234), [`94e1a58`](https://github.com/atlassian-labs/atlaspack/commit/94e1a58a1a8ed5a4e329745d8a7e6a9530b5cb11), [`3ad8e88`](https://github.com/atlassian-labs/atlaspack/commit/3ad8e880c4c2b9126cbfb6963a3862a75306a26f), [`4c1f39a`](https://github.com/atlassian-labs/atlaspack/commit/4c1f39a911acaefd630d877af1ae5a039931662f), [`fcf7ec5`](https://github.com/atlassian-labs/atlaspack/commit/fcf7ec56fea644e21f7a67d649e6efd1f03c4a6e), [`45a0dc5`](https://github.com/atlassian-labs/atlaspack/commit/45a0dc530fd9472dbfdebcbb05f1aad812ab3b23)]:
|
|
14
|
+
- @atlaspack/rust@3.23.0
|
|
15
|
+
- @atlaspack/package-manager@2.14.54
|
|
16
|
+
- @atlaspack/feature-flags@2.30.0
|
|
17
|
+
- @atlaspack/utils@3.3.6
|
|
18
|
+
- @atlaspack/cache@3.2.49
|
|
19
|
+
- @atlaspack/fs@2.15.49
|
|
20
|
+
- @atlaspack/logger@2.14.46
|
|
21
|
+
- @atlaspack/source-map@3.2.9
|
|
22
|
+
- @atlaspack/build-cache@2.13.12
|
|
23
|
+
- @atlaspack/graph@3.6.16
|
|
24
|
+
- @atlaspack/profiler@2.15.15
|
|
25
|
+
- @atlaspack/workers@2.14.54
|
|
26
|
+
- @atlaspack/plugin@2.14.54
|
|
27
|
+
- @atlaspack/types@2.15.44
|
|
28
|
+
|
|
3
29
|
## 2.33.1
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/PackagerRunner.js
CHANGED
|
@@ -60,7 +60,6 @@ const DevDepRequest_2 = require("./requests/DevDepRequest");
|
|
|
60
60
|
const WriteBundleRequest_1 = require("./requests/WriteBundleRequest");
|
|
61
61
|
const profiler_1 = require("@atlaspack/profiler");
|
|
62
62
|
const EnvironmentManager_1 = require("./EnvironmentManager");
|
|
63
|
-
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
64
63
|
const BOUNDARY_LENGTH = constants_1.HASH_REF_PREFIX.length + 32 - 1;
|
|
65
64
|
// Packager/optimizer configs are not bundle-specific, so we only need to
|
|
66
65
|
// load them once per build.
|
|
@@ -366,18 +365,6 @@ class PackagerRunner {
|
|
|
366
365
|
devDepHashes += await this.getDevDepHashes(inlineBundle);
|
|
367
366
|
}
|
|
368
367
|
let invalidationHash = await (0, assetUtils_1.getInvalidationHash)(invalidations, this.options);
|
|
369
|
-
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
370
|
-
const hash = (0, rust_1.hashString)(constants_1.ATLASPACK_VERSION +
|
|
371
|
-
devDepHashes +
|
|
372
|
-
invalidationHash +
|
|
373
|
-
bundle.target.publicUrl +
|
|
374
|
-
bundleGraph.getHash(bundle) +
|
|
375
|
-
JSON.stringify(configResults) +
|
|
376
|
-
JSON.stringify(globalInfoResults) +
|
|
377
|
-
this.options.mode +
|
|
378
|
-
(this.options.shouldBuildLazily ? 'lazy' : 'eager'));
|
|
379
|
-
return path_1.default.join(bundle.displayName ?? bundle.name ?? bundle.id, hash);
|
|
380
|
-
}
|
|
381
368
|
return (0, rust_1.hashString)(constants_1.ATLASPACK_VERSION +
|
|
382
369
|
devDepHashes +
|
|
383
370
|
invalidationHash +
|
|
@@ -407,23 +394,17 @@ class PackagerRunner {
|
|
|
407
394
|
let contentKey = PackagerRunner.getContentKey(cacheKey);
|
|
408
395
|
let mapKey = PackagerRunner.getMapKey(cacheKey);
|
|
409
396
|
let isLargeBlob = await this.options.cache.hasLargeBlob(contentKey);
|
|
410
|
-
let contentExists = (
|
|
411
|
-
? isLargeBlob
|
|
412
|
-
: isLargeBlob || (await this.options.cache.has(contentKey));
|
|
397
|
+
let contentExists = isLargeBlob || (await this.options.cache.has(contentKey));
|
|
413
398
|
if (!contentExists) {
|
|
414
399
|
return null;
|
|
415
400
|
}
|
|
416
|
-
let mapExists =
|
|
417
|
-
? await this.options.cache.hasLargeBlob(mapKey)
|
|
418
|
-
: await this.options.cache.has(mapKey);
|
|
401
|
+
let mapExists = await this.options.cache.has(mapKey);
|
|
419
402
|
return {
|
|
420
403
|
contents: isLargeBlob
|
|
421
404
|
? this.options.cache.getStream(contentKey)
|
|
422
405
|
: (0, utils_1.blobToStream)(await this.options.cache.getBlob(contentKey)),
|
|
423
406
|
map: mapExists
|
|
424
|
-
? (0, utils_1.blobToStream)(
|
|
425
|
-
? await this.options.cache.getLargeBlob(mapKey)
|
|
426
|
-
: await this.options.cache.getBlob(mapKey))
|
|
407
|
+
? (0, utils_1.blobToStream)(await this.options.cache.getBlob(mapKey))
|
|
427
408
|
: null,
|
|
428
409
|
};
|
|
429
410
|
}
|
|
@@ -432,12 +413,10 @@ class PackagerRunner {
|
|
|
432
413
|
let hash;
|
|
433
414
|
// @ts-expect-error TS2702
|
|
434
415
|
let hashReferences = [];
|
|
435
|
-
let isLargeBlob =
|
|
416
|
+
let isLargeBlob = false;
|
|
436
417
|
// TODO: don't replace hash references in binary files??
|
|
437
418
|
if (contents instanceof stream_1.Readable) {
|
|
438
|
-
|
|
439
|
-
isLargeBlob = true;
|
|
440
|
-
}
|
|
419
|
+
isLargeBlob = true;
|
|
441
420
|
let boundaryStr = '';
|
|
442
421
|
let h = new rust_1.Hash();
|
|
443
422
|
await this.options.cache.setStream(cacheKeys.content, (0, utils_1.blobToStream)(contents).pipe(
|
|
@@ -456,31 +435,16 @@ class PackagerRunner {
|
|
|
456
435
|
size = buffer.byteLength;
|
|
457
436
|
hash = (0, rust_1.hashBuffer)(buffer);
|
|
458
437
|
hashReferences = contents.match(constants_1.HASH_REF_REGEX) ?? [];
|
|
459
|
-
|
|
460
|
-
await this.options.cache.setLargeBlob(cacheKeys.content, buffer);
|
|
461
|
-
}
|
|
462
|
-
else {
|
|
463
|
-
await this.options.cache.setBlob(cacheKeys.content, buffer);
|
|
464
|
-
}
|
|
438
|
+
await this.options.cache.setBlob(cacheKeys.content, buffer);
|
|
465
439
|
}
|
|
466
440
|
else {
|
|
467
441
|
size = contents.length;
|
|
468
442
|
hash = (0, rust_1.hashBuffer)(contents);
|
|
469
443
|
hashReferences = contents.toString().match(constants_1.HASH_REF_REGEX) ?? [];
|
|
470
|
-
|
|
471
|
-
await this.options.cache.setLargeBlob(cacheKeys.content, contents);
|
|
472
|
-
}
|
|
473
|
-
else {
|
|
474
|
-
await this.options.cache.setBlob(cacheKeys.content, contents);
|
|
475
|
-
}
|
|
444
|
+
await this.options.cache.setBlob(cacheKeys.content, contents);
|
|
476
445
|
}
|
|
477
446
|
if (map != null) {
|
|
478
|
-
|
|
479
|
-
await this.options.cache.setLargeBlob(cacheKeys.map, map);
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
await this.options.cache.setBlob(cacheKeys.map, map);
|
|
483
|
-
}
|
|
447
|
+
await this.options.cache.setBlob(cacheKeys.map, map);
|
|
484
448
|
}
|
|
485
449
|
let info = {
|
|
486
450
|
type,
|
|
@@ -494,21 +458,12 @@ class PackagerRunner {
|
|
|
494
458
|
return info;
|
|
495
459
|
}
|
|
496
460
|
static getContentKey(cacheKey) {
|
|
497
|
-
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
498
|
-
return `PackagerRunner/${constants_1.ATLASPACK_VERSION}/${cacheKey}/content`;
|
|
499
|
-
}
|
|
500
461
|
return (0, rust_1.hashString)(`${cacheKey}:content`);
|
|
501
462
|
}
|
|
502
463
|
static getMapKey(cacheKey) {
|
|
503
|
-
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
504
|
-
return `PackagerRunner/${constants_1.ATLASPACK_VERSION}/${cacheKey}/map`;
|
|
505
|
-
}
|
|
506
464
|
return (0, rust_1.hashString)(`${cacheKey}:map`);
|
|
507
465
|
}
|
|
508
466
|
static getInfoKey(cacheKey) {
|
|
509
|
-
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
510
|
-
return `PackagerRunner/${constants_1.ATLASPACK_VERSION}/${cacheKey}/info`;
|
|
511
|
-
}
|
|
512
467
|
return (0, rust_1.hashString)(`${cacheKey}:info`);
|
|
513
468
|
}
|
|
514
469
|
}
|
package/dist/RequestTracker.js
CHANGED
|
@@ -47,10 +47,9 @@ exports.getBiggestFSEventsInvalidations = getBiggestFSEventsInvalidations;
|
|
|
47
47
|
const assert_1 = __importStar(require("assert"));
|
|
48
48
|
const path_1 = __importDefault(require("path"));
|
|
49
49
|
const build_cache_1 = require("@atlaspack/build-cache");
|
|
50
|
-
const cache_1 = require("@atlaspack/cache");
|
|
51
50
|
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
52
51
|
const graph_1 = require("@atlaspack/graph");
|
|
53
|
-
const logger_1 =
|
|
52
|
+
const logger_1 = __importDefault(require("@atlaspack/logger"));
|
|
54
53
|
const rust_1 = require("@atlaspack/rust");
|
|
55
54
|
const utils_1 = require("@atlaspack/utils");
|
|
56
55
|
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
@@ -782,12 +781,8 @@ class RequestTracker {
|
|
|
782
781
|
}
|
|
783
782
|
else if (node.resultCacheKey != null && ifMatch == null) {
|
|
784
783
|
let key = node.resultCacheKey;
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
let cachedResult = (0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')
|
|
789
|
-
? (0, nullthrows_1.default)(await this.options.cache.get(key))
|
|
790
|
-
: (0, build_cache_1.deserialize)(await this.options.cache.getLargeBlob(key));
|
|
784
|
+
(0, assert_1.default)(this.options.cache.hasLargeBlob(key));
|
|
785
|
+
let cachedResult = (0, build_cache_1.deserialize)(await this.options.cache.getLargeBlob(key));
|
|
791
786
|
node.result = cachedResult;
|
|
792
787
|
return cachedResult;
|
|
793
788
|
}
|
|
@@ -952,32 +947,13 @@ class RequestTracker {
|
|
|
952
947
|
return { api, subRequestContentKeys };
|
|
953
948
|
}
|
|
954
949
|
async writeToCache(signal) {
|
|
955
|
-
const options = this.options;
|
|
956
|
-
async function runCacheImprovements(newPath, oldPath) {
|
|
957
|
-
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
958
|
-
(0, assert_1.default)(options.cache instanceof cache_1.LMDBLiteCache);
|
|
959
|
-
const result = await newPath(options.cache);
|
|
960
|
-
return result;
|
|
961
|
-
}
|
|
962
|
-
else {
|
|
963
|
-
const result = await oldPath();
|
|
964
|
-
return result;
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
950
|
let cacheKey = getCacheKey(this.options);
|
|
968
|
-
let requestGraphKey =
|
|
969
|
-
|
|
970
|
-
: `requestGraph-${cacheKey}`;
|
|
971
|
-
let snapshotKey = (0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')
|
|
972
|
-
? `${cacheKey}/snapshot`
|
|
973
|
-
: `snapshot-${cacheKey}`;
|
|
951
|
+
let requestGraphKey = `requestGraph-${cacheKey}`;
|
|
952
|
+
let snapshotKey = `snapshot-${cacheKey}`;
|
|
974
953
|
if (this.options.shouldDisableCache) {
|
|
975
954
|
return;
|
|
976
955
|
}
|
|
977
956
|
let total = 0;
|
|
978
|
-
await runCacheImprovements(async (cache) => {
|
|
979
|
-
await cache.getNativeRef().startWriteTransaction();
|
|
980
|
-
}, () => Promise.resolve());
|
|
981
957
|
try {
|
|
982
958
|
(0, ReporterRunner_1.report)({
|
|
983
959
|
type: 'cache',
|
|
@@ -986,7 +962,7 @@ class RequestTracker {
|
|
|
986
962
|
size: this.graph.nodes.length,
|
|
987
963
|
});
|
|
988
964
|
if ((0, feature_flags_1.getFeatureFlag)('environmentDeduplication')) {
|
|
989
|
-
await (0, EnvironmentManager_1.writeEnvironmentsToCache)(options.cache);
|
|
965
|
+
await (0, EnvironmentManager_1.writeEnvironmentsToCache)(this.options.cache);
|
|
990
966
|
}
|
|
991
967
|
let serialisedGraph = this.graph.serialize();
|
|
992
968
|
// Delete an existing request graph cache, to prevent invalid states
|
|
@@ -995,18 +971,11 @@ class RequestTracker {
|
|
|
995
971
|
if (signal?.aborted) {
|
|
996
972
|
throw new Error('Serialization was aborted');
|
|
997
973
|
}
|
|
998
|
-
await
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
}, async () => {
|
|
1004
|
-
await this.options.cache.setLargeBlob(key, (0, build_cache_1.serialize)(contents), signal
|
|
1005
|
-
? {
|
|
1006
|
-
signal: signal,
|
|
1007
|
-
}
|
|
1008
|
-
: undefined);
|
|
1009
|
-
});
|
|
974
|
+
await this.options.cache.setLargeBlob(key, (0, build_cache_1.serialize)(contents), signal
|
|
975
|
+
? {
|
|
976
|
+
signal: signal,
|
|
977
|
+
}
|
|
978
|
+
: undefined);
|
|
1010
979
|
total += 1;
|
|
1011
980
|
(0, ReporterRunner_1.report)({
|
|
1012
981
|
type: 'cache',
|
|
@@ -1057,13 +1026,6 @@ class RequestTracker {
|
|
|
1057
1026
|
nodeCountsPerBlob,
|
|
1058
1027
|
nodes: undefined,
|
|
1059
1028
|
});
|
|
1060
|
-
await runCacheImprovements(() => serialiseAndSet(`${cacheKey}/cache_metadata`, {
|
|
1061
|
-
version: constants_1.ATLASPACK_VERSION,
|
|
1062
|
-
entries: this.options.entries,
|
|
1063
|
-
mode: this.options.mode,
|
|
1064
|
-
shouldBuildLazily: this.options.shouldBuildLazily,
|
|
1065
|
-
watchBackend: this.options.watchBackend,
|
|
1066
|
-
}), () => Promise.resolve());
|
|
1067
1029
|
let opts = getWatcherOptions(this.options);
|
|
1068
1030
|
let snapshotPath = path_1.default.join(this.options.cacheDir, snapshotKey + '.txt');
|
|
1069
1031
|
await this.options.outputFS.writeSnapshot(this.options.watchDir, snapshotPath, opts);
|
|
@@ -1073,11 +1035,6 @@ class RequestTracker {
|
|
|
1073
1035
|
if (!signal?.aborted)
|
|
1074
1036
|
throw err;
|
|
1075
1037
|
}
|
|
1076
|
-
finally {
|
|
1077
|
-
await runCacheImprovements(async (cache) => {
|
|
1078
|
-
await cache.getNativeRef().commitWriteTransaction();
|
|
1079
|
-
}, () => Promise.resolve());
|
|
1080
|
-
}
|
|
1081
1038
|
(0, ReporterRunner_1.report)({ type: 'cache', phase: 'end', total, size: this.graph.nodes.length });
|
|
1082
1039
|
}
|
|
1083
1040
|
static async init({ farm, options, rustAtlaspack, }) {
|
|
@@ -1093,31 +1050,17 @@ function getWatcherOptions({ watchIgnore = [], cacheDir, watchDir, watchBackend,
|
|
|
1093
1050
|
return { ignore, backend: watchBackend };
|
|
1094
1051
|
}
|
|
1095
1052
|
function getCacheKey(options) {
|
|
1096
|
-
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
1097
|
-
const hash = (0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}:${JSON.stringify(options.entries)}:${options.mode}:${options.shouldBuildLazily ? 'lazy' : 'eager'}:${options.watchBackend ?? ''}`);
|
|
1098
|
-
return `RequestTracker/${constants_1.ATLASPACK_VERSION}/${hash}`;
|
|
1099
|
-
}
|
|
1100
1053
|
return (0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}:${JSON.stringify(options.entries)}:${options.mode}:${options.shouldBuildLazily ? 'lazy' : 'eager'}:${options.watchBackend ?? ''}`);
|
|
1101
1054
|
}
|
|
1102
1055
|
function getRequestGraphNodeKey(index, cacheKey) {
|
|
1103
|
-
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
1104
|
-
return `${cacheKey}/RequestGraph/nodes/${index}`;
|
|
1105
|
-
}
|
|
1106
1056
|
return `requestGraph-nodes-${index}-${cacheKey}`;
|
|
1107
1057
|
}
|
|
1108
1058
|
async function readAndDeserializeRequestGraph(cache, requestGraphKey, cacheKey) {
|
|
1109
1059
|
let bufferLength = 0;
|
|
1110
1060
|
const getAndDeserialize = async (key) => {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
return (0, build_cache_1.deserialize)(buffer);
|
|
1115
|
-
}
|
|
1116
|
-
else {
|
|
1117
|
-
const buffer = await cache.getLargeBlob(key);
|
|
1118
|
-
bufferLength += Buffer.byteLength(buffer);
|
|
1119
|
-
return (0, build_cache_1.deserialize)(buffer);
|
|
1120
|
-
}
|
|
1061
|
+
const buffer = await cache.getLargeBlob(key);
|
|
1062
|
+
bufferLength += Buffer.byteLength(buffer);
|
|
1063
|
+
return (0, build_cache_1.deserialize)(buffer);
|
|
1121
1064
|
};
|
|
1122
1065
|
let serializedRequestGraph = await getAndDeserialize(requestGraphKey);
|
|
1123
1066
|
let nodePromises = serializedRequestGraph.nodeCountsPerBlob.map(
|
|
@@ -1141,13 +1084,9 @@ async function loadRequestGraph(options) {
|
|
|
1141
1084
|
return new RequestGraph();
|
|
1142
1085
|
}
|
|
1143
1086
|
let cacheKey = getCacheKey(options);
|
|
1144
|
-
let requestGraphKey =
|
|
1145
|
-
? `${cacheKey}/RequestGraph`
|
|
1146
|
-
: `requestGraph-${cacheKey}`;
|
|
1087
|
+
let requestGraphKey = `requestGraph-${cacheKey}`;
|
|
1147
1088
|
let timeout;
|
|
1148
|
-
const snapshotKey =
|
|
1149
|
-
? `${cacheKey}/snapshot`
|
|
1150
|
-
: `snapshot-${cacheKey}`;
|
|
1089
|
+
const snapshotKey = `snapshot-${cacheKey}`;
|
|
1151
1090
|
const snapshotPath = path_1.default.join(options.cacheDir, snapshotKey + '.txt');
|
|
1152
1091
|
const commonMeta = {
|
|
1153
1092
|
cacheKey,
|
|
@@ -1170,9 +1109,7 @@ async function loadRequestGraph(options) {
|
|
|
1170
1109
|
if ((0, feature_flags_1.getFeatureFlag)('environmentDeduplication')) {
|
|
1171
1110
|
await (0, EnvironmentManager_1.loadEnvironmentsFromCache)(options.cache);
|
|
1172
1111
|
}
|
|
1173
|
-
const hasRequestGraphInCache =
|
|
1174
|
-
? await options.cache.has(requestGraphKey)
|
|
1175
|
-
: await options.cache.hasLargeBlob(requestGraphKey);
|
|
1112
|
+
const hasRequestGraphInCache = await options.cache.hasLargeBlob(requestGraphKey);
|
|
1176
1113
|
if (hasRequestGraphInCache) {
|
|
1177
1114
|
try {
|
|
1178
1115
|
let { requestGraph } = await readAndDeserializeRequestGraph(options.cache, requestGraphKey, cacheKey);
|
package/dist/UncommittedAsset.js
CHANGED
|
@@ -16,7 +16,6 @@ const assetUtils_1 = require("./assetUtils");
|
|
|
16
16
|
const types_1 = require("./types");
|
|
17
17
|
const utils_2 = require("./utils");
|
|
18
18
|
const projectPath_1 = require("./projectPath");
|
|
19
|
-
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
20
19
|
const EnvironmentManager_1 = require("./EnvironmentManager");
|
|
21
20
|
class UncommittedAsset {
|
|
22
21
|
constructor({ value, options, content, mapBuffer, ast, isASTDirty, code, invalidations, }) {
|
|
@@ -209,10 +208,6 @@ class UncommittedAsset {
|
|
|
209
208
|
this.value.astGenerator = null;
|
|
210
209
|
}
|
|
211
210
|
getCacheKey(key) {
|
|
212
|
-
if ((0, feature_flags_1.getFeatureFlag)('cachePerformanceImprovements')) {
|
|
213
|
-
const filePath = (0, projectPath_1.fromProjectPathRelative)(this.value.filePath);
|
|
214
|
-
return `Asset/${constants_1.ATLASPACK_VERSION}/${filePath}/${this.value.id}/${key}`;
|
|
215
|
-
}
|
|
216
211
|
return (0, rust_1.hashString)(constants_1.ATLASPACK_VERSION + key + this.value.id);
|
|
217
212
|
}
|
|
218
213
|
addDependency(opts) {
|
|
@@ -8,7 +8,6 @@ exports.default = createAssetGraphRequest;
|
|
|
8
8
|
const logger_1 = __importDefault(require("@atlaspack/logger"));
|
|
9
9
|
const assert_1 = __importDefault(require("assert"));
|
|
10
10
|
const nullthrows_1 = __importDefault(require("nullthrows"));
|
|
11
|
-
const feature_flags_1 = require("@atlaspack/feature-flags");
|
|
12
11
|
const utils_1 = require("@atlaspack/utils");
|
|
13
12
|
const rust_1 = require("@atlaspack/rust");
|
|
14
13
|
const diagnostic_1 = __importDefault(require("@atlaspack/diagnostic"));
|
|
@@ -77,14 +76,8 @@ class AssetGraphBuilder {
|
|
|
77
76
|
this.lazyIncludes = lazyIncludes ?? [];
|
|
78
77
|
this.lazyExcludes = lazyExcludes ?? [];
|
|
79
78
|
this.skipSymbolProp = input.skipSymbolProp ?? false;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.cacheKey = `AssetGraph/${constants_1.ATLASPACK_VERSION}/${options.mode}/${key}`;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
this.cacheKey =
|
|
86
|
-
(0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-AssetGraph';
|
|
87
|
-
}
|
|
79
|
+
this.cacheKey =
|
|
80
|
+
(0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-AssetGraph';
|
|
88
81
|
this.isSingleChangeRebuild =
|
|
89
82
|
api
|
|
90
83
|
.getInvalidSubRequests()
|
|
@@ -193,14 +193,8 @@ class BundlerRunner {
|
|
|
193
193
|
this.devDepRequests = new Map();
|
|
194
194
|
this.configs = new Map();
|
|
195
195
|
this.pluginOptions = new PluginOptions_1.default((0, utils_1.optionsProxy)(this.options, api.invalidateOnOptionChange));
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
this.cacheKey = `BundleGraph/${constants_1.ATLASPACK_VERSION}/${options.mode}/${key}`;
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
this.cacheKey =
|
|
202
|
-
(0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-BundleGraph';
|
|
203
|
-
}
|
|
196
|
+
this.cacheKey =
|
|
197
|
+
(0, rust_1.hashString)(`${constants_1.ATLASPACK_VERSION}:BundleGraph:${JSON.stringify(options.entries) ?? ''}${options.mode}${options.shouldBuildLazily ? 'lazy' : 'eager'}`) + '-BundleGraph';
|
|
204
198
|
}
|
|
205
199
|
async loadConfigs() {
|
|
206
200
|
// Load all configs up front so we can use them in the cache key
|
|
@@ -134,17 +134,13 @@ async function run({ input, options, api }) {
|
|
|
134
134
|
? []
|
|
135
135
|
: undefined;
|
|
136
136
|
await writeFiles(contentStream, info, hashRefToNameHash, options, config, outputFS, filePath, writeOptions, devDeps, api, bundleReplacements);
|
|
137
|
-
const hasSourceMap =
|
|
138
|
-
? await options.cache.hasLargeBlob(mapKey)
|
|
139
|
-
: await options.cache.has(mapKey);
|
|
137
|
+
const hasSourceMap = await options.cache.has(mapKey);
|
|
140
138
|
if (mapKey && env.sourceMap && !env.sourceMap.inline && hasSourceMap) {
|
|
141
139
|
let mapStream;
|
|
142
140
|
if ((0, feature_flags_1.getFeatureFlag)('fixSourceMapHashRefs') &&
|
|
143
141
|
bundleReplacements &&
|
|
144
142
|
bundleReplacements.length > 0) {
|
|
145
|
-
const mapEntry =
|
|
146
|
-
? await options.cache.getLargeBlob(mapKey)
|
|
147
|
-
: await options.cache.getBlob(mapKey);
|
|
143
|
+
const mapEntry = await options.cache.getBlob(mapKey);
|
|
148
144
|
const mapBuffer = Buffer.isBuffer(mapEntry)
|
|
149
145
|
? mapEntry
|
|
150
146
|
: Buffer.from(mapEntry);
|
|
@@ -161,9 +157,7 @@ async function run({ input, options, api }) {
|
|
|
161
157
|
mapStream = (0, utils_1.blobToStream)(Buffer.from(typeof mapJson === 'string' ? mapJson : JSON.stringify(mapJson), 'utf8'));
|
|
162
158
|
}
|
|
163
159
|
else {
|
|
164
|
-
const mapEntry =
|
|
165
|
-
? await options.cache.getLargeBlob(mapKey)
|
|
166
|
-
: await options.cache.getBlob(mapKey);
|
|
160
|
+
const mapEntry = await options.cache.getBlob(mapKey);
|
|
167
161
|
mapStream = (0, utils_1.blobToStream)(mapEntry);
|
|
168
162
|
}
|
|
169
163
|
await writeFiles(mapStream, info, hashRefToNameHash, options, config, outputFS, (0, projectPath_1.toProjectPathUnsafe)((0, projectPath_1.fromProjectPathRelative)(filePath) + '.map'), writeOptions, devDeps, api);
|
package/dist/resolveOptions.js
CHANGED
|
@@ -133,10 +133,8 @@ async function resolveOptions(initialOptions) {
|
|
|
133
133
|
return initialOptions.cache;
|
|
134
134
|
}
|
|
135
135
|
const needsRustLmdbCache = (0, feature_flags_1.getFeatureFlag)('atlaspackV3') || (0, feature_flags_1.getFeatureFlag)('nativePackager');
|
|
136
|
-
if (!(
|
|
137
|
-
|
|
138
|
-
return new cache_1.FSCache(outputFS, cacheDir);
|
|
139
|
-
}
|
|
136
|
+
if (!needsRustLmdbCache && !(outputFS instanceof fs_1.NodeFS)) {
|
|
137
|
+
return new cache_1.FSCache(outputFS, cacheDir);
|
|
140
138
|
}
|
|
141
139
|
return new cache_1.LMDBLiteCache(cacheDir);
|
|
142
140
|
}
|
package/lib/PackagerRunner.js
CHANGED
|
@@ -87,13 +87,6 @@ function _profiler() {
|
|
|
87
87
|
return data;
|
|
88
88
|
}
|
|
89
89
|
var _EnvironmentManager = require("./EnvironmentManager");
|
|
90
|
-
function _featureFlags() {
|
|
91
|
-
const data = require("@atlaspack/feature-flags");
|
|
92
|
-
_featureFlags = function () {
|
|
93
|
-
return data;
|
|
94
|
-
};
|
|
95
|
-
return data;
|
|
96
|
-
}
|
|
97
90
|
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); }
|
|
98
91
|
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; }
|
|
99
92
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -437,10 +430,6 @@ class PackagerRunner {
|
|
|
437
430
|
devDepHashes += await this.getDevDepHashes(inlineBundle);
|
|
438
431
|
}
|
|
439
432
|
let invalidationHash = await (0, _assetUtils.getInvalidationHash)(invalidations, this.options);
|
|
440
|
-
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
441
|
-
const hash = (0, _rust().hashString)(_constants.ATLASPACK_VERSION + devDepHashes + invalidationHash + bundle.target.publicUrl + bundleGraph.getHash(bundle) + JSON.stringify(configResults) + JSON.stringify(globalInfoResults) + this.options.mode + (this.options.shouldBuildLazily ? 'lazy' : 'eager'));
|
|
442
|
-
return _path().default.join(bundle.displayName ?? bundle.name ?? bundle.id, hash);
|
|
443
|
-
}
|
|
444
433
|
return (0, _rust().hashString)(_constants.ATLASPACK_VERSION + devDepHashes + invalidationHash + bundle.target.publicUrl + bundleGraph.getHash(bundle) + JSON.stringify(configResults) + JSON.stringify(globalInfoResults) + this.options.mode + (this.options.shouldBuildLazily ? 'lazy' : 'eager'));
|
|
445
434
|
}
|
|
446
435
|
async getDevDepHashes(bundle) {
|
|
@@ -464,14 +453,14 @@ class PackagerRunner {
|
|
|
464
453
|
let contentKey = PackagerRunner.getContentKey(cacheKey);
|
|
465
454
|
let mapKey = PackagerRunner.getMapKey(cacheKey);
|
|
466
455
|
let isLargeBlob = await this.options.cache.hasLargeBlob(contentKey);
|
|
467
|
-
let contentExists =
|
|
456
|
+
let contentExists = isLargeBlob || (await this.options.cache.has(contentKey));
|
|
468
457
|
if (!contentExists) {
|
|
469
458
|
return null;
|
|
470
459
|
}
|
|
471
|
-
let mapExists =
|
|
460
|
+
let mapExists = await this.options.cache.has(mapKey);
|
|
472
461
|
return {
|
|
473
462
|
contents: isLargeBlob ? this.options.cache.getStream(contentKey) : (0, _utils().blobToStream)(await this.options.cache.getBlob(contentKey)),
|
|
474
|
-
map: mapExists ? (0, _utils().blobToStream)(
|
|
463
|
+
map: mapExists ? (0, _utils().blobToStream)(await this.options.cache.getBlob(mapKey)) : null
|
|
475
464
|
};
|
|
476
465
|
}
|
|
477
466
|
async writeToCache(cacheKeys, type, contents, map) {
|
|
@@ -479,13 +468,11 @@ class PackagerRunner {
|
|
|
479
468
|
let hash;
|
|
480
469
|
// @ts-expect-error TS2702
|
|
481
470
|
let hashReferences = [];
|
|
482
|
-
let isLargeBlob =
|
|
471
|
+
let isLargeBlob = false;
|
|
483
472
|
|
|
484
473
|
// TODO: don't replace hash references in binary files??
|
|
485
474
|
if (contents instanceof _stream().Readable) {
|
|
486
|
-
|
|
487
|
-
isLargeBlob = true;
|
|
488
|
-
}
|
|
475
|
+
isLargeBlob = true;
|
|
489
476
|
let boundaryStr = '';
|
|
490
477
|
let h = new (_rust().Hash)();
|
|
491
478
|
await this.options.cache.setStream(cacheKeys.content, (0, _utils().blobToStream)(contents).pipe(
|
|
@@ -503,27 +490,15 @@ class PackagerRunner {
|
|
|
503
490
|
size = buffer.byteLength;
|
|
504
491
|
hash = (0, _rust().hashBuffer)(buffer);
|
|
505
492
|
hashReferences = contents.match(_constants.HASH_REF_REGEX) ?? [];
|
|
506
|
-
|
|
507
|
-
await this.options.cache.setLargeBlob(cacheKeys.content, buffer);
|
|
508
|
-
} else {
|
|
509
|
-
await this.options.cache.setBlob(cacheKeys.content, buffer);
|
|
510
|
-
}
|
|
493
|
+
await this.options.cache.setBlob(cacheKeys.content, buffer);
|
|
511
494
|
} else {
|
|
512
495
|
size = contents.length;
|
|
513
496
|
hash = (0, _rust().hashBuffer)(contents);
|
|
514
497
|
hashReferences = contents.toString().match(_constants.HASH_REF_REGEX) ?? [];
|
|
515
|
-
|
|
516
|
-
await this.options.cache.setLargeBlob(cacheKeys.content, contents);
|
|
517
|
-
} else {
|
|
518
|
-
await this.options.cache.setBlob(cacheKeys.content, contents);
|
|
519
|
-
}
|
|
498
|
+
await this.options.cache.setBlob(cacheKeys.content, contents);
|
|
520
499
|
}
|
|
521
500
|
if (map != null) {
|
|
522
|
-
|
|
523
|
-
await this.options.cache.setLargeBlob(cacheKeys.map, map);
|
|
524
|
-
} else {
|
|
525
|
-
await this.options.cache.setBlob(cacheKeys.map, map);
|
|
526
|
-
}
|
|
501
|
+
await this.options.cache.setBlob(cacheKeys.map, map);
|
|
527
502
|
}
|
|
528
503
|
let info = {
|
|
529
504
|
type,
|
|
@@ -537,21 +512,12 @@ class PackagerRunner {
|
|
|
537
512
|
return info;
|
|
538
513
|
}
|
|
539
514
|
static getContentKey(cacheKey) {
|
|
540
|
-
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
541
|
-
return `PackagerRunner/${_constants.ATLASPACK_VERSION}/${cacheKey}/content`;
|
|
542
|
-
}
|
|
543
515
|
return (0, _rust().hashString)(`${cacheKey}:content`);
|
|
544
516
|
}
|
|
545
517
|
static getMapKey(cacheKey) {
|
|
546
|
-
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
547
|
-
return `PackagerRunner/${_constants.ATLASPACK_VERSION}/${cacheKey}/map`;
|
|
548
|
-
}
|
|
549
518
|
return (0, _rust().hashString)(`${cacheKey}:map`);
|
|
550
519
|
}
|
|
551
520
|
static getInfoKey(cacheKey) {
|
|
552
|
-
if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
|
|
553
|
-
return `PackagerRunner/${_constants.ATLASPACK_VERSION}/${cacheKey}/info`;
|
|
554
|
-
}
|
|
555
521
|
return (0, _rust().hashString)(`${cacheKey}:info`);
|
|
556
522
|
}
|
|
557
523
|
}
|