@atlaspack/core 2.14.1-dev.145 → 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 (63) hide show
  1. package/CHANGELOG.md +59 -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/public/Asset.js +3 -2
  15. package/lib/public/Bundle.js +2 -1
  16. package/lib/public/Config.js +98 -3
  17. package/lib/public/Dependency.js +2 -1
  18. package/lib/public/MutableBundleGraph.js +2 -1
  19. package/lib/public/Target.js +2 -1
  20. package/lib/requests/AssetGraphRequest.js +13 -1
  21. package/lib/requests/AssetRequest.js +2 -1
  22. package/lib/requests/BundleGraphRequest.js +13 -1
  23. package/lib/requests/ConfigRequest.js +27 -4
  24. package/lib/requests/TargetRequest.js +18 -16
  25. package/lib/requests/WriteBundleRequest.js +15 -3
  26. package/lib/requests/WriteBundlesRequest.js +1 -0
  27. package/lib/resolveOptions.js +4 -2
  28. package/package.json +17 -17
  29. package/src/AssetGraph.js +12 -6
  30. package/src/Atlaspack.js +5 -4
  31. package/src/BundleGraph.js +13 -8
  32. package/src/Dependency.js +13 -5
  33. package/src/Environment.js +8 -5
  34. package/src/EnvironmentManager.js +145 -0
  35. package/src/InternalConfig.js +6 -5
  36. package/src/PackagerRunner.js +72 -20
  37. package/src/RequestTracker.js +330 -146
  38. package/src/UncommittedAsset.js +23 -3
  39. package/src/applyRuntimes.js +6 -1
  40. package/src/assetUtils.js +4 -3
  41. package/src/atlaspack-v3/worker/compat/plugin-config.js +9 -5
  42. package/src/public/Asset.js +9 -2
  43. package/src/public/Bundle.js +2 -1
  44. package/src/public/Config.js +129 -14
  45. package/src/public/Dependency.js +2 -1
  46. package/src/public/MutableBundleGraph.js +2 -1
  47. package/src/public/Target.js +2 -1
  48. package/src/requests/AssetGraphRequest.js +13 -3
  49. package/src/requests/AssetRequest.js +2 -1
  50. package/src/requests/BundleGraphRequest.js +13 -3
  51. package/src/requests/ConfigRequest.js +33 -9
  52. package/src/requests/TargetRequest.js +19 -25
  53. package/src/requests/WriteBundleRequest.js +14 -8
  54. package/src/requests/WriteBundlesRequest.js +1 -0
  55. package/src/resolveOptions.js +4 -2
  56. package/src/types.js +9 -7
  57. package/test/Environment.test.js +43 -34
  58. package/test/EnvironmentManager.test.js +192 -0
  59. package/test/PublicEnvironment.test.js +10 -7
  60. package/test/RequestTracker.test.js +115 -3
  61. package/test/public/Config.test.js +108 -0
  62. package/test/requests/ConfigRequest.test.js +187 -3
  63. 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,
@@ -1366,7 +1367,8 @@ export default class BundleGraph {
1366
1367
 
1367
1368
  if (
1368
1369
  descendant.type !== bundle.type ||
1369
- descendant.env.context !== bundle.env.context
1370
+ fromEnvironmentId(descendant.env).context !==
1371
+ fromEnvironmentId(bundle.env).context
1370
1372
  ) {
1371
1373
  actions.skipChildren();
1372
1374
  return;
@@ -1407,7 +1409,7 @@ export default class BundleGraph {
1407
1409
  // If a bundle's environment is isolated, it can't access assets present
1408
1410
  // in any ancestor bundles. Don't consider any assets reachable.
1409
1411
  if (
1410
- ISOLATED_ENVS.has(bundle.env.context) ||
1412
+ ISOLATED_ENVS.has(fromEnvironmentId(bundle.env).context) ||
1411
1413
  !bundle.isSplittable ||
1412
1414
  bundle.bundleBehavior === BundleBehavior.isolated ||
1413
1415
  bundle.bundleBehavior === BundleBehavior.inline
@@ -1461,7 +1463,8 @@ export default class BundleGraph {
1461
1463
  node.type === 'root' ||
1462
1464
  (node.type === 'bundle' &&
1463
1465
  (node.value.id === bundle.id ||
1464
- node.value.env.context !== bundle.env.context))
1466
+ fromEnvironmentId(node.value.env).context !==
1467
+ fromEnvironmentId(bundle.env).context))
1465
1468
  ) {
1466
1469
  isReachable = false;
1467
1470
  actions.stop();
@@ -2135,7 +2138,9 @@ export default class BundleGraph {
2135
2138
  hash.writeString(referencedBundle.id);
2136
2139
  }
2137
2140
 
2138
- hash.writeString(JSON.stringify(objectSortedEntriesDeep(bundle.env)));
2141
+ hash.writeString(
2142
+ JSON.stringify(objectSortedEntriesDeep(fromEnvironmentId(bundle.env))),
2143
+ );
2139
2144
  return hash.finish();
2140
2145
  }
2141
2146
 
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,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
  }