@atlaspack/core 2.12.1-dev.3443 → 2.12.1-dev.3460

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 (94) hide show
  1. package/lib/AssetGraph.js +5 -1
  2. package/lib/Atlaspack.js +2 -2
  3. package/lib/Dependency.js +1 -1
  4. package/lib/PackagerRunner.js +45 -3
  5. package/lib/SymbolPropagation.js +25 -36
  6. package/lib/assetUtils.js +1 -1
  7. package/lib/atlaspack-v3/fs.js +31 -29
  8. package/lib/atlaspack-v3/index.js +2 -2
  9. package/lib/atlaspack-v3/jsCallable.js +9 -4
  10. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +192 -0
  11. package/lib/atlaspack-v3/worker/compat/bitflags.js +84 -0
  12. package/lib/atlaspack-v3/worker/compat/dependency.js +44 -0
  13. package/lib/atlaspack-v3/worker/compat/environment.js +68 -0
  14. package/lib/atlaspack-v3/worker/compat/index.js +104 -0
  15. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +144 -0
  16. package/lib/atlaspack-v3/worker/compat/plugin-config.js +58 -0
  17. package/lib/atlaspack-v3/worker/compat/plugin-logger.js +29 -0
  18. package/lib/atlaspack-v3/worker/compat/plugin-options.js +113 -0
  19. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +12 -0
  20. package/lib/atlaspack-v3/worker/compat/target.js +17 -0
  21. package/lib/atlaspack-v3/worker/worker.js +162 -83
  22. package/lib/projectPath.js +12 -4
  23. package/lib/requests/ConfigRequest.js +1 -1
  24. package/lib/requests/WriteBundleRequest.js +15 -15
  25. package/package.json +23 -16
  26. package/src/AssetGraph.js +15 -13
  27. package/src/Atlaspack.js +5 -6
  28. package/src/AtlaspackConfig.js +11 -9
  29. package/src/AtlaspackConfig.schema.js +1 -1
  30. package/src/BundleGraph.js +83 -79
  31. package/src/CommittedAsset.js +1 -1
  32. package/src/Dependency.js +1 -1
  33. package/src/PackagerRunner.js +56 -8
  34. package/src/ReporterRunner.js +4 -4
  35. package/src/RequestTracker.js +18 -18
  36. package/src/SymbolPropagation.js +40 -52
  37. package/src/Transformation.js +12 -12
  38. package/src/UncommittedAsset.js +2 -2
  39. package/src/Validation.js +5 -5
  40. package/src/applyRuntimes.js +2 -2
  41. package/src/assetUtils.js +1 -1
  42. package/src/atlaspack-v3/AtlaspackV3.js +1 -1
  43. package/src/atlaspack-v3/fs.js +39 -25
  44. package/src/atlaspack-v3/index.js +1 -1
  45. package/src/atlaspack-v3/jsCallable.js +11 -10
  46. package/src/atlaspack-v3/worker/compat/asset-symbols.js +225 -0
  47. package/src/atlaspack-v3/worker/compat/bitflags.js +100 -0
  48. package/src/atlaspack-v3/worker/compat/dependency.js +83 -0
  49. package/src/atlaspack-v3/worker/compat/environment.js +92 -0
  50. package/src/atlaspack-v3/worker/compat/index.js +10 -0
  51. package/src/atlaspack-v3/worker/compat/mutable-asset.js +184 -0
  52. package/src/atlaspack-v3/worker/compat/plugin-config.js +94 -0
  53. package/src/atlaspack-v3/worker/compat/plugin-logger.js +47 -0
  54. package/src/atlaspack-v3/worker/compat/plugin-options.js +137 -0
  55. package/src/atlaspack-v3/worker/compat/plugin-tracer.js +11 -0
  56. package/src/atlaspack-v3/worker/compat/target.js +27 -0
  57. package/src/atlaspack-v3/worker/worker.js +218 -113
  58. package/src/dumpGraphToGraphViz.js +1 -1
  59. package/src/loadDotEnv.js +1 -1
  60. package/src/projectPath.js +12 -4
  61. package/src/public/Asset.js +1 -1
  62. package/src/public/Bundle.js +3 -3
  63. package/src/public/BundleGraph.js +20 -20
  64. package/src/public/Config.js +1 -1
  65. package/src/public/MutableBundleGraph.js +8 -8
  66. package/src/requests/AssetGraphRequest.js +10 -10
  67. package/src/requests/AssetGraphRequestRust.js +3 -3
  68. package/src/requests/AssetRequest.js +3 -3
  69. package/src/requests/AtlaspackConfigRequest.js +5 -3
  70. package/src/requests/BundleGraphRequest.js +6 -6
  71. package/src/requests/ConfigRequest.js +5 -5
  72. package/src/requests/DevDepRequest.js +7 -7
  73. package/src/requests/EntryRequest.js +2 -2
  74. package/src/requests/TargetRequest.js +9 -8
  75. package/src/requests/ValidationRequest.js +2 -2
  76. package/src/requests/WriteBundleRequest.js +26 -20
  77. package/src/requests/WriteBundlesRequest.js +6 -6
  78. package/src/requests/asset-graph-diff.js +4 -4
  79. package/src/resolveOptions.js +3 -3
  80. package/src/serializer.js +2 -2
  81. package/src/serializerCore.browser.js +3 -2
  82. package/src/serializerCore.js +2 -2
  83. package/src/utils.js +2 -2
  84. package/test/AtlaspackConfigRequest.test.js +1 -1
  85. package/test/BundleGraph.test.js +3 -3
  86. package/test/Dependency.test.js +28 -0
  87. package/test/PublicMutableBundleGraph.test.js +2 -2
  88. package/test/RequestTracker.test.js +7 -6
  89. package/test/SymbolPropagation.test.js +9 -9
  90. package/test/requests/ConfigRequest.test.js +3 -6
  91. package/test/utils.test.js +1 -1
  92. package/lib/atlaspack-v3/worker/compat.js +0 -57
  93. package/src/atlaspack-v3/worker/compat.js +0 -82
  94. package/test/requests/WriteBundleRequest.test.js +0 -132
@@ -55,13 +55,13 @@ export default class MutableBundleGraph
55
55
  addAssetGraphToBundle(
56
56
  asset: IAsset,
57
57
  bundle: IBundle,
58
- shouldSkipDependency?: IDependency => boolean,
58
+ shouldSkipDependency?: (IDependency) => boolean,
59
59
  ) {
60
60
  this.#graph.addAssetGraphToBundle(
61
61
  assetToAssetValue(asset),
62
62
  bundleToInternalBundle(bundle),
63
63
  shouldSkipDependency
64
- ? d => shouldSkipDependency(new Dependency(d, this.#options))
64
+ ? (d) => shouldSkipDependency(new Dependency(d, this.#options))
65
65
  : undefined,
66
66
  );
67
67
  }
@@ -69,13 +69,13 @@ export default class MutableBundleGraph
69
69
  addEntryToBundle(
70
70
  asset: IAsset,
71
71
  bundle: IBundle,
72
- shouldSkipDependency?: IDependency => boolean,
72
+ shouldSkipDependency?: (IDependency) => boolean,
73
73
  ) {
74
74
  this.#graph.addEntryToBundle(
75
75
  assetToAssetValue(asset),
76
76
  bundleToInternalBundle(bundle),
77
77
  shouldSkipDependency
78
- ? d => shouldSkipDependency(new Dependency(d, this.#options))
78
+ ? (d) => shouldSkipDependency(new Dependency(d, this.#options))
79
79
  : undefined,
80
80
  );
81
81
  }
@@ -194,7 +194,7 @@ export default class MutableBundleGraph
194
194
  return Bundle.get(existing.value, this.#graph, this.#options);
195
195
  }
196
196
 
197
- let publicId = getPublicId(bundleId, existing =>
197
+ let publicId = getPublicId(bundleId, (existing) =>
198
198
  this.#bundlePublicIds.has(existing),
199
199
  );
200
200
  this.#bundlePublicIds.add(publicId);
@@ -283,13 +283,13 @@ export default class MutableBundleGraph
283
283
  getDependencyAssets(dependency: IDependency): Array<IAsset> {
284
284
  return this.#graph
285
285
  .getDependencyAssets(dependencyToInternalDependency(dependency))
286
- .map(asset => assetFromValue(asset, this.#options));
286
+ .map((asset) => assetFromValue(asset, this.#options));
287
287
  }
288
288
 
289
289
  getBundleGroupsContainingBundle(bundle: IBundle): Array<IBundleGroup> {
290
290
  return this.#graph
291
291
  .getBundleGroupsContainingBundle(bundleToInternalBundle(bundle))
292
- .map(bundleGroup => new BundleGroup(bundleGroup, this.#options));
292
+ .map((bundleGroup) => new BundleGroup(bundleGroup, this.#options));
293
293
  }
294
294
 
295
295
  getParentBundlesOfBundleGroup(bundleGroup: IBundleGroup): Array<IBundle> {
@@ -297,7 +297,7 @@ export default class MutableBundleGraph
297
297
  .getParentBundlesOfBundleGroup(
298
298
  bundleGroupToInternalBundleGroup(bundleGroup),
299
299
  )
300
- .map(bundle => Bundle.get(bundle, this.#graph, this.#options));
300
+ .map((bundle) => Bundle.get(bundle, this.#graph, this.#options));
301
301
  }
302
302
 
303
303
  getTotalSize(asset: IAsset): number {
@@ -65,7 +65,7 @@ type RunInput = {|
65
65
  type AssetGraphRequest = {|
66
66
  id: string,
67
67
  +type: typeof requestTypes.asset_graph_request,
68
- run: RunInput => Async<AssetGraphRequestResult>,
68
+ run: (RunInput) => Async<AssetGraphRequestResult>,
69
69
  input: AssetGraphRequestInput,
70
70
  |};
71
71
 
@@ -75,7 +75,7 @@ export default function createAssetGraphRequest(
75
75
  return {
76
76
  type: requestTypes.asset_graph_request,
77
77
  id: requestInput.name,
78
- run: async input => {
78
+ run: async (input) => {
79
79
  let prevResult =
80
80
  await input.api.getPreviousResult<AssetGraphRequestResult>();
81
81
 
@@ -171,10 +171,10 @@ export class AssetGraphBuilder {
171
171
  this.isSingleChangeRebuild =
172
172
  api
173
173
  .getInvalidSubRequests()
174
- .filter(req => req.requestType === 'asset_request').length === 1;
174
+ .filter((req) => req.requestType === 'asset_request').length === 1;
175
175
  this.queue = new PromiseQueue();
176
176
 
177
- assetGraph.onNodeRemoved = nodeId => {
177
+ assetGraph.onNodeRemoved = (nodeId) => {
178
178
  this.assetGroupsWithRemovedParents.delete(nodeId);
179
179
 
180
180
  // This needs to mark all connected nodes that doesn't become orphaned
@@ -365,13 +365,13 @@ export class AssetGraphBuilder {
365
365
  // also consider it not lazy (so it gets marked as requested).
366
366
  const relativePath = fromProjectPathRelative(node.value.filePath);
367
367
  if (this.lazyIncludes.length > 0) {
368
- isNodeLazy = this.lazyIncludes.some(lazyIncludeRegex =>
368
+ isNodeLazy = this.lazyIncludes.some((lazyIncludeRegex) =>
369
369
  relativePath.match(lazyIncludeRegex),
370
370
  );
371
371
  }
372
372
  // Excludes override includes, so a node is _not_ lazy if it is included in the exclude list.
373
373
  if (this.lazyExcludes.length > 0 && isNodeLazy) {
374
- isNodeLazy = !this.lazyExcludes.some(lazyExcludeRegex =>
374
+ isNodeLazy = !this.lazyExcludes.some((lazyExcludeRegex) =>
375
375
  relativePath.match(lazyExcludeRegex),
376
376
  );
377
377
  }
@@ -381,7 +381,7 @@ export class AssetGraphBuilder {
381
381
  } else if (!node.requested) {
382
382
  let isAsyncChild = this.assetGraph
383
383
  .getIncomingDependencies(node.value)
384
- .every(dep => dep.isEntry || dep.priority !== Priority.sync);
384
+ .every((dep) => dep.isEntry || dep.priority !== Priority.sync);
385
385
  if (isAsyncChild) {
386
386
  node.requested = !isNodeLazy;
387
387
  } else {
@@ -456,7 +456,7 @@ export class AssetGraphBuilder {
456
456
  );
457
457
  }
458
458
  return this.queue.add(() =>
459
- promise.then(null, error => errors.push(error)),
459
+ promise.then(null, (error) => errors.push(error)),
460
460
  );
461
461
  }
462
462
 
@@ -464,7 +464,7 @@ export class AssetGraphBuilder {
464
464
  let prevEntries = this.assetGraph.safeToIncrementallyBundle
465
465
  ? this.assetGraph
466
466
  .getEntryAssets()
467
- .map(asset => asset.id)
467
+ .map((asset) => asset.id)
468
468
  .sort()
469
469
  : [];
470
470
 
@@ -480,7 +480,7 @@ export class AssetGraphBuilder {
480
480
  if (this.assetGraph.safeToIncrementallyBundle) {
481
481
  let currentEntries = this.assetGraph
482
482
  .getEntryAssets()
483
- .map(asset => asset.id)
483
+ .map((asset) => asset.id)
484
484
  .sort();
485
485
  let didEntriesChange =
486
486
  prevEntries.length !== currentEntries.length ||
@@ -25,17 +25,17 @@ type RunInput = {|
25
25
  type AssetGraphRequest = {|
26
26
  id: string,
27
27
  +type: typeof requestTypes.asset_graph_request,
28
- run: RunInput => Async<AssetGraphRequestResult>,
28
+ run: (RunInput) => Async<AssetGraphRequestResult>,
29
29
  input: AssetGraphRequestInput,
30
30
  |};
31
31
 
32
32
  export function createAssetGraphRequestRust(
33
33
  rustAtlaspack: AtlaspackV3,
34
34
  ): (input: AssetGraphRequestInput) => AssetGraphRequest {
35
- return input => ({
35
+ return (input) => ({
36
36
  type: requestTypes.asset_graph_request,
37
37
  id: input.name,
38
- run: async input => {
38
+ run: async (input) => {
39
39
  let options = input.options;
40
40
  let serializedAssetGraph;
41
41
  try {
@@ -84,8 +84,8 @@ async function run({input, api, farm, invalidateReason, options}) {
84
84
  await Promise.all(
85
85
  api
86
86
  .getSubRequests()
87
- .filter(req => req.requestType === requestTypes.dev_dep_request)
88
- .map(async req => [
87
+ .filter((req) => req.requestType === requestTypes.dev_dep_request)
88
+ .map(async (req) => [
89
89
  req.id,
90
90
  nullthrows(await api.getRequestResult<DevDepRequestResult>(req.id)),
91
91
  ]),
@@ -112,7 +112,7 @@ async function run({input, api, farm, invalidateReason, options}) {
112
112
  specifier: req.specifier,
113
113
  resolveFrom: req.resolveFrom,
114
114
  },
115
- ...(req.additionalInvalidations ?? []).map(i => ({
115
+ ...(req.additionalInvalidations ?? []).map((i) => ({
116
116
  specifier: i.specifier,
117
117
  resolveFrom: i.resolveFrom,
118
118
  })),
@@ -469,7 +469,9 @@ export async function processConfigChain(
469
469
 
470
470
  if (errors.length > 0) {
471
471
  throw new ThrowableDiagnostic({
472
- diagnostic: errors.flatMap(e => e.diagnostics ?? errorToDiagnostic(e)),
472
+ diagnostic: errors.flatMap(
473
+ (e) => e.diagnostics ?? errorToDiagnostic(e),
474
+ ),
473
475
  });
474
476
  }
475
477
  }
@@ -641,7 +643,7 @@ export function getResolveFrom(
641
643
  function assertPurePipeline(
642
644
  pipeline: ExtendableAtlaspackConfigPipeline,
643
645
  ): PureAtlaspackConfigPipeline {
644
- return pipeline.map(s => {
646
+ return pipeline.map((s) => {
645
647
  invariant(typeof s !== 'string');
646
648
  return s;
647
649
  });
@@ -655,7 +657,7 @@ export function mergePipelines(
655
657
  return base ?? [];
656
658
  }
657
659
 
658
- if (ext.filter(v => v === '...').length > 1) {
660
+ if (ext.filter((v) => v === '...').length > 1) {
659
661
  throw new Error(
660
662
  'Only one spread element can be included in a config pipeline',
661
663
  );
@@ -82,7 +82,7 @@ export type BundleGraphResult = {|
82
82
  type BundleGraphRequest = {|
83
83
  id: string,
84
84
  +type: typeof requestTypes.bundle_graph_request,
85
- run: RunInput => Async<BundleGraphResult>,
85
+ run: (RunInput) => Async<BundleGraphResult>,
86
86
  input: BundleGraphRequestInput,
87
87
  |};
88
88
 
@@ -92,7 +92,7 @@ export default function createBundleGraphRequest(
92
92
  return {
93
93
  type: requestTypes.bundle_graph_request,
94
94
  id: 'BundleGraph',
95
- run: async input => {
95
+ run: async (input) => {
96
96
  let {options, api, invalidateReason} = input;
97
97
  let {optionsRef, requestedAssetIds, signal} = input.input;
98
98
  let measurement = tracer.createMeasurement('building');
@@ -146,7 +146,7 @@ export default function createBundleGraphRequest(
146
146
  Boolean(invalidateReason & OPTION_CHANGE) ||
147
147
  input.api
148
148
  .getSubRequests()
149
- .some(req => !input.api.canSkipSubrequest(req.id));
149
+ .some((req) => !input.api.canSkipSubrequest(req.id));
150
150
 
151
151
  if (subRequestsInvalid) {
152
152
  assetGraph.safeToIncrementallyBundle = false;
@@ -342,7 +342,7 @@ class BundlerRunner {
342
342
  if (tracer.enabled) {
343
343
  measurementFilename = graph
344
344
  .getEntryAssets()
345
- .map(asset => fromProjectPathRelative(asset.filePath))
345
+ .map((asset) => fromProjectPathRelative(asset.filePath))
346
346
  .join(', ');
347
347
  measurement = tracer.createMeasurement(
348
348
  plugin.name,
@@ -440,7 +440,7 @@ class BundlerRunner {
440
440
  // can match them to the correct packager/optimizer plugins.
441
441
  let bundles = internalBundleGraph.getBundles({includeInline: true});
442
442
  await Promise.all(
443
- bundles.map(bundle =>
443
+ bundles.map((bundle) =>
444
444
  this.nameBundle(namers, bundle, internalBundleGraph),
445
445
  ),
446
446
  );
@@ -502,7 +502,7 @@ class BundlerRunner {
502
502
  validateBundles(bundleGraph: InternalBundleGraph): void {
503
503
  let bundles = bundleGraph.getBundles();
504
504
 
505
- let bundleNames = bundles.map(b =>
505
+ let bundleNames = bundles.map((b) =>
506
506
  joinProjectPath(b.target.distDir, nullthrows(b.name)),
507
507
  );
508
508
  assert.deepEqual(
@@ -18,7 +18,7 @@ import type {LoadedPlugin} from '../AtlaspackConfig';
18
18
  import type {RequestResult, RunAPI} from '../RequestTracker';
19
19
  import type {ProjectPath} from '../projectPath';
20
20
 
21
- import {serializeRaw} from '../serializer.js';
21
+ import {serializeRaw} from '../serializer';
22
22
  import {PluginLogger} from '@atlaspack/logger';
23
23
  import PluginOptions from '../public/PluginOptions';
24
24
  import ThrowableDiagnostic, {errorToDiagnostic} from '@atlaspack/diagnostic';
@@ -90,7 +90,7 @@ export async function loadPluginConfig<T: PluginWithLoadConfig>(
90
90
  config.result = await loadConfig({
91
91
  config: new PublicConfig(config, options),
92
92
  options: new PluginOptions(
93
- optionsProxy(options, option => {
93
+ optionsProxy(options, (option) => {
94
94
  config.invalidateOnOptionChange.add(option);
95
95
  }),
96
96
  ),
@@ -231,7 +231,7 @@ export async function getConfigHash(
231
231
  if (config.invalidateOnFileChange.size > 0) {
232
232
  hash.writeString(
233
233
  await getInvalidationHash(
234
- [...config.invalidateOnFileChange].map(filePath => ({
234
+ [...config.invalidateOnFileChange].map((filePath) => ({
235
235
  type: 'file',
236
236
  filePath,
237
237
  })),
@@ -262,7 +262,7 @@ export function getConfigRequests(
262
262
  configs: Array<Config>,
263
263
  ): Array<ConfigRequest> {
264
264
  return configs
265
- .filter(config => {
265
+ .filter((config) => {
266
266
  // No need to send to the graph if there are no invalidations.
267
267
  return (
268
268
  config.invalidateOnFileChange.size > 0 ||
@@ -274,7 +274,7 @@ export function getConfigRequests(
274
274
  config.invalidateOnBuild
275
275
  );
276
276
  })
277
- .map(config => ({
277
+ .map((config) => ({
278
278
  id: config.id,
279
279
  invalidateOnFileChange: config.invalidateOnFileChange,
280
280
  invalidateOnConfigKeyChange: config.invalidateOnConfigKeyChange,
@@ -71,14 +71,14 @@ export async function createDevDependency(
71
71
 
72
72
  let invalidateOnFileChangeProject = [
73
73
  ...invalidations.invalidateOnFileChange,
74
- ].map(f => toProjectPath(options.projectRoot, f));
74
+ ].map((f) => toProjectPath(options.projectRoot, f));
75
75
 
76
76
  // It is possible for a transformer to have multiple different hashes due to
77
77
  // different dependencies (e.g. conditional requires) so we must always
78
78
  // recompute the hash and compare rather than only sending a transformer
79
79
  // dev dependency once.
80
80
  hash = await getInvalidationHash(
81
- invalidateOnFileChangeProject.map(f => ({
81
+ invalidateOnFileChangeProject.map((f) => ({
82
82
  type: 'file',
83
83
  filePath: f,
84
84
  })),
@@ -89,7 +89,7 @@ export async function createDevDependency(
89
89
  specifier,
90
90
  resolveFrom,
91
91
  hash,
92
- invalidateOnFileCreate: invalidations.invalidateOnFileCreate.map(i =>
92
+ invalidateOnFileCreate: invalidations.invalidateOnFileCreate.map((i) =>
93
93
  invalidateOnFileCreateToInternal(options.projectRoot, i),
94
94
  ),
95
95
  invalidateOnFileChange: new Set(invalidateOnFileChangeProject),
@@ -118,8 +118,8 @@ export async function getDevDepRequests<TResult: RequestResult>(
118
118
  await Promise.all(
119
119
  api
120
120
  .getSubRequests()
121
- .filter(req => req.requestType === requestTypes.dev_dep_request)
122
- .map(async req => [
121
+ .filter((req) => req.requestType === requestTypes.dev_dep_request)
122
+ .map(async (req) => [
123
123
  req.id,
124
124
  nullthrows(await api.getRequestResult<DevDepRequestResult>(req.id)),
125
125
  ]),
@@ -144,7 +144,7 @@ export async function getDevDepRequests<TResult: RequestResult>(
144
144
  specifier: req.specifier,
145
145
  resolveFrom: req.resolveFrom,
146
146
  },
147
- ...(req.additionalInvalidations ?? []).map(i => ({
147
+ ...(req.additionalInvalidations ?? []).map((i) => ({
148
148
  specifier: i.specifier,
149
149
  resolveFrom: i.resolveFrom,
150
150
  })),
@@ -232,7 +232,7 @@ const pluginCache = createBuildCache();
232
232
  export function getWorkerDevDepRequests(
233
233
  devDepRequests: Array<DevDepRequest>,
234
234
  ): Array<DevDepRequest> {
235
- return devDepRequests.map(devDepRequest => {
235
+ return devDepRequests.map((devDepRequest) => {
236
236
  // If we've already sent a matching transformer + hash to the main thread during this build,
237
237
  // there's no need to repeat ourselves.
238
238
  let {specifier, resolveFrom, hash} = devDepRequest;
@@ -121,7 +121,7 @@ async function assertFile(
121
121
  ]),
122
122
  },
123
123
  ],
124
- hints: alternatives.map(r => {
124
+ hints: alternatives.map((r) => {
125
125
  return md`Did you mean '__${r}__'?`;
126
126
  }),
127
127
  },
@@ -174,7 +174,7 @@ export class EntryResolver {
174
174
  onlyFiles: false,
175
175
  });
176
176
  let results = await Promise.all(
177
- files.map(f => this.resolveEntry(path.normalize(f))),
177
+ files.map((f) => this.resolveEntry(path.normalize(f))),
178
178
  );
179
179
  return results.reduce(
180
180
  (p, res) => ({
@@ -225,14 +225,14 @@ export class TargetResolver {
225
225
  // Only build the intersection of the exclusive target and option targets.
226
226
  if (exclusiveTarget != null) {
227
227
  optionTargets = optionTargets.filter(
228
- target => target === exclusiveTarget,
228
+ (target) => target === exclusiveTarget,
229
229
  );
230
230
  }
231
231
 
232
232
  // If an array of strings is passed, it's a filter on the resolved package
233
233
  // targets. Load them, and find the matching targets.
234
234
  targets = optionTargets
235
- .map(target => {
235
+ .map((target) => {
236
236
  // null means skipped.
237
237
  if (!packageTargets.has(target)) {
238
238
  throw new ThrowableDiagnostic({
@@ -326,7 +326,8 @@ export class TargetResolver {
326
326
  return target;
327
327
  })
328
328
  .filter(
329
- target => !skipTarget(target.name, exclusiveTarget, target.source),
329
+ (target) =>
330
+ !skipTarget(target.name, exclusiveTarget, target.source),
330
331
  );
331
332
  }
332
333
 
@@ -387,7 +388,7 @@ export class TargetResolver {
387
388
  } else {
388
389
  targets = Array.from(packageTargets.values())
389
390
  .filter(Boolean)
390
- .filter(descriptor => {
391
+ .filter((descriptor) => {
391
392
  return (
392
393
  descriptor &&
393
394
  !skipTarget(descriptor.name, exclusiveTarget, descriptor.source)
@@ -920,7 +921,7 @@ export class TargetResolver {
920
921
  }
921
922
 
922
923
  let customTargets = (Object.keys(pkgTargets): Array<string>).filter(
923
- targetName => !COMMON_TARGETS[targetName],
924
+ (targetName) => !COMMON_TARGETS[targetName],
924
925
  );
925
926
 
926
927
  // Custom targets
@@ -1377,7 +1378,7 @@ function assertNoDuplicateTargets(options, targets, pkgFilePath, pkgContents) {
1377
1378
  code: pkgContents,
1378
1379
  codeHighlights: generateJSONCodeHighlights(
1379
1380
  pkgContents,
1380
- targetNames.map(t => ({
1381
+ targetNames.map((t) => ({
1381
1382
  key: `/${t}`,
1382
1383
  type: 'value',
1383
1384
  })),
@@ -1580,7 +1581,7 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
1580
1581
  includeNodeModules =
1581
1582
  'only ' +
1582
1583
  listFormat.format(
1583
- target.env.includeNodeModules.map(m => JSON.stringify(m)),
1584
+ target.env.includeNodeModules.map((m) => JSON.stringify(m)),
1584
1585
  );
1585
1586
  } else if (
1586
1587
  target.env.includeNodeModules &&
@@ -1595,7 +1596,7 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
1595
1596
  );
1596
1597
  }
1597
1598
 
1598
- let format = v => (v.message != null ? md.italic(v.message) : '');
1599
+ let format = (v) => (v.message != null ? md.italic(v.message) : '');
1599
1600
  logger.verbose({
1600
1601
  origin: '@atlaspack/core',
1601
1602
  message: md`**Target** "${target.name}"
@@ -43,13 +43,13 @@ export default function createValidationRequest(
43
43
  );
44
44
 
45
45
  let config = new AtlaspackConfig(processedConfig, options);
46
- let trackedRequestsDesc = assetRequests.filter(request => {
46
+ let trackedRequestsDesc = assetRequests.filter((request) => {
47
47
  return config.getValidatorNames(request.filePath).length > 0;
48
48
  });
49
49
 
50
50
  // Schedule validations on workers for all plugins that implement the one-asset-at-a-time "validate" method.
51
51
  let promises = trackedRequestsDesc.map(
52
- async request =>
52
+ async (request) =>
53
53
  ((await farm.createHandle('runValidate'))({
54
54
  requests: [request],
55
55
  optionsRef: optionsRef,
@@ -3,7 +3,6 @@
3
3
  import type {FileSystem, FileOptions} from '@atlaspack/fs';
4
4
  import type {ContentKey} from '@atlaspack/graph';
5
5
  import type {Async, FilePath, Compressor} from '@atlaspack/types';
6
- import {replaceHashReferences} from '@atlaspack/rust';
7
6
 
8
7
  import type {RunAPI, StaticRunOpts} from '../RequestTracker';
9
8
  import type {Bundle, PackagedBundleInfo, AtlaspackOptions} from '../types';
@@ -17,7 +16,7 @@ import {HASH_REF_HASH_LEN, HASH_REF_PREFIX} from '../constants';
17
16
  import nullthrows from 'nullthrows';
18
17
  import path from 'path';
19
18
  import {NamedBundle} from '../public/Bundle';
20
- import {blobToStream} from '@atlaspack/utils';
19
+ import {blobToStream, TapStream} from '@atlaspack/utils';
21
20
  import {Readable, Transform, pipeline} from 'stream';
22
21
  import {
23
22
  fromProjectPath,
@@ -130,8 +129,20 @@ async function run({input, options, api}) {
130
129
  : {
131
130
  mode: (await inputFS.stat(mainEntry.filePath)).mode,
132
131
  };
133
- const contents: Buffer = await options.cache.getBlob(cacheKeys.content);
134
- const size = contents.byteLength;
132
+ let contentStream: Readable;
133
+ if (info.isLargeBlob) {
134
+ contentStream = options.cache.getStream(cacheKeys.content);
135
+ } else {
136
+ contentStream = blobToStream(
137
+ await options.cache.getBlob(cacheKeys.content),
138
+ );
139
+ }
140
+ let size = 0;
141
+ contentStream = contentStream.pipe(
142
+ new TapStream((buf) => {
143
+ size += buf.length;
144
+ }),
145
+ );
135
146
 
136
147
  let configResult = nullthrows(
137
148
  await api.runRequest<null, ConfigAndCachePath>(
@@ -144,7 +155,7 @@ async function run({input, options, api}) {
144
155
  invalidateDevDeps(invalidDevDeps, options, config);
145
156
 
146
157
  await writeFiles(
147
- contents,
158
+ contentStream,
148
159
  info,
149
160
  hashRefToNameHash,
150
161
  options,
@@ -163,7 +174,7 @@ async function run({input, options, api}) {
163
174
  (await options.cache.has(mapKey))
164
175
  ) {
165
176
  await writeFiles(
166
- await options.cache.getBlob(mapKey),
177
+ blobToStream(await options.cache.getBlob(mapKey)),
167
178
  info,
168
179
  hashRefToNameHash,
169
180
  options,
@@ -190,7 +201,7 @@ async function run({input, options, api}) {
190
201
  }
191
202
 
192
203
  async function writeFiles(
193
- contents: Buffer,
204
+ inputStream: stream$Readable,
194
205
  info: BundleInfo,
195
206
  hashRefToNameHash: Map<string, string>,
196
207
  options: AtlaspackOptions,
@@ -206,19 +217,16 @@ async function writeFiles(
206
217
  );
207
218
  let fullPath = fromProjectPath(options.projectRoot, filePath);
208
219
 
209
- const stream = info.hashReferences.length
210
- ? replaceHashReferences(
211
- contents,
212
- Object.fromEntries(hashRefToNameHash.entries()),
213
- )
214
- : contents;
220
+ let stream = info.hashReferences.length
221
+ ? inputStream.pipe(replaceStream(hashRefToNameHash))
222
+ : inputStream;
215
223
 
216
224
  let promises = [];
217
225
  for (let compressor of compressors) {
218
226
  promises.push(
219
227
  runCompressor(
220
228
  compressor,
221
- blobToStream(stream),
229
+ cloneStream(stream),
222
230
  options,
223
231
  outputFS,
224
232
  fullPath,
@@ -264,7 +272,7 @@ async function runCompressor(
264
272
  filePath + (res.type != null ? '.' + res.type : ''),
265
273
  writeOptions,
266
274
  ),
267
- err => {
275
+ (err) => {
268
276
  if (err) reject(err);
269
277
  else resolve();
270
278
  },
@@ -292,9 +300,7 @@ async function runCompressor(
292
300
  }
293
301
  }
294
302
 
295
- export function replaceStream(
296
- hashRefToNameHash: Map<string, string>,
297
- ): Transform {
303
+ function replaceStream(hashRefToNameHash) {
298
304
  let boundaryStr = Buffer.alloc(0);
299
305
  let replaced = Buffer.alloc(0);
300
306
  return new Transform({
@@ -349,8 +355,8 @@ function cloneStream(readable) {
349
355
  let res = new Readable();
350
356
  // $FlowFixMe
351
357
  res._read = () => {};
352
- readable.on('data', chunk => res.push(chunk));
358
+ readable.on('data', (chunk) => res.push(chunk));
353
359
  readable.on('end', () => res.push(null));
354
- readable.on('error', err => res.emit('error', err));
360
+ readable.on('error', (err) => res.emit('error', err));
355
361
  return res;
356
362
  }
@@ -63,7 +63,7 @@ async function run({input, api, farm, options}) {
63
63
  |} = {};
64
64
  let writeEarlyPromises = {};
65
65
  let hashRefToNameHash = new Map();
66
- let bundles = bundleGraph.getBundles().filter(bundle => {
66
+ let bundles = bundleGraph.getBundles().filter((bundle) => {
67
67
  // Do not package and write placeholder bundles to disk. We just
68
68
  // need to update the name so other bundles can reference it.
69
69
  if (bundle.isPlaceholder) {
@@ -91,12 +91,12 @@ async function run({input, api, farm, options}) {
91
91
  // This avoids the cost of serializing the bundle graph for single file change builds.
92
92
  let useMainThread =
93
93
  bundles.length === 1 ||
94
- bundles.filter(b => !api.canSkipSubrequest(bundleGraph.getHash(b)))
94
+ bundles.filter((b) => !api.canSkipSubrequest(bundleGraph.getHash(b)))
95
95
  .length === 1;
96
96
 
97
97
  try {
98
98
  await Promise.all(
99
- bundles.map(async bundle => {
99
+ bundles.map(async (bundle) => {
100
100
  let request = createPackageRequest({
101
101
  bundle,
102
102
  bundleGraph,
@@ -142,7 +142,7 @@ async function run({input, api, farm, options}) {
142
142
  );
143
143
  assignComplexNameHashes(hashRefToNameHash, bundles, bundleInfoMap, options);
144
144
  await Promise.all(
145
- bundles.map(bundle => {
145
+ bundles.map((bundle) => {
146
146
  let promise =
147
147
  writeEarlyPromises[bundle.id] ??
148
148
  api.runRequest(
@@ -154,7 +154,7 @@ async function run({input, api, farm, options}) {
154
154
  }),
155
155
  );
156
156
 
157
- return promise.then(r => res.set(bundle.id, r));
157
+ return promise.then((r) => res.set(bundle.id, r));
158
158
  }),
159
159
  );
160
160
 
@@ -180,7 +180,7 @@ function assignComplexNameHashes(
180
180
  options.shouldContentHash
181
181
  ? hashString(
182
182
  [...getBundlesIncludedInHash(bundle.id, bundleInfoMap)]
183
- .map(bundleId => bundleInfoMap[bundleId].hash)
183
+ .map((bundleId) => bundleInfoMap[bundleId].hash)
184
184
  .join(':'),
185
185
  ).slice(-8)
186
186
  : bundle.id.slice(-8),
@@ -49,12 +49,12 @@ function compactDeep(
49
49
  });
50
50
  return copy;
51
51
  } else if (Array.isArray(obj)) {
52
- return obj.map(v => compactDeep(v, ignoredPatterns, `${currentPath}[]`));
52
+ return obj.map((v) => compactDeep(v, ignoredPatterns, `${currentPath}[]`));
53
53
  } else if (typeof obj === 'object') {
54
54
  const copy = {};
55
55
  Object.entries(obj ?? {}).forEach(([key, value]) => {
56
56
  const path = `${currentPath}.${key}`;
57
- if (ignoredPatterns.some(pattern => path.includes(pattern))) {
57
+ if (ignoredPatterns.some((pattern) => path.includes(pattern))) {
58
58
  return;
59
59
  }
60
60
  // Equivalent false == null
@@ -73,10 +73,10 @@ function compactDeep(
73
73
  }
74
74
 
75
75
  function assetGraphDiff(jsAssetGraph: AssetGraph, rustAssetGraph: AssetGraph) {
76
- const getNodes = graph => {
76
+ const getNodes = (graph) => {
77
77
  let nodes = {};
78
78
 
79
- graph.traverse(nodeId => {
79
+ graph.traverse((nodeId) => {
80
80
  let node: AssetGraphNode | null = graph.getNode(nodeId) ?? null;
81
81
  if (!node) return;
82
82