@atlaspack/core 2.16.2-canary.13 → 2.16.2-canary.131
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +300 -0
- package/index.d.ts +4 -0
- package/lib/AssetGraph.js +27 -7
- package/lib/Atlaspack.js +35 -27
- package/lib/AtlaspackConfig.schema.js +7 -1
- package/lib/BundleGraph.js +8 -5
- package/lib/Dependency.js +6 -2
- package/lib/Environment.js +5 -3
- package/lib/EnvironmentManager.js +137 -0
- package/lib/InternalConfig.js +3 -2
- package/lib/PackagerRunner.js +54 -16
- package/lib/RequestTracker.js +345 -132
- package/lib/SymbolPropagation.js +14 -0
- package/lib/Transformation.js +2 -2
- package/lib/UncommittedAsset.js +20 -2
- package/lib/applyRuntimes.js +2 -1
- package/lib/assetUtils.js +2 -1
- package/lib/atlaspack-v3/AtlaspackV3.js +16 -3
- package/lib/atlaspack-v3/worker/compat/environment.js +2 -2
- package/lib/atlaspack-v3/worker/compat/mutable-asset.js +6 -6
- package/lib/atlaspack-v3/worker/compat/plugin-config.js +5 -5
- package/lib/atlaspack-v3/worker/index.js +3 -0
- package/lib/atlaspack-v3/worker/worker.js +8 -0
- package/lib/dumpGraphToGraphViz.js +1 -1
- package/lib/index.js +29 -1
- package/lib/public/Asset.js +7 -9
- package/lib/public/Bundle.js +12 -13
- package/lib/public/BundleGraph.js +3 -2
- package/lib/public/BundleGroup.js +2 -3
- package/lib/public/Config.js +95 -8
- package/lib/public/Dependency.js +4 -4
- package/lib/public/Environment.js +2 -3
- package/lib/public/MutableBundleGraph.js +5 -4
- package/lib/public/PluginOptions.js +1 -2
- package/lib/public/Target.js +4 -4
- package/lib/requests/AssetGraphRequest.js +13 -1
- package/lib/requests/AssetGraphRequestRust.js +17 -2
- package/lib/requests/AssetRequest.js +2 -1
- package/lib/requests/BundleGraphRequest.js +13 -1
- package/lib/requests/ConfigRequest.js +27 -4
- package/lib/requests/DevDepRequest.js +11 -1
- package/lib/requests/PathRequest.js +10 -0
- package/lib/requests/TargetRequest.js +18 -16
- package/lib/requests/WriteBundleRequest.js +15 -3
- package/lib/requests/WriteBundlesRequest.js +22 -1
- package/lib/resolveOptions.js +7 -4
- package/lib/worker.js +18 -1
- package/package.json +18 -25
- package/src/AssetGraph.js +30 -7
- package/src/Atlaspack.js +40 -23
- package/src/BundleGraph.js +13 -8
- package/src/Dependency.js +13 -5
- package/src/Environment.js +9 -6
- package/src/EnvironmentManager.js +145 -0
- package/src/InternalConfig.js +6 -5
- package/src/PackagerRunner.js +72 -20
- package/src/RequestTracker.js +526 -157
- package/src/SymbolPropagation.js +13 -1
- package/src/UncommittedAsset.js +23 -3
- package/src/applyRuntimes.js +6 -1
- package/src/assetUtils.js +4 -3
- package/src/atlaspack-v3/AtlaspackV3.js +24 -3
- package/src/atlaspack-v3/worker/compat/plugin-config.js +9 -5
- package/src/atlaspack-v3/worker/index.js +2 -1
- package/src/atlaspack-v3/worker/worker.js +7 -0
- package/src/index.js +5 -1
- package/src/public/Asset.js +13 -6
- package/src/public/Bundle.js +12 -11
- package/src/public/BundleGraph.js +10 -2
- package/src/public/BundleGroup.js +2 -2
- package/src/public/Config.js +132 -18
- package/src/public/Dependency.js +4 -3
- package/src/public/Environment.js +2 -2
- package/src/public/MutableBundleGraph.js +8 -5
- package/src/public/PluginOptions.js +1 -1
- package/src/public/Target.js +4 -3
- package/src/requests/AssetGraphRequest.js +13 -3
- package/src/requests/AssetGraphRequestRust.js +14 -2
- package/src/requests/AssetRequest.js +2 -1
- package/src/requests/BundleGraphRequest.js +13 -3
- package/src/requests/ConfigRequest.js +33 -9
- package/src/requests/DevDepRequest.js +22 -9
- package/src/requests/PathRequest.js +4 -0
- package/src/requests/TargetRequest.js +19 -25
- package/src/requests/WriteBundleRequest.js +14 -8
- package/src/requests/WriteBundlesRequest.js +31 -3
- package/src/resolveOptions.js +4 -2
- package/src/types.js +10 -7
- package/test/Environment.test.js +43 -34
- package/test/EnvironmentManager.test.js +192 -0
- package/test/PublicEnvironment.test.js +10 -7
- package/test/RequestTracker.test.js +124 -29
- package/test/public/Config.test.js +108 -0
- package/test/requests/ConfigRequest.test.js +199 -7
- package/test/test-utils.js +4 -9
package/src/PackagerRunner.js
CHANGED
|
@@ -63,6 +63,8 @@ import {getInvalidationId, getInvalidationHash} from './assetUtils';
|
|
|
63
63
|
import {optionsProxy} from './utils';
|
|
64
64
|
import {invalidateDevDeps} from './requests/DevDepRequest';
|
|
65
65
|
import {tracer, PluginTracer} from '@atlaspack/profiler';
|
|
66
|
+
import {fromEnvironmentId} from './EnvironmentManager';
|
|
67
|
+
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
66
68
|
|
|
67
69
|
type Opts = {|
|
|
68
70
|
config: AtlaspackConfig,
|
|
@@ -577,32 +579,32 @@ export default class PackagerRunner {
|
|
|
577
579
|
);
|
|
578
580
|
let inlineSources = false;
|
|
579
581
|
|
|
582
|
+
const bundleEnv = fromEnvironmentId(bundle.env);
|
|
580
583
|
if (bundle.target) {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
sourceRoot = bundle.env.sourceMap.sourceRoot;
|
|
584
|
+
const bundleTargetEnv = fromEnvironmentId(bundle.target.env);
|
|
585
|
+
|
|
586
|
+
if (bundleEnv.sourceMap && bundleEnv.sourceMap.sourceRoot !== undefined) {
|
|
587
|
+
sourceRoot = bundleEnv.sourceMap.sourceRoot;
|
|
586
588
|
} else if (
|
|
587
589
|
this.options.serveOptions &&
|
|
588
|
-
|
|
590
|
+
bundleTargetEnv.context === 'browser'
|
|
589
591
|
) {
|
|
590
592
|
sourceRoot = '/__parcel_source_root';
|
|
591
593
|
}
|
|
592
594
|
|
|
593
595
|
if (
|
|
594
|
-
|
|
595
|
-
|
|
596
|
+
bundleEnv.sourceMap &&
|
|
597
|
+
bundleEnv.sourceMap.inlineSources !== undefined
|
|
596
598
|
) {
|
|
597
|
-
inlineSources =
|
|
598
|
-
} else if (
|
|
599
|
+
inlineSources = bundleEnv.sourceMap.inlineSources;
|
|
600
|
+
} else if (bundleTargetEnv.context !== 'node') {
|
|
599
601
|
// inlining should only happen in production for browser targets by default
|
|
600
602
|
inlineSources = this.options.mode === 'production';
|
|
601
603
|
}
|
|
602
604
|
}
|
|
603
605
|
|
|
604
606
|
let mapFilename = fullPath + '.map';
|
|
605
|
-
let isInlineMap =
|
|
607
|
+
let isInlineMap = bundleEnv.sourceMap && bundleEnv.sourceMap.inline;
|
|
606
608
|
|
|
607
609
|
let stringified = await map.stringify({
|
|
608
610
|
file: path.basename(mapFilename),
|
|
@@ -658,6 +660,21 @@ export default class PackagerRunner {
|
|
|
658
660
|
this.options,
|
|
659
661
|
);
|
|
660
662
|
|
|
663
|
+
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
664
|
+
const hash = hashString(
|
|
665
|
+
ATLASPACK_VERSION +
|
|
666
|
+
devDepHashes +
|
|
667
|
+
invalidationHash +
|
|
668
|
+
bundle.target.publicUrl +
|
|
669
|
+
bundleGraph.getHash(bundle) +
|
|
670
|
+
JSON.stringify(configResults) +
|
|
671
|
+
JSON.stringify(globalInfoResults) +
|
|
672
|
+
this.options.mode +
|
|
673
|
+
(this.options.shouldBuildLazily ? 'lazy' : 'eager'),
|
|
674
|
+
);
|
|
675
|
+
return path.join(bundle.displayName ?? bundle.name ?? bundle.id, hash);
|
|
676
|
+
}
|
|
677
|
+
|
|
661
678
|
return hashString(
|
|
662
679
|
ATLASPACK_VERSION +
|
|
663
680
|
devDepHashes +
|
|
@@ -700,20 +717,27 @@ export default class PackagerRunner {
|
|
|
700
717
|
let mapKey = PackagerRunner.getMapKey(cacheKey);
|
|
701
718
|
|
|
702
719
|
let isLargeBlob = await this.options.cache.hasLargeBlob(contentKey);
|
|
703
|
-
let contentExists =
|
|
704
|
-
isLargeBlob
|
|
720
|
+
let contentExists = getFeatureFlag('cachePerformanceImprovements')
|
|
721
|
+
? isLargeBlob
|
|
722
|
+
: isLargeBlob || (await this.options.cache.has(contentKey));
|
|
705
723
|
if (!contentExists) {
|
|
706
724
|
return null;
|
|
707
725
|
}
|
|
708
726
|
|
|
709
|
-
let mapExists =
|
|
727
|
+
let mapExists = getFeatureFlag('cachePerformanceImprovements')
|
|
728
|
+
? await this.options.cache.hasLargeBlob(mapKey)
|
|
729
|
+
: await this.options.cache.has(mapKey);
|
|
710
730
|
|
|
711
731
|
return {
|
|
712
732
|
contents: isLargeBlob
|
|
713
733
|
? this.options.cache.getStream(contentKey)
|
|
714
734
|
: blobToStream(await this.options.cache.getBlob(contentKey)),
|
|
715
735
|
map: mapExists
|
|
716
|
-
? blobToStream(
|
|
736
|
+
? blobToStream(
|
|
737
|
+
getFeatureFlag('cachePerformanceImprovements')
|
|
738
|
+
? await this.options.cache.getLargeBlob(mapKey)
|
|
739
|
+
: await this.options.cache.getBlob(mapKey),
|
|
740
|
+
)
|
|
717
741
|
: null,
|
|
718
742
|
};
|
|
719
743
|
}
|
|
@@ -727,11 +751,14 @@ export default class PackagerRunner {
|
|
|
727
751
|
let size = 0;
|
|
728
752
|
let hash;
|
|
729
753
|
let hashReferences = [];
|
|
730
|
-
let isLargeBlob =
|
|
754
|
+
let isLargeBlob = getFeatureFlag('cachePerformanceImprovements');
|
|
731
755
|
|
|
732
756
|
// TODO: don't replace hash references in binary files??
|
|
733
757
|
if (contents instanceof Readable) {
|
|
734
|
-
|
|
758
|
+
if (!getFeatureFlag('cachePerformanceImprovements')) {
|
|
759
|
+
isLargeBlob = true;
|
|
760
|
+
}
|
|
761
|
+
|
|
735
762
|
let boundaryStr = '';
|
|
736
763
|
let h = new Hash();
|
|
737
764
|
await this.options.cache.setStream(
|
|
@@ -754,17 +781,32 @@ export default class PackagerRunner {
|
|
|
754
781
|
size = buffer.byteLength;
|
|
755
782
|
hash = hashBuffer(buffer);
|
|
756
783
|
hashReferences = contents.match(HASH_REF_REGEX) ?? [];
|
|
757
|
-
|
|
784
|
+
|
|
785
|
+
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
786
|
+
await this.options.cache.setLargeBlob(cacheKeys.content, buffer);
|
|
787
|
+
} else {
|
|
788
|
+
await this.options.cache.setBlob(cacheKeys.content, buffer);
|
|
789
|
+
}
|
|
758
790
|
} else {
|
|
759
791
|
size = contents.length;
|
|
760
792
|
hash = hashBuffer(contents);
|
|
761
793
|
hashReferences = contents.toString().match(HASH_REF_REGEX) ?? [];
|
|
762
|
-
|
|
794
|
+
|
|
795
|
+
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
796
|
+
await this.options.cache.setLargeBlob(cacheKeys.content, contents);
|
|
797
|
+
} else {
|
|
798
|
+
await this.options.cache.setBlob(cacheKeys.content, contents);
|
|
799
|
+
}
|
|
763
800
|
}
|
|
764
801
|
|
|
765
802
|
if (map != null) {
|
|
766
|
-
|
|
803
|
+
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
804
|
+
await this.options.cache.setLargeBlob(cacheKeys.map, map);
|
|
805
|
+
} else {
|
|
806
|
+
await this.options.cache.setBlob(cacheKeys.map, map);
|
|
807
|
+
}
|
|
767
808
|
}
|
|
809
|
+
|
|
768
810
|
let info = {
|
|
769
811
|
type,
|
|
770
812
|
size,
|
|
@@ -773,19 +815,29 @@ export default class PackagerRunner {
|
|
|
773
815
|
cacheKeys,
|
|
774
816
|
isLargeBlob,
|
|
775
817
|
};
|
|
818
|
+
|
|
776
819
|
await this.options.cache.set(cacheKeys.info, info);
|
|
777
820
|
return info;
|
|
778
821
|
}
|
|
779
822
|
|
|
780
823
|
static getContentKey(cacheKey: string): string {
|
|
824
|
+
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
825
|
+
return `PackagerRunner/${ATLASPACK_VERSION}/${cacheKey}/content`;
|
|
826
|
+
}
|
|
781
827
|
return hashString(`${cacheKey}:content`);
|
|
782
828
|
}
|
|
783
829
|
|
|
784
830
|
static getMapKey(cacheKey: string): string {
|
|
831
|
+
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
832
|
+
return `PackagerRunner/${ATLASPACK_VERSION}/${cacheKey}/map`;
|
|
833
|
+
}
|
|
785
834
|
return hashString(`${cacheKey}:map`);
|
|
786
835
|
}
|
|
787
836
|
|
|
788
837
|
static getInfoKey(cacheKey: string): string {
|
|
838
|
+
if (getFeatureFlag('cachePerformanceImprovements')) {
|
|
839
|
+
return `PackagerRunner/${ATLASPACK_VERSION}/${cacheKey}/info`;
|
|
840
|
+
}
|
|
789
841
|
return hashString(`${cacheKey}:info`);
|
|
790
842
|
}
|
|
791
843
|
}
|