@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
@@ -85,6 +85,7 @@ export type BundleInfo = {|
85
85
  +hashReferences: Array<string>,
86
86
  +time?: number,
87
87
  +cacheKeys: CacheKeyMap,
88
+ +isLargeBlob: boolean,
88
89
  |};
89
90
 
90
91
  type CacheKeyMap = {|
@@ -126,7 +127,7 @@ export default class PackagerRunner {
126
127
  this.previousInvalidations = previousInvalidations;
127
128
  this.invalidations = new Map();
128
129
  this.pluginOptions = new PluginOptions(
129
- optionsProxy(this.options, option => {
130
+ optionsProxy(this.options, (option) => {
130
131
  let invalidation: RequestInvalidation = {
131
132
  type: 'option',
132
133
  key: option,
@@ -339,7 +340,7 @@ export default class PackagerRunner {
339
340
  bundleConfigs: Map<string, Config>,
340
341
  ): Promise<{|
341
342
  type: string,
342
- contents: Buffer | string,
343
+ contents: Blob,
343
344
  map: ?string,
344
345
  |}> {
345
346
  let packaged = await this.package(
@@ -409,7 +410,7 @@ export default class PackagerRunner {
409
410
  NamedBundle.get.bind(NamedBundle),
410
411
  this.options,
411
412
  ),
412
- getSourceMapReference: map => {
413
+ getSourceMapReference: (map) => {
413
414
  return this.getSourceMapReference(bundle, map);
414
415
  },
415
416
  options: this.pluginOptions,
@@ -466,7 +467,7 @@ export default class PackagerRunner {
466
467
  internalBundle: InternalBundle,
467
468
  internalBundleGraph: InternalBundleGraph,
468
469
  type: string,
469
- contents: Buffer | string,
470
+ contents: Blob,
470
471
  map?: ?SourceMap,
471
472
  configs: Map<string, Config>,
472
473
  bundleConfigs: Map<string, Config>,
@@ -485,7 +486,7 @@ export default class PackagerRunner {
485
486
  bundle.name,
486
487
  internalBundle.pipeline,
487
488
  );
488
- if (optimizers.length === 0) {
489
+ if (!optimizers.length) {
489
490
  return {type: bundle.type, contents, map};
490
491
  }
491
492
 
@@ -516,7 +517,7 @@ export default class PackagerRunner {
516
517
  bundleGraph,
517
518
  contents: optimized.contents,
518
519
  map: optimized.map,
519
- getSourceMapReference: map => {
520
+ getSourceMapReference: (map) => {
520
521
  return this.getSourceMapReference(bundle, map);
521
522
  },
522
523
  options: this.pluginOptions,
@@ -690,18 +691,64 @@ export default class PackagerRunner {
690
691
  return devDepHashes;
691
692
  }
692
693
 
694
+ async readFromCache(cacheKey: string): Promise<?{|
695
+ contents: Readable,
696
+ map: ?Readable,
697
+ |}> {
698
+ let contentKey = PackagerRunner.getContentKey(cacheKey);
699
+ let mapKey = PackagerRunner.getMapKey(cacheKey);
700
+
701
+ let isLargeBlob = await this.options.cache.hasLargeBlob(contentKey);
702
+ let contentExists =
703
+ isLargeBlob || (await this.options.cache.has(contentKey));
704
+ if (!contentExists) {
705
+ return null;
706
+ }
707
+
708
+ let mapExists = await this.options.cache.has(mapKey);
709
+
710
+ return {
711
+ contents: isLargeBlob
712
+ ? this.options.cache.getStream(contentKey)
713
+ : blobToStream(await this.options.cache.getBlob(contentKey)),
714
+ map: mapExists
715
+ ? blobToStream(await this.options.cache.getBlob(mapKey))
716
+ : null,
717
+ };
718
+ }
719
+
693
720
  async writeToCache(
694
721
  cacheKeys: CacheKeyMap,
695
722
  type: string,
696
- contents: Buffer | string,
723
+ contents: Blob,
697
724
  map: ?string,
698
725
  ): Promise<BundleInfo> {
699
726
  let size = 0;
700
727
  let hash;
701
728
  let hashReferences = [];
729
+ let isLargeBlob = false;
702
730
 
703
731
  // TODO: don't replace hash references in binary files??
704
- if (typeof contents === 'string') {
732
+ if (contents instanceof Readable) {
733
+ isLargeBlob = true;
734
+ let boundaryStr = '';
735
+ let h = new Hash();
736
+ await this.options.cache.setStream(
737
+ cacheKeys.content,
738
+ blobToStream(contents).pipe(
739
+ new TapStream((buf) => {
740
+ let str = boundaryStr + buf.toString();
741
+ hashReferences = hashReferences.concat(
742
+ str.match(HASH_REF_REGEX) ?? [],
743
+ );
744
+ size += buf.length;
745
+ h.writeBuffer(buf);
746
+ boundaryStr = str.slice(str.length - BOUNDARY_LENGTH);
747
+ }),
748
+ ),
749
+ );
750
+ hash = h.finish();
751
+ } else if (typeof contents === 'string') {
705
752
  let buffer = Buffer.from(contents);
706
753
  size = buffer.byteLength;
707
754
  hash = hashBuffer(buffer);
@@ -723,6 +770,7 @@ export default class PackagerRunner {
723
770
  hash,
724
771
  hashReferences,
725
772
  cacheKeys,
773
+ isLargeBlob,
726
774
  };
727
775
  await this.options.cache.set(cacheKeys.info, info);
728
776
  return info;
@@ -45,8 +45,8 @@ export default class ReporterRunner {
45
45
  this.workerFarm = opts.workerFarm;
46
46
  this.pluginOptions = new PluginOptions(this.options);
47
47
 
48
- logger.onLog(event => this.report(event));
49
- tracer.onTrace(event => this.report(event));
48
+ logger.onLog((event) => this.report(event));
49
+ tracer.onTrace((event) => this.report(event));
50
50
 
51
51
  bus.on('reporterEvent', this.eventHandler);
52
52
  instances.add(this);
@@ -58,7 +58,7 @@ export default class ReporterRunner {
58
58
  }
59
59
  }
60
60
 
61
- eventHandler: ReporterEvent => void = (event): void => {
61
+ eventHandler: (ReporterEvent) => void = (event): void => {
62
62
  if (
63
63
  event.type === 'buildProgress' &&
64
64
  (event.phase === 'optimizing' || event.phase === 'packaging') &&
@@ -154,5 +154,5 @@ export function reportWorker(workerApi: WorkerApi, event: ReporterEvent) {
154
154
  }
155
155
 
156
156
  export async function report(event: ReporterEvent): Promise<void> {
157
- await Promise.all([...instances].map(instance => instance.report(event)));
157
+ await Promise.all([...instances].map((instance) => instance.report(event)));
158
158
  }
@@ -210,9 +210,9 @@ type RequestGraphNode =
210
210
  | ConfigKeyNode;
211
211
 
212
212
  export type RunAPI<TResult: RequestResult> = {|
213
- invalidateOnFileCreate: InternalFileCreateInvalidation => void,
214
- invalidateOnFileDelete: ProjectPath => void,
215
- invalidateOnFileUpdate: ProjectPath => void,
213
+ invalidateOnFileCreate: (InternalFileCreateInvalidation) => void,
214
+ invalidateOnFileDelete: (ProjectPath) => void,
215
+ invalidateOnFileUpdate: (ProjectPath) => void,
216
216
  invalidateOnConfigKeyChange: (
217
217
  filePath: ProjectPath,
218
218
  configKey: string,
@@ -220,8 +220,8 @@ export type RunAPI<TResult: RequestResult> = {|
220
220
  ) => void,
221
221
  invalidateOnStartup: () => void,
222
222
  invalidateOnBuild: () => void,
223
- invalidateOnEnvChange: string => void,
224
- invalidateOnOptionChange: string => void,
223
+ invalidateOnEnvChange: (string) => void,
224
+ invalidateOnOptionChange: (string) => void,
225
225
  getInvalidations(): Array<RequestInvalidation>,
226
226
  storeResult(result: TResult, cacheKey?: string): void,
227
227
  getRequestResult<T: RequestResult>(contentKey: ContentKey): Async<?T>,
@@ -761,7 +761,7 @@ export class RequestGraph extends ContentGraph<
761
761
  requestGraphEdgeTypes.invalidated_by_update,
762
762
  );
763
763
  return invalidations
764
- .map(nodeId => {
764
+ .map((nodeId) => {
765
765
  let node = nullthrows(this.getNode(nodeId));
766
766
  switch (node.type) {
767
767
  case FILE:
@@ -788,7 +788,7 @@ export class RequestGraph extends ContentGraph<
788
788
  requestGraphEdgeTypes.subrequest,
789
789
  );
790
790
 
791
- return subRequests.map(nodeId => {
791
+ return subRequests.map((nodeId) => {
792
792
  let node = nullthrows(this.getNode(nodeId));
793
793
  invariant(node.type === REQUEST);
794
794
  return node;
@@ -806,8 +806,8 @@ export class RequestGraph extends ContentGraph<
806
806
  );
807
807
 
808
808
  return subRequests
809
- .filter(id => this.invalidNodeIds.has(id))
810
- .map(nodeId => {
809
+ .filter((id) => this.invalidNodeIds.has(id))
810
+ .map((nodeId) => {
811
811
  let node = nullthrows(this.getNode(nodeId));
812
812
  invariant(node.type === REQUEST);
813
813
  return node;
@@ -920,7 +920,7 @@ export class RequestGraph extends ContentGraph<
920
920
  this.invalidateNode(nodeId, reason);
921
921
  };
922
922
  const aboveCache = new Map();
923
- const getAbove = fileNameNodeId => {
923
+ const getAbove = (fileNameNodeId) => {
924
924
  const cachedResult = aboveCache.get(fileNameNodeId);
925
925
  if (enableOptimization && cachedResult) {
926
926
  return cachedResult;
@@ -1390,7 +1390,7 @@ export default class RequestTracker {
1390
1390
  ): {|api: RunAPI<TResult>, subRequestContentKeys: Set<ContentKey>|} {
1391
1391
  let subRequestContentKeys = new Set<ContentKey>();
1392
1392
  let api: RunAPI<TResult> = {
1393
- invalidateOnFileCreate: input =>
1393
+ invalidateOnFileCreate: (input) =>
1394
1394
  this.graph.invalidateOnFileCreate(requestId, input),
1395
1395
  invalidateOnConfigKeyChange: (filePath, configKey, contentHash) =>
1396
1396
  this.graph.invalidateOnConfigKeyChange(
@@ -1399,15 +1399,15 @@ export default class RequestTracker {
1399
1399
  configKey,
1400
1400
  contentHash,
1401
1401
  ),
1402
- invalidateOnFileDelete: filePath =>
1402
+ invalidateOnFileDelete: (filePath) =>
1403
1403
  this.graph.invalidateOnFileDelete(requestId, filePath),
1404
- invalidateOnFileUpdate: filePath =>
1404
+ invalidateOnFileUpdate: (filePath) =>
1405
1405
  this.graph.invalidateOnFileUpdate(requestId, filePath),
1406
1406
  invalidateOnStartup: () => this.graph.invalidateOnStartup(requestId),
1407
1407
  invalidateOnBuild: () => this.graph.invalidateOnBuild(requestId),
1408
- invalidateOnEnvChange: env =>
1408
+ invalidateOnEnvChange: (env) =>
1409
1409
  this.graph.invalidateOnEnvChange(requestId, env, this.options.env[env]),
1410
- invalidateOnOptionChange: option =>
1410
+ invalidateOnOptionChange: (option) =>
1411
1411
  this.graph.invalidateOnOptionChange(
1412
1412
  requestId,
1413
1413
  option,
@@ -1425,7 +1425,7 @@ export default class RequestTracker {
1425
1425
  },
1426
1426
  getRequestResult: <T: RequestResult>(id): Async<?T> =>
1427
1427
  this.getRequestResult<T>(id),
1428
- canSkipSubrequest: contentKey => {
1428
+ canSkipSubrequest: (contentKey) => {
1429
1429
  if (
1430
1430
  this.graph.hasContentKey(contentKey) &&
1431
1431
  this.hasValidResult(this.graph.getNodeIdByContentKey(contentKey))
@@ -1611,7 +1611,7 @@ export function getWatcherOptions({
1611
1611
  }: AtlaspackOptions): WatcherOptions {
1612
1612
  const vcsDirs = ['.git', '.hg'];
1613
1613
  const uniqueDirs = [...new Set([...watchIgnore, ...vcsDirs, cacheDir])];
1614
- const ignore = uniqueDirs.map(dir => path.resolve(watchDir, dir));
1614
+ const ignore = uniqueDirs.map((dir) => path.resolve(watchDir, dir));
1615
1615
 
1616
1616
  return {ignore, backend: watchBackend};
1617
1617
  }
@@ -1787,7 +1787,7 @@ export function cleanUpOrphans<N, E: number>(graph: Graph<N, E>): NodeId[] {
1787
1787
  }
1788
1788
 
1789
1789
  const reachableNodes = new Set();
1790
- graph.traverse(nodeId => {
1790
+ graph.traverse((nodeId) => {
1791
1791
  reachableNodes.add(nodeId);
1792
1792
  });
1793
1793
 
@@ -33,7 +33,7 @@ export function propagateSymbols({
33
33
  previousErrors?: ?Map<NodeId, Array<Diagnostic>>,
34
34
  |}): Map<NodeId, Array<Diagnostic>> {
35
35
  let changedAssets = new Set(
36
- [...changedAssetsPropagation].map(id =>
36
+ [...changedAssetsPropagation].map((id) =>
37
37
  assetGraph.getNodeIdByContentKey(id),
38
38
  ),
39
39
  );
@@ -80,7 +80,7 @@ export function propagateSymbols({
80
80
  }
81
81
  }
82
82
  let hasNamespaceOutgoingDeps = outgoingDeps.some(
83
- d => d.value.symbols?.get('*')?.local === '*',
83
+ (d) => d.value.symbols?.get('*')?.local === '*',
84
84
  );
85
85
 
86
86
  // 1) Determine what the incomingDeps requests from the asset
@@ -196,18 +196,18 @@ export function propagateSymbols({
196
196
  // we need everything
197
197
  depUsedSymbolsDown.add(symbol);
198
198
 
199
- [...reexportedExportSymbols].forEach(s =>
199
+ [...reexportedExportSymbols].forEach((s) =>
200
200
  assetNode.usedSymbols.delete(s),
201
201
  );
202
202
  } else {
203
203
  let usedReexportedExportSymbols = [
204
204
  ...reexportedExportSymbols,
205
- ].filter(s => assetNode.usedSymbols.has(s));
205
+ ].filter((s) => assetNode.usedSymbols.has(s));
206
206
  if (usedReexportedExportSymbols.length > 0) {
207
207
  // The symbol is indeed a reexport, so it's not used from the asset itself
208
208
  depUsedSymbolsDown.add(symbol);
209
209
 
210
- usedReexportedExportSymbols.forEach(s =>
210
+ usedReexportedExportSymbols.forEach((s) =>
211
211
  assetNode.usedSymbols.delete(s),
212
212
  );
213
213
  }
@@ -341,7 +341,7 @@ export function propagateSymbols({
341
341
 
342
342
  let reexported = assetSymbolsInverse?.get(local);
343
343
  if (reexported != null) {
344
- reexported.forEach(s => {
344
+ reexported.forEach((s) => {
345
345
  // see same code above
346
346
  if (reexportedSymbols.has(s)) {
347
347
  if (!assetNode.usedSymbols.has('*')) {
@@ -558,16 +558,8 @@ function propagateSymbolsDown(
558
558
  } else if (node.type === 'asset' && node.usedSymbolsDownDirty) {
559
559
  visit(
560
560
  node,
561
- assetGraph.getIncomingDependencies(node.value).map(d => {
562
- let dep = assetGraph.getNodeByContentKey(d.id);
563
- invariant(dep && dep.type === 'dependency');
564
- return dep;
565
- }),
566
- outgoing.map(dep => {
567
- let depNode = nullthrows(assetGraph.getNode(dep));
568
- invariant(depNode.type === 'dependency');
569
- return depNode;
570
- }),
561
+ incomingDependencyNodesFromAsset(assetGraph, node.value),
562
+ dependencyNodesFromIds(assetGraph, outgoing),
571
563
  );
572
564
  node.usedSymbolsDownDirty = false;
573
565
  }
@@ -623,7 +615,7 @@ function propagateSymbolsUp(
623
615
  let changedDepsUsedSymbolsUpDirtyDownAssets = new Set([
624
616
  ...[...changedDepsUsedSymbolsUpDirtyDown]
625
617
  .reverse()
626
- .flatMap(id => getDependencyResolution(assetGraph, id)),
618
+ .flatMap((id) => getDependencyResolution(assetGraph, id)),
627
619
  ...changedAssets,
628
620
  ]);
629
621
 
@@ -643,27 +635,18 @@ function propagateSymbolsUp(
643
635
  'A root node is required to traverse',
644
636
  );
645
637
 
646
- const nodeVisitor = nodeId => {
638
+ const nodeVisitor = (nodeId) => {
647
639
  let node = nullthrows(assetGraph.getNode(nodeId));
648
- let outgoing = assetGraph.getNodeIdsConnectedFrom(nodeId);
649
640
 
650
- for (let childId of outgoing) {
651
- let child = nullthrows(assetGraph.getNode(childId));
652
- if (node.type === 'asset') {
653
- invariant(child.type === 'dependency');
641
+ if (node.type === 'asset') {
642
+ let outgoing = outgoingDependencyNodesFromAsset(assetGraph, nodeId);
643
+ for (let child of outgoing) {
654
644
  if (child.usedSymbolsUpDirtyUp) {
655
645
  node.usedSymbolsUpDirty = true;
656
646
  child.usedSymbolsUpDirtyUp = false;
657
647
  }
658
648
  }
659
- }
660
-
661
- if (node.type === 'asset') {
662
- let incoming = assetGraph.getIncomingDependencies(node.value).map(d => {
663
- let n = assetGraph.getNodeByContentKey(d.id);
664
- invariant(n && n.type === 'dependency');
665
- return n;
666
- });
649
+ let incoming = incomingDependencyNodesFromAsset(assetGraph, node.value);
667
650
  for (let dep of incoming) {
668
651
  if (dep.usedSymbolsUpDirtyDown) {
669
652
  dep.usedSymbolsUpDirtyDown = false;
@@ -671,15 +654,7 @@ function propagateSymbolsUp(
671
654
  }
672
655
  }
673
656
  if (node.usedSymbolsUpDirty) {
674
- let e = visit(
675
- node,
676
- incoming,
677
- outgoing.map(depNodeId => {
678
- let depNode = nullthrows(assetGraph.getNode(depNodeId));
679
- invariant(depNode.type === 'dependency');
680
- return depNode;
681
- }),
682
- );
657
+ let e = visit(node, incoming, outgoing);
683
658
  if (e.length > 0) {
684
659
  node.usedSymbolsUpDirty = true;
685
660
  errors.set(nodeId, e);
@@ -706,24 +681,14 @@ function propagateSymbolsUp(
706
681
  let queuedNodeId = setPop(queue);
707
682
  let node = nullthrows(assetGraph.getNode(queuedNodeId));
708
683
  if (node.type === 'asset') {
709
- let incoming = assetGraph.getIncomingDependencies(node.value).map(dep => {
710
- let depNode = assetGraph.getNodeByContentKey(dep.id);
711
- invariant(depNode && depNode.type === 'dependency');
712
- return depNode;
713
- });
684
+ let incoming = incomingDependencyNodesFromAsset(assetGraph, node.value);
714
685
  for (let dep of incoming) {
715
686
  if (dep.usedSymbolsUpDirtyDown) {
716
687
  dep.usedSymbolsUpDirtyDown = false;
717
688
  node.usedSymbolsUpDirty = true;
718
689
  }
719
690
  }
720
- let outgoing = assetGraph
721
- .getNodeIdsConnectedFrom(queuedNodeId)
722
- .map(depNodeId => {
723
- let depNode = nullthrows(assetGraph.getNode(depNodeId));
724
- invariant(depNode.type === 'dependency');
725
- return depNode;
726
- });
691
+ let outgoing = outgoingDependencyNodesFromAsset(assetGraph, queuedNodeId);
727
692
  for (let dep of outgoing) {
728
693
  if (dep.usedSymbolsUpDirtyUp) {
729
694
  node.usedSymbolsUpDirty = true;
@@ -795,3 +760,26 @@ function setPop<T>(set: Set<T>): T {
795
760
  set.delete(v);
796
761
  return v;
797
762
  }
763
+
764
+ function outgoingDependencyNodesFromAsset(assetGraph, assetNode) {
765
+ return dependencyNodesFromIds(
766
+ assetGraph,
767
+ assetGraph.getNodeIdsConnectedFrom(assetNode),
768
+ );
769
+ }
770
+
771
+ function dependencyNodesFromIds(assetGraph, dependencyIds) {
772
+ return dependencyIds.map((depNodeId) => {
773
+ let depNode = nullthrows(assetGraph.getNode(depNodeId));
774
+ invariant(depNode.type === 'dependency');
775
+ return depNode;
776
+ });
777
+ }
778
+
779
+ function incomingDependencyNodesFromAsset(assetGraph, assetNodeValue) {
780
+ return assetGraph.getIncomingDependencies(assetNodeValue).map((d) => {
781
+ let n = assetGraph.getNodeByContentKey(d.id);
782
+ invariant(n && n.type === 'dependency');
783
+ return n;
784
+ });
785
+ }
@@ -121,10 +121,10 @@ export default class Transformation {
121
121
  this.pluginOptions = new PluginOptions(
122
122
  optionsProxy(
123
123
  this.options,
124
- option => {
124
+ (option) => {
125
125
  this.invalidations.invalidateOnOptionChange.add(option);
126
126
  },
127
- devDep => {
127
+ (devDep) => {
128
128
  this.pluginDevDeps.push(devDep);
129
129
  },
130
130
  ),
@@ -181,8 +181,8 @@ export default class Transformation {
181
181
  let assets, error;
182
182
  try {
183
183
  let results = await this.runPipelines(pipeline, asset);
184
- await Promise.all(results.map(asset => asset.commit()));
185
- assets = results.map(a => a.value);
184
+ await Promise.all(results.map((asset) => asset.commit()));
185
+ assets = results.map((a) => a.value);
186
186
  } catch (e) {
187
187
  error = e;
188
188
  }
@@ -440,7 +440,7 @@ export default class Transformation {
440
440
  await Promise.all(
441
441
  resultingAssets
442
442
  .filter(
443
- asset =>
443
+ (asset) =>
444
444
  asset.ast != null &&
445
445
  !(
446
446
  this.options.mode === 'production' &&
@@ -448,7 +448,7 @@ export default class Transformation {
448
448
  asset.value.symbols
449
449
  ),
450
450
  )
451
- .map(async asset => {
451
+ .map(async (asset) => {
452
452
  if (asset.isASTDirty && asset.generate) {
453
453
  let output = await asset.generate();
454
454
  asset.content = output.content;
@@ -481,8 +481,8 @@ export default class Transformation {
481
481
  }
482
482
 
483
483
  return {
484
- id: transformers.map(t => t.name).join(':'),
485
- transformers: transformers.map(transformer => ({
484
+ id: transformers.map((t) => t.name).join(':'),
485
+ transformers: transformers.map((transformer) => ({
486
486
  name: transformer.name,
487
487
  resolveFrom: transformer.resolveFrom,
488
488
  config: this.configs.get(transformer.name)?.result,
@@ -584,7 +584,7 @@ export default class Transformation {
584
584
 
585
585
  if (result.invalidateOnFileCreate) {
586
586
  this.invalidations.invalidateOnFileCreate.push(
587
- ...result.invalidateOnFileCreate.map(i =>
587
+ ...result.invalidateOnFileCreate.map((i) =>
588
588
  invalidateOnFileCreateToInternal(this.options.projectRoot, i),
589
589
  ),
590
590
  );
@@ -686,7 +686,7 @@ export default class Transformation {
686
686
  assets: Array<UncommittedAsset>,
687
687
  ): Promise<Array<UncommittedAsset> | null> => {
688
688
  let results = await postProcess.call(transformer, {
689
- assets: assets.map(asset => new MutableAsset(asset)),
689
+ assets: assets.map((asset) => new MutableAsset(asset)),
690
690
  config,
691
691
  options: pipeline.pluginOptions,
692
692
  resolve,
@@ -695,7 +695,7 @@ export default class Transformation {
695
695
  });
696
696
 
697
697
  return Promise.all(
698
- results.map(result =>
698
+ results.map((result) =>
699
699
  asset.createChildAsset(
700
700
  result,
701
701
  transformerName,
@@ -734,7 +734,7 @@ function normalizeAssets(
734
734
  options,
735
735
  results: Array<TransformerResult | MutableAsset>,
736
736
  ): Array<TransformerResult | UncommittedAsset> {
737
- return results.map(result => {
737
+ return results.map((result) => {
738
738
  if (result instanceof MutableAsset) {
739
739
  return mutableAssetToUncommittedAsset(result);
740
740
  }
@@ -99,7 +99,7 @@ export default class UncommittedAsset {
99
99
  await Promise.all([
100
100
  contentKey != null &&
101
101
  this.commitContent(contentKey).then(
102
- s => ((size = s.size), (outputHash = s.hash)),
102
+ (s) => ((size = s.size), (outputHash = s.hash)),
103
103
  ),
104
104
  this.mapBuffer != null &&
105
105
  mapKey != null &&
@@ -134,7 +134,7 @@ export default class UncommittedAsset {
134
134
  await this.options.cache.setStream(
135
135
  contentKey,
136
136
  content.pipe(
137
- new TapStream(buf => {
137
+ new TapStream((buf) => {
138
138
  hash.writeBuffer(buf);
139
139
  size += buf.length;
140
140
  }),
package/src/Validation.js CHANGED
@@ -62,7 +62,7 @@ export default class Validation {
62
62
  let pluginOptions = new PluginOptions(this.options);
63
63
  await this.buildAssetsAndValidators();
64
64
  await Promise.all(
65
- Object.keys(this.allValidators).map(async validatorName => {
65
+ Object.keys(this.allValidators).map(async (validatorName) => {
66
66
  let assets = this.allAssets[validatorName];
67
67
  if (assets) {
68
68
  let plugin = this.allValidators[validatorName];
@@ -76,7 +76,7 @@ export default class Validation {
76
76
  // If the plugin supports the single-threading validateAll method, pass all assets to it.
77
77
  if (plugin.validateAll && this.dedicatedThread) {
78
78
  validatorResults = await plugin.validateAll({
79
- assets: assets.map(asset => new Asset(asset)),
79
+ assets: assets.map((asset) => new Asset(asset)),
80
80
  options: pluginOptions,
81
81
  logger: validatorLogger,
82
82
  tracer: validatorTracer,
@@ -96,7 +96,7 @@ export default class Validation {
96
96
  // Otherwise, pass the assets one-at-a-time
97
97
  else if (plugin.validate && !this.dedicatedThread) {
98
98
  await Promise.all(
99
- assets.map(async input => {
99
+ assets.map(async (input) => {
100
100
  let config = null;
101
101
  let publicAsset = new Asset(input);
102
102
  if (plugin.getConfig) {
@@ -142,7 +142,7 @@ export default class Validation {
142
142
  async buildAssetsAndValidators() {
143
143
  // Figure out what validators need to be run, and group the assets by the relevant validators.
144
144
  await Promise.all(
145
- this.requests.map(async request => {
145
+ this.requests.map(async (request) => {
146
146
  this.report({
147
147
  type: 'validation',
148
148
  filePath: fromProjectPath(this.options.projectRoot, request.filePath),
@@ -169,7 +169,7 @@ export default class Validation {
169
169
  handleResults(validatorResults: Array<?ValidateResult>) {
170
170
  let warnings: Array<Diagnostic> = [];
171
171
  let errors: Array<Diagnostic> = [];
172
- validatorResults.forEach(result => {
172
+ validatorResults.forEach((result) => {
173
173
  if (result) {
174
174
  warnings.push(...result.warnings);
175
175
  errors.push(...result.errors);
@@ -320,7 +320,7 @@ export default async function applyRuntimes<TResult: RequestResult>({
320
320
 
321
321
  let assets = runtimesBundleGraph._graph
322
322
  .getNodeIdsConnectedFrom(nodeId)
323
- .map(assetNodeId => {
323
+ .map((assetNodeId) => {
324
324
  let assetNode = nullthrows(
325
325
  runtimesBundleGraph._graph.getNode(assetNodeId),
326
326
  );
@@ -393,7 +393,7 @@ function reconcileNewRuntimes<TResult: RequestResult>(
393
393
  connections: Array<RuntimeConnection>,
394
394
  optionsRef: SharedReference,
395
395
  ) {
396
- let assetGroups = connections.map(t => t.assetGroup);
396
+ let assetGroups = connections.map((t) => t.assetGroup);
397
397
  let request = createAssetGraphRequest({
398
398
  name: 'Runtimes',
399
399
  assetGroups,
package/src/assetUtils.js CHANGED
@@ -70,7 +70,7 @@ export type AssetOptions = {|
70
70
 
71
71
  export function createAssetIdFromOptions(options: AssetOptions): string {
72
72
  return createAssetIdRust({
73
- env: options.env,
73
+ environmentId: options.env.id,
74
74
  filePath: options.filePath,
75
75
  code: options.code,
76
76
  pipeline: options.pipeline,
@@ -57,7 +57,7 @@ export class AtlaspackV3 {
57
57
 
58
58
  return [
59
59
  workers,
60
- tx_worker => {
60
+ (tx_worker) => {
61
61
  let worker = new Worker(WORKER_PATH, {
62
62
  workerData: {
63
63
  tx_worker,