Skip to content

Commit

Permalink
Reduce redundancy in the RequestGraph's file nodes (#9360)
Browse files Browse the repository at this point in the history
* remove value objects in file nodes

* remove opaque type

* restore opaque type
  • Loading branch information
gorakong committed Nov 3, 2023
1 parent 506e762 commit 406650e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/core/core/src/RequestTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type {
import type {
ParcelOptions,
RequestInvalidation,
InternalFile,
InternalFileCreateInvalidation,
InternalGlob,
} from './types';
Expand Down Expand Up @@ -84,7 +83,7 @@ type SerializedRequestGraph = {|
invalidateOnBuildNodeIds: Set<NodeId>,
|};

type FileNode = {|id: ContentKey, +type: 'file', value: InternalFile|};
type FileNode = {|id: ContentKey, +type: 'file'|};
type GlobNode = {|id: ContentKey, +type: 'glob', value: InternalGlob|};
type FileNameNode = {|
id: ContentKey,
Expand Down Expand Up @@ -167,7 +166,6 @@ export type StaticRunOpts<TResult> = {|
const nodeFromFilePath = (filePath: ProjectPath): RequestGraphNode => ({
id: fromProjectPathRelative(filePath),
type: 'file',
value: {filePath},
});

const nodeFromGlob = (glob: InternalGlob): RequestGraphNode => ({
Expand Down Expand Up @@ -609,7 +607,7 @@ export class RequestGraph extends ContentGraph<
let node = nullthrows(this.getNode(nodeId));
switch (node.type) {
case 'file':
return {type: 'file', filePath: node.value.filePath};
return {type: 'file', filePath: toProjectPathUnsafe(node.id)};
case 'env':
return {type: 'env', key: node.value.key};
case 'option':
Expand Down Expand Up @@ -675,7 +673,7 @@ export class RequestGraph extends ContentGraph<
requestGraphEdgeTypes.invalidated_by_create_above,
) &&
isDirectoryInside(
fromProjectPathRelative(matchNode.value.filePath),
fromProjectPathRelative(toProjectPathUnsafe(matchNode.id)),
dirname,
)
) {
Expand Down

0 comments on commit 406650e

Please sign in to comment.