@atlaspack/core 2.14.1-dev.144 → 2.14.1-dev.146

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +201 -0
  2. package/lib/AssetGraph.js +17 -6
  3. package/lib/Atlaspack.js +24 -5
  4. package/lib/BundleGraph.js +6 -5
  5. package/lib/Dependency.js +6 -2
  6. package/lib/Environment.js +4 -3
  7. package/lib/EnvironmentManager.js +137 -0
  8. package/lib/InternalConfig.js +3 -2
  9. package/lib/PackagerRunner.js +52 -15
  10. package/lib/RequestTracker.js +337 -82
  11. package/lib/UncommittedAsset.js +20 -2
  12. package/lib/applyRuntimes.js +2 -1
  13. package/lib/assetUtils.js +2 -1
  14. package/lib/atlaspack-v3/worker/worker.js +8 -0
  15. package/lib/public/Asset.js +3 -2
  16. package/lib/public/Bundle.js +2 -1
  17. package/lib/public/BundleGraph.js +21 -5
  18. package/lib/public/Config.js +98 -3
  19. package/lib/public/Dependency.js +2 -1
  20. package/lib/public/MutableBundleGraph.js +2 -1
  21. package/lib/public/Target.js +2 -1
  22. package/lib/requests/AssetGraphRequest.js +13 -1
  23. package/lib/requests/AssetRequest.js +2 -1
  24. package/lib/requests/BundleGraphRequest.js +13 -1
  25. package/lib/requests/ConfigRequest.js +27 -4
  26. package/lib/requests/TargetRequest.js +18 -16
  27. package/lib/requests/WriteBundleRequest.js +15 -3
  28. package/lib/requests/WriteBundlesRequest.js +1 -0
  29. package/lib/resolveOptions.js +5 -6
  30. package/package.json +22 -18
  31. package/src/AssetGraph.js +12 -6
  32. package/src/Atlaspack.js +29 -13
  33. package/src/BundleGraph.js +13 -8
  34. package/src/Dependency.js +13 -5
  35. package/src/Environment.js +8 -5
  36. package/src/EnvironmentManager.js +145 -0
  37. package/src/InternalConfig.js +6 -5
  38. package/src/PackagerRunner.js +72 -20
  39. package/src/RequestTracker.js +567 -131
  40. package/src/UncommittedAsset.js +23 -3
  41. package/src/applyRuntimes.js +6 -1
  42. package/src/assetUtils.js +4 -3
  43. package/src/atlaspack-v3/worker/compat/plugin-config.js +9 -5
  44. package/src/atlaspack-v3/worker/worker.js +7 -0
  45. package/src/public/Asset.js +9 -2
  46. package/src/public/Bundle.js +2 -1
  47. package/src/public/BundleGraph.js +22 -5
  48. package/src/public/Config.js +129 -14
  49. package/src/public/Dependency.js +2 -1
  50. package/src/public/MutableBundleGraph.js +2 -1
  51. package/src/public/Target.js +2 -1
  52. package/src/requests/AssetGraphRequest.js +13 -3
  53. package/src/requests/AssetRequest.js +2 -1
  54. package/src/requests/BundleGraphRequest.js +13 -3
  55. package/src/requests/ConfigRequest.js +33 -9
  56. package/src/requests/TargetRequest.js +19 -25
  57. package/src/requests/WriteBundleRequest.js +14 -8
  58. package/src/requests/WriteBundlesRequest.js +1 -0
  59. package/src/resolveOptions.js +6 -8
  60. package/src/types.js +9 -7
  61. package/test/Environment.test.js +43 -34
  62. package/test/EnvironmentManager.test.js +192 -0
  63. package/test/PublicEnvironment.test.js +10 -7
  64. package/test/RequestTracker.test.js +115 -3
  65. package/test/public/Config.test.js +108 -0
  66. package/test/requests/ConfigRequest.test.js +187 -3
  67. package/test/test-utils.js +4 -9
@@ -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,25 +579,25 @@ 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
- if (
582
- bundle.env.sourceMap &&
583
- bundle.env.sourceMap.sourceRoot !== undefined
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
- bundle.target.env.context === 'browser'
590
+ bundleTargetEnv.context === 'browser'
589
591
  ) {
590
592
  sourceRoot = '/__parcel_source_root';
591
593
  }
592
594
 
593
595
  if (
594
- bundle.env.sourceMap &&
595
- bundle.env.sourceMap.inlineSources !== undefined
596
+ bundleEnv.sourceMap &&
597
+ bundleEnv.sourceMap.inlineSources !== undefined
596
598
  ) {
597
- inlineSources = bundle.env.sourceMap.inlineSources;
598
- } else if (bundle.target.env.context !== 'node') {
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
  }
@@ -607,7 +609,7 @@ export default class PackagerRunner {
607
609
  }
608
610
 
609
611
  let mapFilename = fullPath + '.map';
610
- let isInlineMap = bundle.env.sourceMap && bundle.env.sourceMap.inline;
612
+ let isInlineMap = bundleEnv.sourceMap && bundleEnv.sourceMap.inline;
611
613
 
612
614
  let stringified = await map.stringify({
613
615
  file: path.basename(mapFilename),
@@ -663,6 +665,21 @@ export default class PackagerRunner {
663
665
  this.options,
664
666
  );
665
667
 
668
+ if (getFeatureFlag('cachePerformanceImprovements')) {
669
+ const hash = hashString(
670
+ ATLASPACK_VERSION +
671
+ devDepHashes +
672
+ invalidationHash +
673
+ bundle.target.publicUrl +
674
+ bundleGraph.getHash(bundle) +
675
+ JSON.stringify(configResults) +
676
+ JSON.stringify(globalInfoResults) +
677
+ this.options.mode +
678
+ (this.options.shouldBuildLazily ? 'lazy' : 'eager'),
679
+ );
680
+ return path.join(bundle.displayName ?? bundle.name ?? bundle.id, hash);
681
+ }
682
+
666
683
  return hashString(
667
684
  ATLASPACK_VERSION +
668
685
  devDepHashes +
@@ -705,20 +722,27 @@ export default class PackagerRunner {
705
722
  let mapKey = PackagerRunner.getMapKey(cacheKey);
706
723
 
707
724
  let isLargeBlob = await this.options.cache.hasLargeBlob(contentKey);
708
- let contentExists =
709
- isLargeBlob || (await this.options.cache.has(contentKey));
725
+ let contentExists = getFeatureFlag('cachePerformanceImprovements')
726
+ ? isLargeBlob
727
+ : isLargeBlob || (await this.options.cache.has(contentKey));
710
728
  if (!contentExists) {
711
729
  return null;
712
730
  }
713
731
 
714
- let mapExists = await this.options.cache.has(mapKey);
732
+ let mapExists = getFeatureFlag('cachePerformanceImprovements')
733
+ ? await this.options.cache.hasLargeBlob(mapKey)
734
+ : await this.options.cache.has(mapKey);
715
735
 
716
736
  return {
717
737
  contents: isLargeBlob
718
738
  ? this.options.cache.getStream(contentKey)
719
739
  : blobToStream(await this.options.cache.getBlob(contentKey)),
720
740
  map: mapExists
721
- ? blobToStream(await this.options.cache.getBlob(mapKey))
741
+ ? blobToStream(
742
+ getFeatureFlag('cachePerformanceImprovements')
743
+ ? await this.options.cache.getLargeBlob(mapKey)
744
+ : await this.options.cache.getBlob(mapKey),
745
+ )
722
746
  : null,
723
747
  };
724
748
  }
@@ -732,11 +756,14 @@ export default class PackagerRunner {
732
756
  let size = 0;
733
757
  let hash;
734
758
  let hashReferences = [];
735
- let isLargeBlob = false;
759
+ let isLargeBlob = getFeatureFlag('cachePerformanceImprovements');
736
760
 
737
761
  // TODO: don't replace hash references in binary files??
738
762
  if (contents instanceof Readable) {
739
- isLargeBlob = true;
763
+ if (!getFeatureFlag('cachePerformanceImprovements')) {
764
+ isLargeBlob = true;
765
+ }
766
+
740
767
  let boundaryStr = '';
741
768
  let h = new Hash();
742
769
  await this.options.cache.setStream(
@@ -759,17 +786,32 @@ export default class PackagerRunner {
759
786
  size = buffer.byteLength;
760
787
  hash = hashBuffer(buffer);
761
788
  hashReferences = contents.match(HASH_REF_REGEX) ?? [];
762
- await this.options.cache.setBlob(cacheKeys.content, buffer);
789
+
790
+ if (getFeatureFlag('cachePerformanceImprovements')) {
791
+ await this.options.cache.setLargeBlob(cacheKeys.content, buffer);
792
+ } else {
793
+ await this.options.cache.setBlob(cacheKeys.content, buffer);
794
+ }
763
795
  } else {
764
796
  size = contents.length;
765
797
  hash = hashBuffer(contents);
766
798
  hashReferences = contents.toString().match(HASH_REF_REGEX) ?? [];
767
- await this.options.cache.setBlob(cacheKeys.content, contents);
799
+
800
+ if (getFeatureFlag('cachePerformanceImprovements')) {
801
+ await this.options.cache.setLargeBlob(cacheKeys.content, contents);
802
+ } else {
803
+ await this.options.cache.setBlob(cacheKeys.content, contents);
804
+ }
768
805
  }
769
806
 
770
807
  if (map != null) {
771
- await this.options.cache.setBlob(cacheKeys.map, map);
808
+ if (getFeatureFlag('cachePerformanceImprovements')) {
809
+ await this.options.cache.setLargeBlob(cacheKeys.map, map);
810
+ } else {
811
+ await this.options.cache.setBlob(cacheKeys.map, map);
812
+ }
772
813
  }
814
+
773
815
  let info = {
774
816
  type,
775
817
  size,
@@ -778,19 +820,29 @@ export default class PackagerRunner {
778
820
  cacheKeys,
779
821
  isLargeBlob,
780
822
  };
823
+
781
824
  await this.options.cache.set(cacheKeys.info, info);
782
825
  return info;
783
826
  }
784
827
 
785
828
  static getContentKey(cacheKey: string): string {
829
+ if (getFeatureFlag('cachePerformanceImprovements')) {
830
+ return `PackagerRunner/${ATLASPACK_VERSION}/${cacheKey}/content`;
831
+ }
786
832
  return hashString(`${cacheKey}:content`);
787
833
  }
788
834
 
789
835
  static getMapKey(cacheKey: string): string {
836
+ if (getFeatureFlag('cachePerformanceImprovements')) {
837
+ return `PackagerRunner/${ATLASPACK_VERSION}/${cacheKey}/map`;
838
+ }
790
839
  return hashString(`${cacheKey}:map`);
791
840
  }
792
841
 
793
842
  static getInfoKey(cacheKey: string): string {
843
+ if (getFeatureFlag('cachePerformanceImprovements')) {
844
+ return `PackagerRunner/${ATLASPACK_VERSION}/${cacheKey}/info`;
845
+ }
794
846
  return hashString(`${cacheKey}:info`);
795
847
  }
796
848
  }