Skip to content

Commit

Permalink
fix(core): fix projectFileMap access in plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
vsavkin committed May 17, 2023
1 parent 74c5ad3 commit 1670986
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
13 changes: 5 additions & 8 deletions packages/nx/src/project-graph/build-project-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ import { readNxJson } from '../config/configuration';
import { existsSync } from 'fs';
import { PackageJson } from '../utils/package-json';

let storedProjectGraph: ProjectGraph | null = null;
let storedProjectFileMap: ProjectFileMap | null = null;
let storedAllWorkspaceFiles: FileData[] | null = null;

export function getProjectFileMap(projectGraph: ProjectGraph): {
export function getProjectFileMap(): {
projectFileMap: ProjectFileMap;
allWorkspaceFiles: FileData[];
} {
if (projectGraph === storedProjectGraph) {
if (!!storedProjectFileMap) {
return {
projectFileMap: storedProjectFileMap,
allWorkspaceFiles: storedAllWorkspaceFiles,
Expand All @@ -58,6 +57,9 @@ export async function buildProjectGraphUsingProjectFileMap(
projectGraph: ProjectGraph;
projectFileMapCache: ProjectFileMapCache;
}> {
storedProjectFileMap = projectFileMap;
storedAllWorkspaceFiles = allWorkspaceFiles;

const nxJson = readNxJson();
const projectGraphVersion = '6.0';
assertWorkspaceValidity(projectsConfigurations, nxJson);
Expand Down Expand Up @@ -106,11 +108,6 @@ export async function buildProjectGraphUsingProjectFileMap(
if (shouldWriteCache) {
writeCache(projectFileMapCache, projectGraph);
}

storedProjectGraph = projectGraph;
storedProjectFileMap = projectFileMap;
storedAllWorkspaceFiles = allWorkspaceFiles;

return {
projectGraph,
projectFileMapCache,
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/src/project-graph/project-graph-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ProjectGraphBuilder {
constructor(g?: ProjectGraph, fileMap?: ProjectFileMap) {
if (g) {
this.graph = g;
this.fileMap = fileMap || getProjectFileMap(g).projectFileMap;
this.fileMap = fileMap || getProjectFileMap().projectFileMap;
} else {
this.graph = {
nodes: {},
Expand Down
3 changes: 1 addition & 2 deletions packages/nx/src/tasks-runner/run-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@ export async function invokeTasksRunner({
if (daemonClient.enabled()) {
hasher = new DaemonBasedTaskHasher(daemonClient, runnerOptions);
} else {
const { projectFileMap, allWorkspaceFiles } =
getProjectFileMap(projectGraph);
const { projectFileMap, allWorkspaceFiles } = getProjectFileMap();
hasher = new InProcessTaskHasher(
projectFileMap,
allWorkspaceFiles,
Expand Down

1 comment on commit 1670986

@vercel
Copy link

@vercel vercel bot commented on 1670986 May 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx.dev
nx-five.vercel.app
nx-dev-git-master-nrwl.vercel.app

Please sign in to comment.