Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce redundancy in the RequestGraph's file nodes #9360

Merged
merged 8 commits into from
Nov 3, 2023
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