@atlaspack/core 2.17.3 → 2.18.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/lib/AssetGraph.js +17 -6
  3. package/lib/Atlaspack.js +3 -1
  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 +191 -89
  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 +4 -2
  30. package/package.json +13 -13
  31. package/src/AssetGraph.js +12 -6
  32. package/src/Atlaspack.js +5 -4
  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 +330 -146
  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 +4 -2
  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
@@ -24,7 +24,6 @@ import type {
24
24
  BundleNode,
25
25
  Dependency,
26
26
  DependencyNode,
27
- Environment,
28
27
  InternalSourceLocation,
29
28
  Target,
30
29
  Condition,
@@ -49,6 +48,8 @@ import {ISOLATED_ENVS} from './public/Environment';
49
48
  import {fromProjectPath, fromProjectPathRelative} from './projectPath';
50
49
  import {HASH_REF_PREFIX} from './constants';
51
50
  import {getFeatureFlag} from '@atlaspack/feature-flags';
51
+ import {fromEnvironmentId} from './EnvironmentManager';
52
+ import type {EnvironmentRef} from './EnvironmentManager';
52
53
 
53
54
  export const bundleGraphEdgeTypes = {
54
55
  // A lack of an edge type indicates to follow the edge while traversing
@@ -283,7 +284,7 @@ export default class BundleGraph {
283
284
  if (
284
285
  node.type === 'dependency' &&
285
286
  node.value.symbols != null &&
286
- node.value.env.shouldScopeHoist &&
287
+ fromEnvironmentId(node.value.env).shouldScopeHoist &&
287
288
  // Disable in dev mode because this feature is at odds with safeToIncrementallyBundle
288
289
  isProduction
289
290
  ) {
@@ -555,11 +556,11 @@ export default class BundleGraph {
555
556
  +needsStableName?: ?boolean,
556
557
  +bundleBehavior?: ?IBundleBehavior,
557
558
  +shouldContentHash: boolean,
558
- +env: Environment,
559
+ +env: EnvironmentRef,
559
560
  |}
560
561
  | {|
561
562
  +type: string,
562
- +env: Environment,
563
+ +env: EnvironmentRef,
563
564
  +uniqueKey: string,
564
565
  +target: Target,
565
566
  +needsStableName?: ?boolean,
@@ -1359,7 +1360,8 @@ export default class BundleGraph {
1359
1360
 
1360
1361
  if (
1361
1362
  descendant.type !== bundle.type ||
1362
- descendant.env.context !== bundle.env.context
1363
+ fromEnvironmentId(descendant.env).context !==
1364
+ fromEnvironmentId(bundle.env).context
1363
1365
  ) {
1364
1366
  actions.skipChildren();
1365
1367
  return;
@@ -1400,7 +1402,7 @@ export default class BundleGraph {
1400
1402
  // If a bundle's environment is isolated, it can't access assets present
1401
1403
  // in any ancestor bundles. Don't consider any assets reachable.
1402
1404
  if (
1403
- ISOLATED_ENVS.has(bundle.env.context) ||
1405
+ ISOLATED_ENVS.has(fromEnvironmentId(bundle.env).context) ||
1404
1406
  !bundle.isSplittable ||
1405
1407
  bundle.bundleBehavior === BundleBehavior.isolated ||
1406
1408
  bundle.bundleBehavior === BundleBehavior.inline
@@ -1454,7 +1456,8 @@ export default class BundleGraph {
1454
1456
  node.type === 'root' ||
1455
1457
  (node.type === 'bundle' &&
1456
1458
  (node.value.id === bundle.id ||
1457
- node.value.env.context !== bundle.env.context))
1459
+ fromEnvironmentId(node.value.env).context !==
1460
+ fromEnvironmentId(bundle.env).context))
1458
1461
  ) {
1459
1462
  isReachable = false;
1460
1463
  actions.stop();
@@ -2128,7 +2131,9 @@ export default class BundleGraph {
2128
2131
  hash.writeString(referencedBundle.id);
2129
2132
  }
2130
2133
 
2131
- hash.writeString(JSON.stringify(objectSortedEntriesDeep(bundle.env)));
2134
+ hash.writeString(
2135
+ JSON.stringify(objectSortedEntriesDeep(fromEnvironmentId(bundle.env))),
2136
+ );
2132
2137
  return hash.finish();
2133
2138
  }
2134
2139
 
package/src/Dependency.js CHANGED
@@ -8,7 +8,7 @@ import type {
8
8
  BundleBehavior as IBundleBehavior,
9
9
  SemverRange,
10
10
  } from '@atlaspack/types';
11
- import type {Dependency, Environment, Target} from './types';
11
+ import type {Dependency, Target} from './types';
12
12
  import {createDependencyId as createDependencyIdRust} from '@atlaspack/rust';
13
13
  import {
14
14
  SpecifierType,
@@ -21,6 +21,8 @@ import {toInternalSourceLocation} from './utils';
21
21
  import {toProjectPath} from './projectPath';
22
22
  import assert from 'assert';
23
23
  import {identifierRegistry} from './IdentifierRegistry';
24
+ import {fromEnvironmentId, toEnvironmentId} from './EnvironmentManager';
25
+ import type {EnvironmentRef} from './EnvironmentManager';
24
26
 
25
27
  type DependencyOpts = {|
26
28
  id?: string,
@@ -34,7 +36,7 @@ type DependencyOpts = {|
34
36
  isEntry?: boolean,
35
37
  isOptional?: boolean,
36
38
  loc?: SourceLocation,
37
- env: Environment,
39
+ env: EnvironmentRef,
38
40
  packageConditions?: Array<string>,
39
41
  meta?: Meta,
40
42
  resolveFrom?: FilePath,
@@ -60,7 +62,7 @@ export function createDependencyId({
60
62
  }: {|
61
63
  sourceAssetId?: string | void,
62
64
  specifier: DependencySpecifier,
63
- env: Environment,
65
+ env: EnvironmentRef,
64
66
  target?: Target | void,
65
67
  pipeline?: ?string,
66
68
  specifierType: $Keys<typeof SpecifierType>,
@@ -73,8 +75,14 @@ export function createDependencyId({
73
75
  const params = {
74
76
  sourceAssetId,
75
77
  specifier,
76
- environmentId: env.id,
77
- target,
78
+ environmentId: toEnvironmentId(env),
79
+ target:
80
+ target != null
81
+ ? {
82
+ ...target,
83
+ env: fromEnvironmentId(target.env),
84
+ }
85
+ : null,
78
86
  pipeline,
79
87
  specifierType: SpecifierType[specifierType],
80
88
  bundleBehavior,
@@ -10,6 +10,8 @@ import {toInternalSourceLocation} from './utils';
10
10
  import PublicEnvironment from './public/Environment';
11
11
  import {environmentToInternalEnvironment} from './public/Environment';
12
12
  import {identifierRegistry} from './IdentifierRegistry';
13
+ import {toEnvironmentRef} from './EnvironmentManager';
14
+ import type {EnvironmentRef} from './EnvironmentManager';
13
15
 
14
16
  const DEFAULT_ENGINES = {
15
17
  browsers: ['> 0.25%'],
@@ -35,7 +37,7 @@ export function createEnvironment({
35
37
  loc,
36
38
  }: EnvironmentOpts = {
37
39
  /*::...null*/
38
- }): Environment {
40
+ }): EnvironmentRef {
39
41
  if (context == null) {
40
42
  if (engines?.node) {
41
43
  context = 'node';
@@ -112,21 +114,22 @@ export function createEnvironment({
112
114
  };
113
115
 
114
116
  res.id = getEnvironmentHash(res);
115
- return Object.freeze(res);
117
+
118
+ return toEnvironmentRef(Object.freeze(res));
116
119
  }
117
120
 
118
121
  export function mergeEnvironments(
119
122
  projectRoot: FilePath,
120
123
  a: Environment,
121
124
  b: ?(EnvironmentOptions | IEnvironment),
122
- ): Environment {
125
+ ): EnvironmentRef {
123
126
  // If merging the same object, avoid copying.
124
127
  if (a === b || !b) {
125
- return a;
128
+ return toEnvironmentRef(a);
126
129
  }
127
130
 
128
131
  if (b instanceof PublicEnvironment) {
129
- return environmentToInternalEnvironment(b);
132
+ return toEnvironmentRef(environmentToInternalEnvironment(b));
130
133
  }
131
134
 
132
135
  // $FlowFixMe - ignore the `id` that is already on a
@@ -0,0 +1,145 @@
1
+ // @flow strict-local
2
+ /*!
3
+ * At the moment we're doing this change for `CoreEnvironment`,
4
+ * but the same change must be made for `TypesEnvironment` in @atlaspack/types.
5
+ */
6
+ import type {Environment as CoreEnvironment} from './types';
7
+ import {type Cache} from '@atlaspack/cache';
8
+ import {
9
+ addEnvironment,
10
+ getEnvironment,
11
+ getAllEnvironments,
12
+ setAllEnvironments,
13
+ } from '@atlaspack/rust';
14
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
15
+ import {instrument} from '@atlaspack/logger';
16
+ import {ATLASPACK_VERSION} from './constants';
17
+
18
+ const localEnvironmentCache = new Map<string, CoreEnvironment>();
19
+
20
+ export opaque type EnvironmentId = string;
21
+ /**
22
+ * When deduplication is cleaned-up this will always be a string.
23
+ */
24
+ export type EnvironmentRef = EnvironmentId | CoreEnvironment;
25
+
26
+ /**
27
+ * Convert environment to a ref.
28
+ * This is what we should be using to store environments.
29
+ */
30
+ export function toEnvironmentRef(env: CoreEnvironment): EnvironmentRef {
31
+ if (!getFeatureFlag('environmentDeduplication')) {
32
+ return env;
33
+ }
34
+
35
+ const id = toEnvironmentId(env);
36
+ return id;
37
+ }
38
+
39
+ /**
40
+ * Convert environment to a string ID
41
+ */
42
+ export function toEnvironmentId(
43
+ /**
44
+ * Redundant type during roll-out
45
+ */
46
+ env: CoreEnvironment | EnvironmentRef,
47
+ ): string {
48
+ if (!getFeatureFlag('environmentDeduplication')) {
49
+ return typeof env === 'string' ? env : env.id;
50
+ }
51
+
52
+ if (typeof env === 'string') {
53
+ return env;
54
+ }
55
+
56
+ addEnvironment(env);
57
+ return env.id;
58
+ }
59
+
60
+ export function fromEnvironmentId(id: EnvironmentRef): CoreEnvironment {
61
+ if (!getFeatureFlag('environmentDeduplication')) {
62
+ if (typeof id === 'string') {
63
+ throw new Error(
64
+ 'This should never happen when environmentDeduplication feature-flag is off',
65
+ );
66
+ } else {
67
+ return id;
68
+ }
69
+ }
70
+
71
+ if (typeof id !== 'string') {
72
+ return id;
73
+ }
74
+
75
+ const localEnv = localEnvironmentCache.get(id);
76
+
77
+ if (localEnv) {
78
+ return localEnv;
79
+ }
80
+
81
+ const env = Object.freeze(getEnvironment(id));
82
+ localEnvironmentCache.set(id, env);
83
+ return env;
84
+ }
85
+
86
+ /**
87
+ * Writes all environments and their IDs to the cache
88
+ * @param {Cache} cache
89
+ * @returns {Promise<void>}
90
+ */
91
+ export async function writeEnvironmentsToCache(cache: Cache): Promise<void> {
92
+ const environments = getAllEnvironments();
93
+ const environmentIds = new Set<string>();
94
+
95
+ // Store each environment individually
96
+ for (const env of environments) {
97
+ environmentIds.add(env.id);
98
+ const envKey = `Environment/${ATLASPACK_VERSION}/${env.id}`;
99
+
100
+ await instrument(
101
+ `RequestTracker::writeToCache::cache.put(${envKey})`,
102
+ async () => {
103
+ await cache.set(envKey, env);
104
+ },
105
+ );
106
+ }
107
+
108
+ // Store the list of environment IDs
109
+ await instrument(
110
+ `RequestTracker::writeToCache::cache.put(${`EnvironmentManager/${ATLASPACK_VERSION}`})`,
111
+ async () => {
112
+ await cache.set(
113
+ `EnvironmentManager/${ATLASPACK_VERSION}`,
114
+ Array.from(environmentIds),
115
+ );
116
+ },
117
+ );
118
+ }
119
+
120
+ /**
121
+ * Loads all environments and their IDs from the cache
122
+ * @param {Cache} cache
123
+ * @returns {Promise<void>}
124
+ */
125
+ export async function loadEnvironmentsFromCache(cache: Cache): Promise<void> {
126
+ const cachedEnvIds = await cache.get(
127
+ `EnvironmentManager/${ATLASPACK_VERSION}`,
128
+ );
129
+
130
+ if (cachedEnvIds == null) {
131
+ return;
132
+ }
133
+
134
+ const environments = [];
135
+ for (const envId of cachedEnvIds) {
136
+ const envKey = `Environment/${ATLASPACK_VERSION}/${envId}`;
137
+ const cachedEnv = await cache.get(envKey);
138
+ if (cachedEnv != null) {
139
+ environments.push(cachedEnv);
140
+ }
141
+ }
142
+ if (environments.length > 0) {
143
+ setAllEnvironments(environments);
144
+ }
145
+ }
@@ -3,7 +3,6 @@
3
3
  import type {PackageName, ConfigResult} from '@atlaspack/types';
4
4
  import type {
5
5
  Config,
6
- Environment,
7
6
  InternalFileCreateInvalidation,
8
7
  InternalDevDepOptions,
9
8
  } from './types';
@@ -13,17 +12,19 @@ import {fromProjectPathRelative} from './projectPath';
13
12
  import {createEnvironment} from './Environment';
14
13
  import {hashString} from '@atlaspack/rust';
15
14
  import {identifierRegistry} from './IdentifierRegistry';
15
+ import type {EnvironmentRef} from './EnvironmentManager';
16
+ import {toEnvironmentId} from './EnvironmentManager';
16
17
 
17
18
  type ConfigOpts = {|
18
19
  plugin: PackageName,
19
20
  searchPath: ProjectPath,
20
21
  isSource?: boolean,
21
- env?: Environment,
22
+ env?: EnvironmentRef,
22
23
  result?: ConfigResult,
23
24
  invalidateOnFileChange?: Set<ProjectPath>,
24
25
  invalidateOnConfigKeyChange?: Array<{|
25
26
  filePath: ProjectPath,
26
- configKey: string,
27
+ configKey: string[],
27
28
  |}>,
28
29
  invalidateOnFileCreate?: Array<InternalFileCreateInvalidation>,
29
30
  invalidateOnEnvChange?: Set<string>,
@@ -52,13 +53,13 @@ export function createConfig({
52
53
  const configId = hashString(
53
54
  plugin +
54
55
  fromProjectPathRelative(searchPath) +
55
- environment.id +
56
+ toEnvironmentId(environment) +
56
57
  String(isSource),
57
58
  );
58
59
  identifierRegistry.addIdentifier('config_request', configId, {
59
60
  plugin,
60
61
  searchPath,
61
- environmentId: environment.id,
62
+ environmentId: toEnvironmentId(environment),
62
63
  isSource,
63
64
  });
64
65
  return {
@@ -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
- 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
  }
602
604
  }
603
605
 
604
606
  let mapFilename = fullPath + '.map';
605
- let isInlineMap = bundle.env.sourceMap && bundle.env.sourceMap.inline;
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 || (await this.options.cache.has(contentKey));
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 = await this.options.cache.has(mapKey);
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(await this.options.cache.getBlob(mapKey))
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 = false;
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
- isLargeBlob = true;
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
- await this.options.cache.setBlob(cacheKeys.content, buffer);
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
- await this.options.cache.setBlob(cacheKeys.content, contents);
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
- await this.options.cache.setBlob(cacheKeys.map, map);
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
  }