@atlaspack/core 2.33.1 → 2.35.0
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 +72 -0
- package/dist/AssetGraph.js +4 -72
- package/dist/BundleGraph.js +34 -0
- package/dist/PackagerRunner.js +13 -88
- package/dist/RequestTracker.js +17 -80
- package/dist/TargetDescriptor.schema.js +3 -0
- package/dist/UncommittedAsset.js +0 -5
- package/dist/applyRuntimes.js +2 -1
- package/dist/atlaspack-v3/AtlaspackV3.js +6 -2
- package/dist/requests/AssetGraphRequest.js +6 -15
- package/dist/requests/AssetGraphRequestRust.js +119 -22
- package/dist/requests/AtlaspackBuildRequest.js +8 -2
- package/dist/requests/BundleGraphRequest.js +9 -15
- package/dist/requests/BundleGraphRequestRust.js +1 -2
- package/dist/requests/PackageRequest.js +1 -1
- package/dist/requests/TargetRequest.js +5 -0
- package/dist/requests/WriteBundleRequest.js +129 -12
- package/dist/requests/WriteBundlesRequest.js +15 -9
- package/dist/resolveOptions.js +2 -4
- package/lib/AssetGraph.js +3 -62
- package/lib/BundleGraph.js +38 -0
- package/lib/PackagerRunner.js +13 -77
- package/lib/RequestTracker.js +15 -69
- package/lib/TargetDescriptor.schema.js +3 -0
- package/lib/UncommittedAsset.js +0 -11
- package/lib/applyRuntimes.js +1 -1
- package/lib/atlaspack-v3/AtlaspackV3.js +6 -2
- package/lib/requests/AssetGraphRequest.js +4 -18
- package/lib/requests/AssetGraphRequestRust.js +88 -23
- package/lib/requests/AtlaspackBuildRequest.js +8 -2
- package/lib/requests/BundleGraphRequest.js +12 -16
- package/lib/requests/BundleGraphRequestRust.js +2 -3
- package/lib/requests/PackageRequest.js +3 -1
- package/lib/requests/TargetRequest.js +5 -0
- package/lib/requests/WriteBundleRequest.js +131 -8
- package/lib/requests/WriteBundlesRequest.js +12 -5
- package/lib/resolveOptions.js +2 -4
- package/lib/types/AssetGraph.d.ts +2 -27
- package/lib/types/BundleGraph.d.ts +5 -0
- package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +3 -2
- package/lib/types/requests/BundleGraphRequest.d.ts +1 -1
- package/lib/types/requests/WriteBundleRequest.d.ts +20 -1
- package/lib/types/types.d.ts +1 -0
- package/package.json +15 -15
- package/src/AssetGraph.ts +4 -72
- package/src/BundleGraph.ts +39 -0
- package/src/PackagerRunner.ts +15 -101
- package/src/RequestTracker.ts +24 -110
- package/src/TargetDescriptor.schema.ts +3 -0
- package/src/UncommittedAsset.ts +1 -11
- package/src/applyRuntimes.ts +3 -1
- package/src/atlaspack-v3/AtlaspackV3.ts +19 -3
- package/src/requests/AssetGraphRequest.ts +8 -20
- package/src/requests/AssetGraphRequestRust.ts +96 -23
- package/src/requests/AtlaspackBuildRequest.ts +16 -8
- package/src/requests/BundleGraphRequest.ts +12 -30
- package/src/requests/BundleGraphRequestRust.ts +1 -2
- package/src/requests/PackageRequest.ts +1 -1
- package/src/requests/TargetRequest.ts +5 -0
- package/src/requests/WriteBundleRequest.ts +177 -13
- package/src/requests/WriteBundlesRequest.ts +25 -13
- package/src/resolveOptions.ts +2 -4
- package/src/types.ts +1 -0
- package/test/AssetGraph.test.ts +0 -32
- package/test/RequestTracker.test.ts +0 -165
- package/test/TargetRequest.test.ts +25 -0
- package/test/requests/WriteBundleRequest.test.ts +239 -0
- package/tsconfig.tsbuildinfo +1 -1
package/src/PackagerRunner.ts
CHANGED
|
@@ -30,7 +30,6 @@ import ThrowableDiagnostic, {errorToDiagnostic} from '@atlaspack/diagnostic';
|
|
|
30
30
|
import {Readable} from 'stream';
|
|
31
31
|
import nullthrows from 'nullthrows';
|
|
32
32
|
import path from 'path';
|
|
33
|
-
import url from 'url';
|
|
34
33
|
import {hashString, hashBuffer, Hash} from '@atlaspack/rust';
|
|
35
34
|
|
|
36
35
|
import {NamedBundle, bundleToInternalBundle} from './public/Bundle';
|
|
@@ -60,9 +59,9 @@ import {
|
|
|
60
59
|
import {getInvalidationId, getInvalidationHash} from './assetUtils';
|
|
61
60
|
import {optionsProxy} from './utils';
|
|
62
61
|
import {invalidateDevDeps} from './requests/DevDepRequest';
|
|
62
|
+
import {computeSourceMapRoot} from './requests/WriteBundleRequest';
|
|
63
63
|
import {tracer, PluginTracer} from '@atlaspack/profiler';
|
|
64
64
|
import {fromEnvironmentId} from './EnvironmentManager';
|
|
65
|
-
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
66
65
|
|
|
67
66
|
type Opts = {
|
|
68
67
|
config: AtlaspackConfig;
|
|
@@ -590,64 +589,24 @@ export default class PackagerRunner {
|
|
|
590
589
|
bundle: InternalBundle,
|
|
591
590
|
map: SourceMap,
|
|
592
591
|
): Promise<string> {
|
|
593
|
-
|
|
592
|
+
let sourceRoot = computeSourceMapRoot(bundle, this.options);
|
|
593
|
+
let inlineSources = sourceRoot === undefined;
|
|
594
|
+
|
|
594
595
|
let filePath = joinProjectPath(
|
|
595
596
|
bundle.target.distDir,
|
|
596
597
|
nullthrows(bundle.name),
|
|
597
598
|
);
|
|
598
599
|
let fullPath = fromProjectPath(this.options.projectRoot, filePath);
|
|
599
|
-
let
|
|
600
|
-
path.dirname(fullPath),
|
|
601
|
-
this.options.projectRoot,
|
|
602
|
-
);
|
|
603
|
-
let inlineSources = false;
|
|
600
|
+
let mapFilename = fullPath + '.map';
|
|
604
601
|
|
|
605
602
|
const bundleEnv = fromEnvironmentId(bundle.env);
|
|
606
|
-
if (bundle.target) {
|
|
607
|
-
const bundleTargetEnv = fromEnvironmentId(bundle.target.env);
|
|
608
|
-
|
|
609
|
-
if (bundleEnv.sourceMap && bundleEnv.sourceMap.sourceRoot !== undefined) {
|
|
610
|
-
sourceRoot = bundleEnv.sourceMap.sourceRoot;
|
|
611
|
-
} else if (
|
|
612
|
-
this.options.serveOptions &&
|
|
613
|
-
bundleTargetEnv.context === 'browser'
|
|
614
|
-
) {
|
|
615
|
-
sourceRoot = '/__parcel_source_root';
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
if (
|
|
619
|
-
bundleEnv.sourceMap &&
|
|
620
|
-
bundleEnv.sourceMap.inlineSources !== undefined
|
|
621
|
-
) {
|
|
622
|
-
inlineSources = bundleEnv.sourceMap.inlineSources;
|
|
623
|
-
} else if (bundleTargetEnv.context !== 'node') {
|
|
624
|
-
// inlining should only happen in production for browser targets by default
|
|
625
|
-
inlineSources = this.options.mode === 'production';
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
let mapFilename = fullPath + '.map';
|
|
630
603
|
let isInlineMap = bundleEnv.sourceMap && bundleEnv.sourceMap.inline;
|
|
631
604
|
|
|
632
|
-
if (getFeatureFlag('omitSourcesContentInMemory') && !isInlineMap) {
|
|
633
|
-
if (
|
|
634
|
-
!(bundleEnv.sourceMap && bundleEnv.sourceMap.inlineSources === false)
|
|
635
|
-
) {
|
|
636
|
-
/*
|
|
637
|
-
We're omitting sourcesContent during transformation to allow GC to run.
|
|
638
|
-
Ensure sources are still inlined into the final source maps written to disk. UNLESS the user explicitly disabled inlineSources.
|
|
639
|
-
*/
|
|
640
|
-
inlineSources = true;
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
|
|
644
605
|
let stringified = await map.stringify({
|
|
645
606
|
file: path.basename(mapFilename),
|
|
646
607
|
fs: this.options.inputFS,
|
|
647
608
|
rootDir: this.options.projectRoot,
|
|
648
|
-
sourceRoot
|
|
649
|
-
? url.format(url.parse(sourceRoot + '/'))
|
|
650
|
-
: undefined,
|
|
609
|
+
sourceRoot,
|
|
651
610
|
inlineSources,
|
|
652
611
|
format: isInlineMap ? 'inline' : 'string',
|
|
653
612
|
});
|
|
@@ -694,21 +653,6 @@ export default class PackagerRunner {
|
|
|
694
653
|
this.options,
|
|
695
654
|
);
|
|
696
655
|
|
|
697
|
-
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
698
|
-
const hash = hashString(
|
|
699
|
-
ATLASPACK_VERSION +
|
|
700
|
-
devDepHashes +
|
|
701
|
-
invalidationHash +
|
|
702
|
-
bundle.target.publicUrl +
|
|
703
|
-
bundleGraph.getHash(bundle) +
|
|
704
|
-
JSON.stringify(configResults) +
|
|
705
|
-
JSON.stringify(globalInfoResults) +
|
|
706
|
-
this.options.mode +
|
|
707
|
-
(this.options.shouldBuildLazily ? 'lazy' : 'eager'),
|
|
708
|
-
);
|
|
709
|
-
return path.join(bundle.displayName ?? bundle.name ?? bundle.id, hash);
|
|
710
|
-
}
|
|
711
|
-
|
|
712
656
|
return hashString(
|
|
713
657
|
ATLASPACK_VERSION +
|
|
714
658
|
devDepHashes +
|
|
@@ -755,27 +699,20 @@ export default class PackagerRunner {
|
|
|
755
699
|
let mapKey = PackagerRunner.getMapKey(cacheKey);
|
|
756
700
|
|
|
757
701
|
let isLargeBlob = await this.options.cache.hasLargeBlob(contentKey);
|
|
758
|
-
let contentExists =
|
|
759
|
-
|
|
760
|
-
: isLargeBlob || (await this.options.cache.has(contentKey));
|
|
702
|
+
let contentExists =
|
|
703
|
+
isLargeBlob || (await this.options.cache.has(contentKey));
|
|
761
704
|
if (!contentExists) {
|
|
762
705
|
return null;
|
|
763
706
|
}
|
|
764
707
|
|
|
765
|
-
let mapExists =
|
|
766
|
-
? await this.options.cache.hasLargeBlob(mapKey)
|
|
767
|
-
: await this.options.cache.has(mapKey);
|
|
708
|
+
let mapExists = await this.options.cache.has(mapKey);
|
|
768
709
|
|
|
769
710
|
return {
|
|
770
711
|
contents: isLargeBlob
|
|
771
712
|
? this.options.cache.getStream(contentKey)
|
|
772
713
|
: blobToStream(await this.options.cache.getBlob(contentKey)),
|
|
773
714
|
map: mapExists
|
|
774
|
-
? blobToStream(
|
|
775
|
-
getFeatureFlag('cachePerformanceImprovements')
|
|
776
|
-
? await this.options.cache.getLargeBlob(mapKey)
|
|
777
|
-
: await this.options.cache.getBlob(mapKey),
|
|
778
|
-
)
|
|
715
|
+
? blobToStream(await this.options.cache.getBlob(mapKey))
|
|
779
716
|
: null,
|
|
780
717
|
};
|
|
781
718
|
}
|
|
@@ -790,13 +727,11 @@ export default class PackagerRunner {
|
|
|
790
727
|
let hash;
|
|
791
728
|
// @ts-expect-error TS2702
|
|
792
729
|
let hashReferences: RegExp.matchResult | Array<string> = [];
|
|
793
|
-
let isLargeBlob =
|
|
730
|
+
let isLargeBlob = false;
|
|
794
731
|
|
|
795
732
|
// TODO: don't replace hash references in binary files??
|
|
796
733
|
if (contents instanceof Readable) {
|
|
797
|
-
|
|
798
|
-
isLargeBlob = true;
|
|
799
|
-
}
|
|
734
|
+
isLargeBlob = true;
|
|
800
735
|
|
|
801
736
|
let boundaryStr = '';
|
|
802
737
|
let h = new Hash();
|
|
@@ -822,29 +757,17 @@ export default class PackagerRunner {
|
|
|
822
757
|
hash = hashBuffer(buffer);
|
|
823
758
|
hashReferences = contents.match(HASH_REF_REGEX) ?? [];
|
|
824
759
|
|
|
825
|
-
|
|
826
|
-
await this.options.cache.setLargeBlob(cacheKeys.content, buffer);
|
|
827
|
-
} else {
|
|
828
|
-
await this.options.cache.setBlob(cacheKeys.content, buffer);
|
|
829
|
-
}
|
|
760
|
+
await this.options.cache.setBlob(cacheKeys.content, buffer);
|
|
830
761
|
} else {
|
|
831
762
|
size = contents.length;
|
|
832
763
|
hash = hashBuffer(contents);
|
|
833
764
|
hashReferences = contents.toString().match(HASH_REF_REGEX) ?? [];
|
|
834
765
|
|
|
835
|
-
|
|
836
|
-
await this.options.cache.setLargeBlob(cacheKeys.content, contents);
|
|
837
|
-
} else {
|
|
838
|
-
await this.options.cache.setBlob(cacheKeys.content, contents);
|
|
839
|
-
}
|
|
766
|
+
await this.options.cache.setBlob(cacheKeys.content, contents);
|
|
840
767
|
}
|
|
841
768
|
|
|
842
769
|
if (map != null) {
|
|
843
|
-
|
|
844
|
-
await this.options.cache.setLargeBlob(cacheKeys.map, map);
|
|
845
|
-
} else {
|
|
846
|
-
await this.options.cache.setBlob(cacheKeys.map, map);
|
|
847
|
-
}
|
|
770
|
+
await this.options.cache.setBlob(cacheKeys.map, map);
|
|
848
771
|
}
|
|
849
772
|
|
|
850
773
|
let info = {
|
|
@@ -861,23 +784,14 @@ export default class PackagerRunner {
|
|
|
861
784
|
}
|
|
862
785
|
|
|
863
786
|
static getContentKey(cacheKey: string): string {
|
|
864
|
-
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
865
|
-
return `PackagerRunner/${ATLASPACK_VERSION}/${cacheKey}/content`;
|
|
866
|
-
}
|
|
867
787
|
return hashString(`${cacheKey}:content`);
|
|
868
788
|
}
|
|
869
789
|
|
|
870
790
|
static getMapKey(cacheKey: string): string {
|
|
871
|
-
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
872
|
-
return `PackagerRunner/${ATLASPACK_VERSION}/${cacheKey}/map`;
|
|
873
|
-
}
|
|
874
791
|
return hashString(`${cacheKey}:map`);
|
|
875
792
|
}
|
|
876
793
|
|
|
877
794
|
static getInfoKey(cacheKey: string): string {
|
|
878
|
-
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
879
|
-
return `PackagerRunner/${ATLASPACK_VERSION}/${cacheKey}/info`;
|
|
880
|
-
}
|
|
881
795
|
return hashString(`${cacheKey}:info`);
|
|
882
796
|
}
|
|
883
797
|
}
|
package/src/RequestTracker.ts
CHANGED
|
@@ -2,7 +2,7 @@ import invariant, {AssertionError} from 'assert';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
|
|
4
4
|
import {deserialize, serialize} from '@atlaspack/build-cache';
|
|
5
|
-
import {
|
|
5
|
+
import {Cache} from '@atlaspack/cache';
|
|
6
6
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
7
7
|
import {ContentGraph} from '@atlaspack/graph';
|
|
8
8
|
import type {
|
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
SerializedContentGraph,
|
|
13
13
|
Graph,
|
|
14
14
|
} from '@atlaspack/graph';
|
|
15
|
-
import logger
|
|
15
|
+
import logger from '@atlaspack/logger';
|
|
16
16
|
import {hashString} from '@atlaspack/rust';
|
|
17
17
|
import type {Async, EnvMap} from '@atlaspack/types';
|
|
18
18
|
import {
|
|
@@ -1315,13 +1315,11 @@ export default class RequestTracker {
|
|
|
1315
1315
|
return result;
|
|
1316
1316
|
} else if (node.resultCacheKey != null && ifMatch == null) {
|
|
1317
1317
|
let key = node.resultCacheKey;
|
|
1318
|
-
|
|
1319
|
-
invariant(this.options.cache.hasLargeBlob(key));
|
|
1320
|
-
}
|
|
1318
|
+
invariant(this.options.cache.hasLargeBlob(key));
|
|
1321
1319
|
|
|
1322
|
-
let cachedResult: T =
|
|
1323
|
-
|
|
1324
|
-
|
|
1320
|
+
let cachedResult: T = deserialize(
|
|
1321
|
+
await this.options.cache.getLargeBlob(key),
|
|
1322
|
+
);
|
|
1325
1323
|
node.result = cachedResult;
|
|
1326
1324
|
return cachedResult;
|
|
1327
1325
|
}
|
|
@@ -1559,40 +1557,15 @@ export default class RequestTracker {
|
|
|
1559
1557
|
}
|
|
1560
1558
|
|
|
1561
1559
|
async writeToCache(signal?: AbortSignal) {
|
|
1562
|
-
const options = this.options;
|
|
1563
|
-
async function runCacheImprovements<T>(
|
|
1564
|
-
newPath: (cache: LMDBLiteCache) => Promise<T>,
|
|
1565
|
-
oldPath: () => Promise<T>,
|
|
1566
|
-
): Promise<T> {
|
|
1567
|
-
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
1568
|
-
invariant(options.cache instanceof LMDBLiteCache);
|
|
1569
|
-
const result = await newPath(options.cache);
|
|
1570
|
-
return result;
|
|
1571
|
-
} else {
|
|
1572
|
-
const result = await oldPath();
|
|
1573
|
-
return result;
|
|
1574
|
-
}
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
1560
|
let cacheKey = getCacheKey(this.options);
|
|
1578
|
-
let requestGraphKey =
|
|
1579
|
-
|
|
1580
|
-
: `requestGraph-${cacheKey}`;
|
|
1581
|
-
let snapshotKey = getFeatureFlag('cachePerformanceImprovements')
|
|
1582
|
-
? `${cacheKey}/snapshot`
|
|
1583
|
-
: `snapshot-${cacheKey}`;
|
|
1561
|
+
let requestGraphKey = `requestGraph-${cacheKey}`;
|
|
1562
|
+
let snapshotKey = `snapshot-${cacheKey}`;
|
|
1584
1563
|
|
|
1585
1564
|
if (this.options.shouldDisableCache) {
|
|
1586
1565
|
return;
|
|
1587
1566
|
}
|
|
1588
1567
|
|
|
1589
1568
|
let total = 0;
|
|
1590
|
-
await runCacheImprovements(
|
|
1591
|
-
async (cache) => {
|
|
1592
|
-
await cache.getNativeRef().startWriteTransaction();
|
|
1593
|
-
},
|
|
1594
|
-
() => Promise.resolve(),
|
|
1595
|
-
);
|
|
1596
1569
|
try {
|
|
1597
1570
|
report({
|
|
1598
1571
|
type: 'cache',
|
|
@@ -1602,7 +1575,7 @@ export default class RequestTracker {
|
|
|
1602
1575
|
});
|
|
1603
1576
|
|
|
1604
1577
|
if (getFeatureFlag('environmentDeduplication')) {
|
|
1605
|
-
await writeEnvironmentsToCache(options.cache);
|
|
1578
|
+
await writeEnvironmentsToCache(this.options.cache);
|
|
1606
1579
|
}
|
|
1607
1580
|
|
|
1608
1581
|
let serialisedGraph = this.graph.serialize();
|
|
@@ -1618,27 +1591,14 @@ export default class RequestTracker {
|
|
|
1618
1591
|
throw new Error('Serialization was aborted');
|
|
1619
1592
|
}
|
|
1620
1593
|
|
|
1621
|
-
await
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
return Promise.resolve();
|
|
1630
|
-
},
|
|
1631
|
-
async () => {
|
|
1632
|
-
await this.options.cache.setLargeBlob(
|
|
1633
|
-
key,
|
|
1634
|
-
serialize(contents),
|
|
1635
|
-
signal
|
|
1636
|
-
? {
|
|
1637
|
-
signal: signal,
|
|
1638
|
-
}
|
|
1639
|
-
: undefined,
|
|
1640
|
-
);
|
|
1641
|
-
},
|
|
1594
|
+
await this.options.cache.setLargeBlob(
|
|
1595
|
+
key,
|
|
1596
|
+
serialize(contents),
|
|
1597
|
+
signal
|
|
1598
|
+
? {
|
|
1599
|
+
signal: signal,
|
|
1600
|
+
}
|
|
1601
|
+
: undefined,
|
|
1642
1602
|
);
|
|
1643
1603
|
|
|
1644
1604
|
total += 1;
|
|
@@ -1720,18 +1680,6 @@ export default class RequestTracker {
|
|
|
1720
1680
|
nodes: undefined,
|
|
1721
1681
|
});
|
|
1722
1682
|
|
|
1723
|
-
await runCacheImprovements(
|
|
1724
|
-
() =>
|
|
1725
|
-
serialiseAndSet(`${cacheKey}/cache_metadata`, {
|
|
1726
|
-
version: ATLASPACK_VERSION,
|
|
1727
|
-
entries: this.options.entries,
|
|
1728
|
-
mode: this.options.mode,
|
|
1729
|
-
shouldBuildLazily: this.options.shouldBuildLazily,
|
|
1730
|
-
watchBackend: this.options.watchBackend,
|
|
1731
|
-
}),
|
|
1732
|
-
() => Promise.resolve(),
|
|
1733
|
-
);
|
|
1734
|
-
|
|
1735
1683
|
let opts = getWatcherOptions(this.options);
|
|
1736
1684
|
let snapshotPath = path.join(this.options.cacheDir, snapshotKey + '.txt');
|
|
1737
1685
|
|
|
@@ -1743,13 +1691,6 @@ export default class RequestTracker {
|
|
|
1743
1691
|
} catch (err: any) {
|
|
1744
1692
|
// If we have aborted, ignore the error and continue
|
|
1745
1693
|
if (!signal?.aborted) throw err;
|
|
1746
|
-
} finally {
|
|
1747
|
-
await runCacheImprovements(
|
|
1748
|
-
async (cache) => {
|
|
1749
|
-
await cache.getNativeRef().commitWriteTransaction();
|
|
1750
|
-
},
|
|
1751
|
-
() => Promise.resolve(),
|
|
1752
|
-
);
|
|
1753
1694
|
}
|
|
1754
1695
|
|
|
1755
1696
|
report({type: 'cache', phase: 'end', total, size: this.graph.nodes.length});
|
|
@@ -1783,18 +1724,6 @@ export function getWatcherOptions({
|
|
|
1783
1724
|
}
|
|
1784
1725
|
|
|
1785
1726
|
function getCacheKey(options: AtlaspackOptions) {
|
|
1786
|
-
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
1787
|
-
const hash = hashString(
|
|
1788
|
-
`${ATLASPACK_VERSION}:${JSON.stringify(options.entries)}:${
|
|
1789
|
-
options.mode
|
|
1790
|
-
}:${options.shouldBuildLazily ? 'lazy' : 'eager'}:${
|
|
1791
|
-
options.watchBackend ?? ''
|
|
1792
|
-
}`,
|
|
1793
|
-
);
|
|
1794
|
-
|
|
1795
|
-
return `RequestTracker/${ATLASPACK_VERSION}/${hash}`;
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
1727
|
return hashString(
|
|
1799
1728
|
`${ATLASPACK_VERSION}:${JSON.stringify(options.entries)}:${options.mode}:${
|
|
1800
1729
|
options.shouldBuildLazily ? 'lazy' : 'eager'
|
|
@@ -1803,10 +1732,6 @@ function getCacheKey(options: AtlaspackOptions) {
|
|
|
1803
1732
|
}
|
|
1804
1733
|
|
|
1805
1734
|
function getRequestGraphNodeKey(index: number, cacheKey: string) {
|
|
1806
|
-
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
1807
|
-
return `${cacheKey}/RequestGraph/nodes/${index}`;
|
|
1808
|
-
}
|
|
1809
|
-
|
|
1810
1735
|
return `requestGraph-nodes-${index}-${cacheKey}`;
|
|
1811
1736
|
}
|
|
1812
1737
|
|
|
@@ -1823,15 +1748,9 @@ export async function readAndDeserializeRequestGraph(
|
|
|
1823
1748
|
let bufferLength = 0;
|
|
1824
1749
|
|
|
1825
1750
|
const getAndDeserialize = async (key: string) => {
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
return deserialize(buffer);
|
|
1830
|
-
} else {
|
|
1831
|
-
const buffer = await cache.getLargeBlob(key);
|
|
1832
|
-
bufferLength += Buffer.byteLength(buffer);
|
|
1833
|
-
return deserialize(buffer);
|
|
1834
|
-
}
|
|
1751
|
+
const buffer = await cache.getLargeBlob(key);
|
|
1752
|
+
bufferLength += Buffer.byteLength(buffer);
|
|
1753
|
+
return deserialize(buffer);
|
|
1835
1754
|
};
|
|
1836
1755
|
|
|
1837
1756
|
let serializedRequestGraph = await getAndDeserialize(requestGraphKey);
|
|
@@ -1867,14 +1786,10 @@ async function loadRequestGraph(
|
|
|
1867
1786
|
}
|
|
1868
1787
|
|
|
1869
1788
|
let cacheKey = getCacheKey(options);
|
|
1870
|
-
let requestGraphKey =
|
|
1871
|
-
? `${cacheKey}/RequestGraph`
|
|
1872
|
-
: `requestGraph-${cacheKey}`;
|
|
1789
|
+
let requestGraphKey = `requestGraph-${cacheKey}`;
|
|
1873
1790
|
|
|
1874
1791
|
let timeout;
|
|
1875
|
-
const snapshotKey =
|
|
1876
|
-
? `${cacheKey}/snapshot`
|
|
1877
|
-
: `snapshot-${cacheKey}`;
|
|
1792
|
+
const snapshotKey = `snapshot-${cacheKey}`;
|
|
1878
1793
|
const snapshotPath = path.join(options.cacheDir, snapshotKey + '.txt');
|
|
1879
1794
|
|
|
1880
1795
|
const commonMeta = {
|
|
@@ -1901,9 +1816,8 @@ async function loadRequestGraph(
|
|
|
1901
1816
|
await loadEnvironmentsFromCache(options.cache);
|
|
1902
1817
|
}
|
|
1903
1818
|
|
|
1904
|
-
const hasRequestGraphInCache =
|
|
1905
|
-
|
|
1906
|
-
: await options.cache.hasLargeBlob(requestGraphKey);
|
|
1819
|
+
const hasRequestGraphInCache =
|
|
1820
|
+
await options.cache.hasLargeBlob(requestGraphKey);
|
|
1907
1821
|
|
|
1908
1822
|
if (hasRequestGraphInCache) {
|
|
1909
1823
|
try {
|
package/src/UncommittedAsset.ts
CHANGED
|
@@ -28,12 +28,7 @@ import {ATLASPACK_VERSION} from './constants';
|
|
|
28
28
|
import {createAsset, createAssetIdFromOptions} from './assetUtils';
|
|
29
29
|
import {BundleBehaviorNames} from './types';
|
|
30
30
|
import {invalidateOnFileCreateToInternal, createInvalidations} from './utils';
|
|
31
|
-
import {
|
|
32
|
-
ProjectPath,
|
|
33
|
-
fromProjectPath,
|
|
34
|
-
fromProjectPathRelative,
|
|
35
|
-
} from './projectPath';
|
|
36
|
-
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
31
|
+
import {ProjectPath, fromProjectPath} from './projectPath';
|
|
37
32
|
import {fromEnvironmentId} from './EnvironmentManager';
|
|
38
33
|
|
|
39
34
|
type UncommittedAssetOptions = {
|
|
@@ -308,11 +303,6 @@ export default class UncommittedAsset {
|
|
|
308
303
|
}
|
|
309
304
|
|
|
310
305
|
getCacheKey(key: string): string {
|
|
311
|
-
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
312
|
-
const filePath = fromProjectPathRelative(this.value.filePath);
|
|
313
|
-
return `Asset/${ATLASPACK_VERSION}/${filePath}/${this.value.id}/${key}`;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
306
|
return hashString(ATLASPACK_VERSION + key + this.value.id);
|
|
317
307
|
}
|
|
318
308
|
|
package/src/applyRuntimes.ts
CHANGED
|
@@ -505,7 +505,9 @@ function reconcileNewRuntimes<TResult extends RequestResult>(
|
|
|
505
505
|
name: 'Runtimes',
|
|
506
506
|
assetGroups,
|
|
507
507
|
optionsRef,
|
|
508
|
-
skipSymbolProp:
|
|
508
|
+
skipSymbolProp:
|
|
509
|
+
getFeatureFlag('skipRuntimeSymbolProp') ||
|
|
510
|
+
getFeatureFlag('rustSymbolTracker'),
|
|
509
511
|
});
|
|
510
512
|
|
|
511
513
|
// rebuild the graph
|
|
@@ -6,10 +6,12 @@ import {
|
|
|
6
6
|
atlaspackNapiCompleteSession,
|
|
7
7
|
atlaspackNapiLoadBundleGraph,
|
|
8
8
|
atlaspackNapiPackage,
|
|
9
|
+
atlaspackNapiUpdateBundleGraph,
|
|
9
10
|
AtlaspackNapi,
|
|
10
11
|
Lmdb,
|
|
11
12
|
AtlaspackNapiOptions,
|
|
12
13
|
CacheStats,
|
|
14
|
+
PackageOptions,
|
|
13
15
|
} from '@atlaspack/rust';
|
|
14
16
|
import {NapiWorkerPool} from './NapiWorkerPool';
|
|
15
17
|
import ThrowableDiagnostic, {Diagnostic} from '@atlaspack/diagnostic';
|
|
@@ -119,12 +121,26 @@ export class AtlaspackV3 {
|
|
|
119
121
|
) as Promise<void>;
|
|
120
122
|
}
|
|
121
123
|
|
|
124
|
+
updateBundleGraph(
|
|
125
|
+
bundleGraph: BundleGraph,
|
|
126
|
+
changedAssetIds: string[],
|
|
127
|
+
): Promise<void> {
|
|
128
|
+
const nodesJson = bundleGraph.serializeAssetNodesForNative(changedAssetIds);
|
|
129
|
+
return atlaspackNapiUpdateBundleGraph(
|
|
130
|
+
this._atlaspack_napi,
|
|
131
|
+
nodesJson,
|
|
132
|
+
) as Promise<void>;
|
|
133
|
+
}
|
|
134
|
+
|
|
122
135
|
package(
|
|
123
136
|
bundleId: string,
|
|
137
|
+
options?: PackageOptions,
|
|
124
138
|
): Promise<[RunPackagerRunnerResult, Diagnostic | null]> {
|
|
125
|
-
return atlaspackNapiPackage(
|
|
126
|
-
|
|
127
|
-
|
|
139
|
+
return atlaspackNapiPackage(
|
|
140
|
+
this._atlaspack_napi,
|
|
141
|
+
bundleId,
|
|
142
|
+
options,
|
|
143
|
+
) as Promise<[RunPackagerRunnerResult, Diagnostic | null]>;
|
|
128
144
|
}
|
|
129
145
|
|
|
130
146
|
async respondToFsEvents(events: Array<Event>): Promise<boolean> {
|
|
@@ -18,7 +18,6 @@ import logger from '@atlaspack/logger';
|
|
|
18
18
|
|
|
19
19
|
import invariant from 'assert';
|
|
20
20
|
import nullthrows from 'nullthrows';
|
|
21
|
-
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
22
21
|
import {PromiseQueue, setEqual} from '@atlaspack/utils';
|
|
23
22
|
import {hashString} from '@atlaspack/rust';
|
|
24
23
|
import ThrowableDiagnostic from '@atlaspack/diagnostic';
|
|
@@ -85,10 +84,12 @@ export default function createAssetGraphRequest(
|
|
|
85
84
|
let assetGraphRequest = await builder.build();
|
|
86
85
|
|
|
87
86
|
// early break for incremental bundling if production or flag is off;
|
|
88
|
-
|
|
87
|
+
if (
|
|
89
88
|
!input.options.shouldBundleIncrementally ||
|
|
90
|
-
|
|
91
|
-
)
|
|
89
|
+
input.options.mode === 'production'
|
|
90
|
+
) {
|
|
91
|
+
assetGraphRequest.assetGraph.safeToIncrementallyBundle = false;
|
|
92
|
+
}
|
|
92
93
|
|
|
93
94
|
if (
|
|
94
95
|
!input.options.shouldBundleIncrementally ||
|
|
@@ -171,21 +172,12 @@ export class AssetGraphBuilder {
|
|
|
171
172
|
this.lazyExcludes = lazyExcludes ?? [];
|
|
172
173
|
this.skipSymbolProp = input.skipSymbolProp ?? false;
|
|
173
174
|
|
|
174
|
-
|
|
175
|
-
|
|
175
|
+
this.cacheKey =
|
|
176
|
+
hashString(
|
|
176
177
|
`${ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${
|
|
177
178
|
options.mode
|
|
178
179
|
}${options.shouldBuildLazily ? 'lazy' : 'eager'}`,
|
|
179
|
-
);
|
|
180
|
-
this.cacheKey = `AssetGraph/${ATLASPACK_VERSION}/${options.mode}/${key}`;
|
|
181
|
-
} else {
|
|
182
|
-
this.cacheKey =
|
|
183
|
-
hashString(
|
|
184
|
-
`${ATLASPACK_VERSION}${name}${JSON.stringify(entries) ?? ''}${
|
|
185
|
-
options.mode
|
|
186
|
-
}${options.shouldBuildLazily ? 'lazy' : 'eager'}`,
|
|
187
|
-
) + '-AssetGraph';
|
|
188
|
-
}
|
|
180
|
+
) + '-AssetGraph';
|
|
189
181
|
|
|
190
182
|
this.isSingleChangeRebuild =
|
|
191
183
|
api
|
|
@@ -535,7 +527,6 @@ export class AssetGraphBuilder {
|
|
|
535
527
|
|
|
536
528
|
if (didEntriesChange) {
|
|
537
529
|
this.assetGraph.safeToIncrementallyBundle = false;
|
|
538
|
-
this.assetGraph.setNeedsBundling();
|
|
539
530
|
}
|
|
540
531
|
}
|
|
541
532
|
}
|
|
@@ -590,12 +581,10 @@ export class AssetGraphBuilder {
|
|
|
590
581
|
invariant(otherAsset.type === 'asset');
|
|
591
582
|
if (!this._areDependenciesEqualForAssets(asset, otherAsset.value)) {
|
|
592
583
|
this.assetGraph.safeToIncrementallyBundle = false;
|
|
593
|
-
this.assetGraph.setNeedsBundling();
|
|
594
584
|
}
|
|
595
585
|
} else {
|
|
596
586
|
// adding a new entry or dependency
|
|
597
587
|
this.assetGraph.safeToIncrementallyBundle = false;
|
|
598
|
-
this.assetGraph.setNeedsBundling();
|
|
599
588
|
}
|
|
600
589
|
}
|
|
601
590
|
this.changedAssets.set(asset.id, asset);
|
|
@@ -604,7 +593,6 @@ export class AssetGraphBuilder {
|
|
|
604
593
|
this.assetGraph.resolveAssetGroup(input, assets, request.id);
|
|
605
594
|
} else {
|
|
606
595
|
this.assetGraph.safeToIncrementallyBundle = false;
|
|
607
|
-
this.assetGraph.setNeedsBundling();
|
|
608
596
|
}
|
|
609
597
|
|
|
610
598
|
this.isSingleChangeRebuild = false;
|