diff --git a/packages/nx/src/project-graph/nx-deps-cache.spec.ts b/packages/nx/src/project-graph/nx-deps-cache.spec.ts index 99ec136ba1de6c..9c0b81cc97d55a 100644 --- a/packages/nx/src/project-graph/nx-deps-cache.spec.ts +++ b/packages/nx/src/project-graph/nx-deps-cache.spec.ts @@ -7,6 +7,7 @@ import { import { ProjectGraph } from '../config/project-graph'; import { ProjectsConfigurations } from '../config/workspace-json-project-json'; import { NxJsonConfiguration } from '../config/nx-json'; +import { nxVersion } from '../utils/versions'; describe('nx deps utils', () => { describe('shouldRecomputeWholeGraph', () => { @@ -34,14 +35,11 @@ describe('nx deps utils', () => { ).toEqual(true); }); - it('should be true when version of nrwl/workspace changes', () => { + it('should be true when version of nx changes', () => { expect( shouldRecomputeWholeGraph( createCache({ - deps: { - '@nx/workspace': '12.0.1', - plugin: '1.0.0', - }, + nxVersion: '12.0.1', }), createPackageJsonDeps({}), createProjectsConfiguration({}), @@ -317,10 +315,7 @@ describe('nx deps utils', () => { function createCache(p: Partial): ProjectGraphCache { const defaults: ProjectGraphCache = { version: '5.1', - deps: { - '@nx/workspace': '12.0.0', - plugin: '1.0.0', - }, + nxVersion: nxVersion, pathMappings: { mylib: ['libs/mylib/index.ts'], }, diff --git a/packages/nx/src/project-graph/nx-deps-cache.ts b/packages/nx/src/project-graph/nx-deps-cache.ts index cdb1f9631e165e..49e1800d645c27 100644 --- a/packages/nx/src/project-graph/nx-deps-cache.ts +++ b/packages/nx/src/project-graph/nx-deps-cache.ts @@ -19,10 +19,11 @@ import { readJsonFile, writeJsonFile, } from '../utils/fileutils'; +import { nxVersion } from '../utils/versions'; export interface ProjectGraphCache { version: string; - deps: Record; + nxVersion: string; pathMappings: Record; nxJsonPlugins: { name: string; version: string }[]; pluginsConfig?: any; @@ -93,7 +94,7 @@ export function createCache( })); const newValue: ProjectGraphCache = { version: projectGraph.version || '5.1', - deps: packageJsonDeps, + nxVersion: nxVersion, // compilerOptions may not exist, especially for package-based repos pathMappings: tsConfig?.compilerOptions?.paths || {}, nxJsonPlugins, @@ -149,13 +150,7 @@ export function shouldRecomputeWholeGraph( if (cache.version !== '5.1') { return true; } - if ( - cache.deps['@nx/workspace'] !== packageJsonDeps['@nx/workspace'] || - cache.deps['@nrwl/workspace'] !== packageJsonDeps['@nrwl/workspace'] - ) { - return true; - } - if (cache.deps['nx'] !== packageJsonDeps['nx']) { + if (cache.nxVersion !== nxVersion) { return true; }