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

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 (70) hide show
  1. package/lib/AssetGraph.js +1 -2
  2. package/lib/Atlaspack.js +25 -3
  3. package/lib/AtlaspackConfig.schema.js +10 -36
  4. package/lib/BundleGraph.js +59 -5
  5. package/lib/Dependency.js +46 -1
  6. package/lib/Environment.js +12 -2
  7. package/lib/PackagerRunner.js +3 -45
  8. package/lib/RequestTracker.js +112 -30
  9. package/lib/SymbolPropagation.js +1 -1
  10. package/lib/Transformation.js +1 -15
  11. package/lib/UncommittedAsset.js +4 -4
  12. package/lib/Validation.js +1 -13
  13. package/lib/applyRuntimes.js +96 -20
  14. package/lib/assetUtils.js +9 -3
  15. package/lib/atlaspack-v3/AtlaspackV3.js +6 -8
  16. package/lib/atlaspack-v3/fs.js +8 -1
  17. package/lib/atlaspack-v3/worker/compat.js +57 -0
  18. package/lib/atlaspack-v3/worker/worker.js +156 -1
  19. package/lib/public/BundleGraph.js +68 -0
  20. package/lib/requests/AssetGraphRequestRust.js +79 -12
  21. package/lib/requests/BundleGraphRequest.js +19 -0
  22. package/lib/requests/WriteBundleRequest.js +15 -15
  23. package/lib/requests/asset-graph-diff.js +128 -0
  24. package/lib/resolveOptions.js +15 -8
  25. package/lib/types.js +2 -1
  26. package/package.json +19 -17
  27. package/src/AssetGraph.js +1 -1
  28. package/src/Atlaspack.js +28 -6
  29. package/src/AtlaspackConfig.schema.js +13 -36
  30. package/src/BundleGraph.js +77 -1
  31. package/src/CommittedAsset.js +1 -1
  32. package/src/Dependency.js +50 -12
  33. package/src/Environment.js +13 -15
  34. package/src/PackagerRunner.js +5 -53
  35. package/src/RequestTracker.js +144 -38
  36. package/src/SymbolPropagation.js +5 -2
  37. package/src/Transformation.js +1 -9
  38. package/src/UncommittedAsset.js +6 -6
  39. package/src/Validation.js +1 -7
  40. package/src/applyRuntimes.js +86 -22
  41. package/src/assetUtils.js +12 -19
  42. package/src/atlaspack-v3/AtlaspackV3.js +8 -11
  43. package/src/atlaspack-v3/fs.js +8 -3
  44. package/src/atlaspack-v3/jsCallable.js +4 -0
  45. package/src/atlaspack-v3/worker/compat.js +82 -0
  46. package/src/atlaspack-v3/worker/worker.js +209 -2
  47. package/src/public/BundleGraph.js +106 -0
  48. package/src/requests/AssetGraphRequestRust.js +105 -17
  49. package/src/requests/BundleGraphRequest.js +18 -0
  50. package/src/requests/WriteBundleRequest.js +17 -23
  51. package/src/requests/asset-graph-diff.js +145 -0
  52. package/src/resolveOptions.js +12 -2
  53. package/src/types.js +10 -0
  54. package/test/AssetGraph.test.js +23 -9
  55. package/test/AtlaspackConfigRequest.test.js +0 -161
  56. package/test/BundleGraph.test.js +8 -3
  57. package/test/Dependency.test.js +21 -0
  58. package/test/Environment.test.js +16 -5
  59. package/test/InternalAsset.test.js +8 -2
  60. package/test/PublicAsset.test.js +6 -2
  61. package/test/PublicBundle.test.js +1 -0
  62. package/test/PublicMutableBundleGraph.test.js +9 -4
  63. package/test/RequestTracker.test.js +139 -2
  64. package/test/SymbolPropagation.test.js +1 -0
  65. package/test/TargetRequest.test.js +25 -25
  66. package/test/requests/WriteBundleRequest.test.js +132 -0
  67. package/lib/atlaspack-v3/plugins/Resolver.js +0 -12
  68. package/lib/atlaspack-v3/plugins/index.js +0 -16
  69. package/src/atlaspack-v3/plugins/Resolver.js +0 -9
  70. package/src/atlaspack-v3/plugins/index.js +0 -3
@@ -85,7 +85,6 @@ export type BundleInfo = {|
85
85
  +hashReferences: Array<string>,
86
86
  +time?: number,
87
87
  +cacheKeys: CacheKeyMap,
88
- +isLargeBlob: boolean,
89
88
  |};
90
89
 
91
90
  type CacheKeyMap = {|
@@ -340,7 +339,7 @@ export default class PackagerRunner {
340
339
  bundleConfigs: Map<string, Config>,
341
340
  ): Promise<{|
342
341
  type: string,
343
- contents: Blob,
342
+ contents: Buffer | string,
344
343
  map: ?string,
345
344
  |}> {
346
345
  let packaged = await this.package(
@@ -467,7 +466,7 @@ export default class PackagerRunner {
467
466
  internalBundle: InternalBundle,
468
467
  internalBundleGraph: InternalBundleGraph,
469
468
  type: string,
470
- contents: Blob,
469
+ contents: Buffer | string,
471
470
  map?: ?SourceMap,
472
471
  configs: Map<string, Config>,
473
472
  bundleConfigs: Map<string, Config>,
@@ -486,7 +485,7 @@ export default class PackagerRunner {
486
485
  bundle.name,
487
486
  internalBundle.pipeline,
488
487
  );
489
- if (!optimizers.length) {
488
+ if (optimizers.length === 0) {
490
489
  return {type: bundle.type, contents, map};
491
490
  }
492
491
 
@@ -691,64 +690,18 @@ export default class PackagerRunner {
691
690
  return devDepHashes;
692
691
  }
693
692
 
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
-
720
693
  async writeToCache(
721
694
  cacheKeys: CacheKeyMap,
722
695
  type: string,
723
- contents: Blob,
696
+ contents: Buffer | string,
724
697
  map: ?string,
725
698
  ): Promise<BundleInfo> {
726
699
  let size = 0;
727
700
  let hash;
728
701
  let hashReferences = [];
729
- let isLargeBlob = false;
730
702
 
731
703
  // TODO: don't replace hash references in binary files??
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') {
704
+ if (typeof contents === 'string') {
752
705
  let buffer = Buffer.from(contents);
753
706
  size = buffer.byteLength;
754
707
  hash = hashBuffer(buffer);
@@ -770,7 +723,6 @@ export default class PackagerRunner {
770
723
  hash,
771
724
  hashReferences,
772
725
  cacheKeys,
773
- isLargeBlob,
774
726
  };
775
727
  await this.options.cache.set(cacheKeys.info, info);
776
728
  return info;
@@ -4,12 +4,14 @@ import invariant, {AssertionError} from 'assert';
4
4
  import path from 'path';
5
5
 
6
6
  import type {Cache} from '@atlaspack/cache';
7
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
7
8
  import {ContentGraph} from '@atlaspack/graph';
8
9
  import type {
9
10
  ContentGraphOpts,
10
11
  ContentKey,
11
12
  NodeId,
12
13
  SerializedContentGraph,
14
+ Graph,
13
15
  } from '@atlaspack/graph';
14
16
  import logger from '@atlaspack/logger';
15
17
  import {hashString} from '@atlaspack/rust';
@@ -370,7 +372,7 @@ export class RequestGraph extends ContentGraph<
370
372
  return nodeId;
371
373
  }
372
374
 
373
- removeNode(nodeId: NodeId): void {
375
+ removeNode(nodeId: NodeId, removeOrphans: boolean = true): void {
374
376
  this.invalidNodeIds.delete(nodeId);
375
377
  this.incompleteNodeIds.delete(nodeId);
376
378
  this.incompleteNodePromises.delete(nodeId);
@@ -388,7 +390,7 @@ export class RequestGraph extends ContentGraph<
388
390
  configKeyNodes.delete(nodeId);
389
391
  }
390
392
  }
391
- return super.removeNode(nodeId);
393
+ return super.removeNode(nodeId, removeOrphans);
392
394
  }
393
395
 
394
396
  getRequestNode(nodeId: NodeId): RequestNode {
@@ -816,32 +818,59 @@ export class RequestGraph extends ContentGraph<
816
818
  node: FileNameNode,
817
819
  filePath: ProjectPath,
818
820
  matchNodes: Array<FileNode>,
821
+ invalidateNode: (NodeId, InvalidateReason) => void,
819
822
  ) {
820
823
  // If there is an edge between this file_name node and one of the original file nodes pointed to
821
824
  // by the original file_name node, and the matched node is inside the current directory, invalidate
822
825
  // all connected requests pointed to by the file node.
823
- let dirname = path.dirname(fromProjectPathRelative(filePath));
824
826
 
825
827
  let nodeId = this.getNodeIdByContentKey(node.id);
826
- for (let matchNode of matchNodes) {
827
- let matchNodeId = this.getNodeIdByContentKey(matchNode.id);
828
- if (
829
- this.hasEdge(
830
- nodeId,
831
- matchNodeId,
832
- requestGraphEdgeTypes.invalidated_by_create_above,
833
- ) &&
834
- isDirectoryInside(
835
- fromProjectPathRelative(toProjectPathUnsafe(matchNode.id)),
836
- dirname,
828
+ let dirname = path.dirname(fromProjectPathRelative(filePath));
829
+
830
+ if (getFeatureFlag('fixQuadraticCacheInvalidation')) {
831
+ while (dirname !== '/') {
832
+ if (!this.hasContentKey(dirname)) break;
833
+ const matchNodeId = this.getNodeIdByContentKey(dirname);
834
+ if (
835
+ !this.hasEdge(
836
+ nodeId,
837
+ matchNodeId,
838
+ requestGraphEdgeTypes.invalidated_by_create_above,
839
+ )
837
840
  )
838
- ) {
839
- let connectedNodes = this.getNodeIdsConnectedTo(
841
+ break;
842
+
843
+ const connectedNodes = this.getNodeIdsConnectedTo(
840
844
  matchNodeId,
841
845
  requestGraphEdgeTypes.invalidated_by_create,
842
846
  );
843
847
  for (let connectedNode of connectedNodes) {
844
- this.invalidateNode(connectedNode, FILE_CREATE);
848
+ invalidateNode(connectedNode, FILE_CREATE);
849
+ }
850
+
851
+ dirname = path.dirname(dirname);
852
+ }
853
+ } else {
854
+ for (let matchNode of matchNodes) {
855
+ let matchNodeId = this.getNodeIdByContentKey(matchNode.id);
856
+ if (
857
+ this.hasEdge(
858
+ nodeId,
859
+ matchNodeId,
860
+ requestGraphEdgeTypes.invalidated_by_create_above,
861
+ ) &&
862
+ isDirectoryInside(
863
+ fromProjectPathRelative(toProjectPathUnsafe(matchNode.id)),
864
+ dirname,
865
+ )
866
+ ) {
867
+ let connectedNodes = this.getNodeIdsConnectedTo(
868
+ matchNodeId,
869
+ requestGraphEdgeTypes.invalidated_by_create,
870
+ );
871
+ for (let connectedNode of connectedNodes) {
872
+ this.invalidateNode(connectedNode, FILE_CREATE);
873
+ }
845
874
  }
846
875
  }
847
876
  }
@@ -864,6 +893,7 @@ export class RequestGraph extends ContentGraph<
864
893
  parent,
865
894
  toProjectPathUnsafe(dirname),
866
895
  matchNodes,
896
+ invalidateNode,
867
897
  );
868
898
  }
869
899
  }
@@ -878,9 +908,45 @@ export class RequestGraph extends ContentGraph<
878
908
  let count = 0;
879
909
  let predictedTime = 0;
880
910
  let startTime = Date.now();
911
+ const enableOptimization = getFeatureFlag('fixQuadraticCacheInvalidation');
912
+ const removeOrphans = !enableOptimization;
913
+
914
+ const invalidatedNodes = new Set();
915
+ const invalidateNode = (nodeId, reason) => {
916
+ if (enableOptimization && invalidatedNodes.has(nodeId)) {
917
+ return;
918
+ }
919
+ invalidatedNodes.add(nodeId);
920
+ this.invalidateNode(nodeId, reason);
921
+ };
922
+ const aboveCache = new Map();
923
+ const getAbove = fileNameNodeId => {
924
+ const cachedResult = aboveCache.get(fileNameNodeId);
925
+ if (enableOptimization && cachedResult) {
926
+ return cachedResult;
927
+ }
928
+
929
+ let above = [];
930
+ const children = this.getNodeIdsConnectedTo(
931
+ fileNameNodeId,
932
+ requestGraphEdgeTypes.invalidated_by_create_above,
933
+ );
934
+ for (const nodeId of children) {
935
+ let node = nullthrows(this.getNode(nodeId));
936
+ if (node.type === FILE) {
937
+ above.push(node);
938
+ }
939
+ }
940
+ aboveCache.set(fileNameNodeId, above);
941
+ return above;
942
+ };
881
943
 
882
944
  for (let {path: _path, type} of events) {
883
- if (++count === 256) {
945
+ if (
946
+ !enableOptimization &&
947
+ process.env.ATLASPACK_DISABLE_CACHE_TIMEOUT !== 'true' &&
948
+ ++count === 256
949
+ ) {
884
950
  let duration = Date.now() - startTime;
885
951
  predictedTime = duration * (events.length >> 8);
886
952
  if (predictedTime > threshold) {
@@ -936,7 +1002,7 @@ export class RequestGraph extends ContentGraph<
936
1002
 
937
1003
  for (let connectedNode of nodes) {
938
1004
  didInvalidate = true;
939
- this.invalidateNode(connectedNode, FILE_UPDATE);
1005
+ invalidateNode(connectedNode, FILE_UPDATE);
940
1006
  }
941
1007
 
942
1008
  if (type === 'create') {
@@ -946,7 +1012,7 @@ export class RequestGraph extends ContentGraph<
946
1012
  );
947
1013
  for (let connectedNode of nodes) {
948
1014
  didInvalidate = true;
949
- this.invalidateNode(connectedNode, FILE_CREATE);
1015
+ invalidateNode(connectedNode, FILE_CREATE);
950
1016
  }
951
1017
  }
952
1018
  } else if (type === 'create') {
@@ -958,21 +1024,15 @@ export class RequestGraph extends ContentGraph<
958
1024
  );
959
1025
 
960
1026
  // Find potential file nodes to be invalidated if this file name pattern matches
961
- let above: Array<FileNode> = [];
962
- for (const nodeId of this.getNodeIdsConnectedTo(
963
- fileNameNodeId,
964
- requestGraphEdgeTypes.invalidated_by_create_above,
965
- )) {
966
- let node = nullthrows(this.getNode(nodeId));
967
- // these might also be `glob` nodes which get handled below, we only care about files here.
968
- if (node.type === FILE) {
969
- above.push(node);
970
- }
971
- }
972
-
1027
+ let above: Array<FileNode> = getAbove(fileNameNodeId);
973
1028
  if (above.length > 0) {
974
1029
  didInvalidate = true;
975
- this.invalidateFileNameNode(fileNameNode, _filePath, above);
1030
+ this.invalidateFileNameNode(
1031
+ fileNameNode,
1032
+ _filePath,
1033
+ above,
1034
+ invalidateNode,
1035
+ );
976
1036
  }
977
1037
  }
978
1038
 
@@ -987,7 +1047,7 @@ export class RequestGraph extends ContentGraph<
987
1047
  );
988
1048
  for (let connectedNode of connectedNodes) {
989
1049
  didInvalidate = true;
990
- this.invalidateNode(connectedNode, FILE_CREATE);
1050
+ invalidateNode(connectedNode, FILE_CREATE);
991
1051
  }
992
1052
  }
993
1053
  }
@@ -998,13 +1058,13 @@ export class RequestGraph extends ContentGraph<
998
1058
  requestGraphEdgeTypes.invalidated_by_delete,
999
1059
  )) {
1000
1060
  didInvalidate = true;
1001
- this.invalidateNode(connectedNode, FILE_DELETE);
1061
+ invalidateNode(connectedNode, FILE_DELETE);
1002
1062
  }
1003
1063
 
1004
1064
  // Delete the file node since it doesn't exist anymore.
1005
1065
  // This ensures that files that don't exist aren't sent
1006
1066
  // to requests as invalidations for future requests.
1007
- this.removeNode(nodeId);
1067
+ this.removeNode(nodeId, removeOrphans);
1008
1068
  }
1009
1069
 
1010
1070
  let configKeyNodes = this.configKeyNodes.get(_filePath);
@@ -1030,18 +1090,22 @@ export class RequestGraph extends ContentGraph<
1030
1090
  nodeId,
1031
1091
  requestGraphEdgeTypes.invalidated_by_update,
1032
1092
  )) {
1033
- this.invalidateNode(
1093
+ invalidateNode(
1034
1094
  connectedNode,
1035
1095
  type === 'delete' ? FILE_DELETE : FILE_UPDATE,
1036
1096
  );
1037
1097
  }
1038
1098
  didInvalidate = true;
1039
- this.removeNode(nodeId);
1099
+ this.removeNode(nodeId, removeOrphans);
1040
1100
  }
1041
1101
  }
1042
1102
  }
1043
1103
  }
1044
1104
 
1105
+ if (getFeatureFlag('fixQuadraticCacheInvalidation')) {
1106
+ cleanUpOrphans(this);
1107
+ }
1108
+
1045
1109
  let duration = Date.now() - startTime;
1046
1110
  logger.verbose({
1047
1111
  origin: '@atlaspack/core',
@@ -1050,6 +1114,8 @@ export class RequestGraph extends ContentGraph<
1050
1114
  trackableEvent: 'fsevent_response_time',
1051
1115
  duration,
1052
1116
  predictedTime,
1117
+ numberOfEvents: events.length,
1118
+ numberOfInvalidatedNodes: invalidatedNodes.size,
1053
1119
  },
1054
1120
  });
1055
1121
 
@@ -1608,6 +1674,15 @@ async function loadRequestGraph(options): Async<RequestGraph> {
1608
1674
  let timeout;
1609
1675
  const snapshotKey = `snapshot-${cacheKey}`;
1610
1676
  const snapshotPath = path.join(options.cacheDir, snapshotKey + '.txt');
1677
+
1678
+ logger.verbose({
1679
+ origin: '@atlaspack/core',
1680
+ message: 'Loading request graph',
1681
+ meta: {
1682
+ cacheKey,
1683
+ snapshotKey,
1684
+ },
1685
+ });
1611
1686
  if (await options.cache.hasLargeBlob(requestGraphKey)) {
1612
1687
  try {
1613
1688
  let {requestGraph} = await readAndDeserializeRequestGraph(
@@ -1663,8 +1738,18 @@ async function loadRequestGraph(options): Async<RequestGraph> {
1663
1738
  }
1664
1739
  }
1665
1740
 
1741
+ logger.verbose({
1742
+ origin: '@atlaspack/core',
1743
+ message:
1744
+ 'Cache entry for request tracker was not found, initializing a clean cache.',
1745
+ meta: {
1746
+ cacheKey,
1747
+ snapshotKey,
1748
+ },
1749
+ });
1666
1750
  return new RequestGraph();
1667
1751
  }
1752
+
1668
1753
  function logErrorOnBailout(
1669
1754
  options: AtlaspackOptions,
1670
1755
  snapshotPath: string,
@@ -1695,3 +1780,24 @@ function logErrorOnBailout(
1695
1780
  });
1696
1781
  }
1697
1782
  }
1783
+
1784
+ export function cleanUpOrphans<N, E: number>(graph: Graph<N, E>): NodeId[] {
1785
+ if (graph.rootNodeId == null) {
1786
+ return [];
1787
+ }
1788
+
1789
+ const reachableNodes = new Set();
1790
+ graph.traverse(nodeId => {
1791
+ reachableNodes.add(nodeId);
1792
+ });
1793
+
1794
+ const removedNodeIds = [];
1795
+ graph.nodes.forEach((_node, nodeId) => {
1796
+ if (!reachableNodes.has(nodeId)) {
1797
+ removedNodeIds.push(nodeId);
1798
+ graph.removeNode(nodeId);
1799
+ }
1800
+ });
1801
+
1802
+ return removedNodeIds;
1803
+ }
@@ -16,7 +16,7 @@ import nullthrows from 'nullthrows';
16
16
  import {setEqual} from '@atlaspack/utils';
17
17
  import logger from '@atlaspack/logger';
18
18
  import {md, convertSourceLocationToHighlight} from '@atlaspack/diagnostic';
19
- import {BundleBehavior} from './types';
19
+ import {BundleBehavior, Priority} from './types';
20
20
  import {fromProjectPathRelative, fromProjectPath} from './projectPath';
21
21
 
22
22
  export function propagateSymbols({
@@ -101,7 +101,10 @@ export function propagateSymbols({
101
101
  namespaceReexportedSymbols.add('*');
102
102
  } else {
103
103
  for (let incomingDep of incomingDeps) {
104
- if (incomingDep.value.symbols == null) {
104
+ if (
105
+ incomingDep.value.symbols == null ||
106
+ incomingDep.value.priority === Priority.conditional
107
+ ) {
105
108
  if (incomingDep.value.sourceAssetId == null) {
106
109
  // The root dependency on non-library builds
107
110
  isEntry = true;
@@ -33,7 +33,6 @@ import ThrowableDiagnostic, {
33
33
  type Diagnostic,
34
34
  } from '@atlaspack/diagnostic';
35
35
  import {SOURCEMAP_EXTENSIONS} from '@atlaspack/utils';
36
- import {hashString} from '@atlaspack/rust';
37
36
 
38
37
  import {createDependency} from './Dependency';
39
38
  import AtlaspackConfig from './AtlaspackConfig';
@@ -231,16 +230,9 @@ export default class Transformation {
231
230
  // Prefer `isSource` originating from the AssetRequest.
232
231
  let isSource = isSourceOverride ?? summarizedIsSource;
233
232
 
234
- // If the transformer request passed code, use a hash in addition
235
- // to the filename as the base for the id to ensure it is unique.
236
- let idBase = fromProjectPathRelative(filePath);
237
- if (code != null) {
238
- idBase += hashString(code);
239
- }
240
233
  return new UncommittedAsset({
241
- idBase,
242
234
  value: createAsset(this.options.projectRoot, {
243
- idBase,
235
+ code,
244
236
  filePath,
245
237
  isSource,
246
238
  type: path.extname(fromProjectPathRelative(filePath)).slice(1),
@@ -39,7 +39,7 @@ type UncommittedAssetOptions = {|
39
39
  mapBuffer?: ?Buffer,
40
40
  ast?: ?AST,
41
41
  isASTDirty?: ?boolean,
42
- idBase?: ?string,
42
+ code?: ?string,
43
43
  invalidations?: Invalidations,
44
44
  |};
45
45
 
@@ -52,7 +52,7 @@ export default class UncommittedAsset {
52
52
  map: ?SourceMap;
53
53
  ast: ?AST;
54
54
  isASTDirty: boolean;
55
- idBase: ?string;
55
+ code: ?string;
56
56
  invalidations: Invalidations;
57
57
  generate: ?() => Promise<GenerateOutput>;
58
58
 
@@ -63,7 +63,7 @@ export default class UncommittedAsset {
63
63
  mapBuffer,
64
64
  ast,
65
65
  isASTDirty,
66
- idBase,
66
+ code,
67
67
  invalidations,
68
68
  }: UncommittedAssetOptions) {
69
69
  this.value = value;
@@ -72,7 +72,7 @@ export default class UncommittedAsset {
72
72
  this.mapBuffer = mapBuffer;
73
73
  this.ast = ast;
74
74
  this.isASTDirty = isASTDirty || false;
75
- this.idBase = idBase;
75
+ this.code = code;
76
76
  this.invalidations = invalidations || createInvalidations();
77
77
  }
78
78
 
@@ -358,7 +358,7 @@ export default class UncommittedAsset {
358
358
 
359
359
  let asset = new UncommittedAsset({
360
360
  value: createAsset(this.options.projectRoot, {
361
- idBase: this.idBase,
361
+ code: this.code,
362
362
  filePath: this.value.filePath,
363
363
  type: result.type,
364
364
  bundleBehavior:
@@ -405,7 +405,7 @@ export default class UncommittedAsset {
405
405
  ast: result.ast,
406
406
  isASTDirty: result.ast === this.ast ? this.isASTDirty : true,
407
407
  mapBuffer: result.map ? result.map.toBuffer() : null,
408
- idBase: this.idBase,
408
+ code: this.code,
409
409
  invalidations: this.invalidations,
410
410
  });
411
411
 
package/src/Validation.js CHANGED
@@ -17,7 +17,6 @@ import PluginOptions from './public/PluginOptions';
17
17
  import summarizeRequest from './summarizeRequest';
18
18
  import {fromProjectPath, fromProjectPathRelative} from './projectPath';
19
19
  import {PluginTracer} from '@atlaspack/profiler';
20
- import {hashString} from '@atlaspack/rust';
21
20
 
22
21
  export type ValidationOpts = {|
23
22
  config: AtlaspackConfig,
@@ -197,14 +196,9 @@ export default class Validation {
197
196
  },
198
197
  );
199
198
 
200
- // If the transformer request passed code rather than a filename,
201
- // use a hash as the base for the id to ensure it is unique.
202
- let idBase =
203
- code != null ? hashString(code) : fromProjectPathRelative(filePath);
204
199
  return new UncommittedAsset({
205
- idBase,
206
200
  value: createAsset(this.options.projectRoot, {
207
- idBase,
201
+ code,
208
202
  filePath: filePath,
209
203
  isSource,
210
204
  type: path.extname(fromProjectPathRelative(filePath)).slice(1),