diff --git a/packages/nx/src/project-graph/utils/project-configuration-utils.ts b/packages/nx/src/project-graph/utils/project-configuration-utils.ts index 352ed3019d0ec..9da24d9a492c6 100644 --- a/packages/nx/src/project-graph/utils/project-configuration-utils.ts +++ b/packages/nx/src/project-graph/utils/project-configuration-utils.ts @@ -1,7 +1,5 @@ import { basename } from 'node:path'; -import { getNxPackageJsonWorkspacesPlugin } from '../../../plugins/package-json-workspaces'; -import { CreateProjectJsonProjectsPlugin } from '../../plugins/project-json/build-nodes/project-json'; import { NxJsonConfiguration, TargetDefaults } from '../../config/nx-json'; import { ProjectGraphExternalNode } from '../../config/project-graph'; import { @@ -90,12 +88,6 @@ export function buildProjectsConfigurationsFromProjectPathsAndPlugins( const projectRootMap: Map = new Map(); const externalNodes: Record = {}; - // We push the nx core node builder onto the end, s.t. it overwrites any user specified behavior - plugins.push( - getNxPackageJsonWorkspacesPlugin(root), - CreateProjectJsonProjectsPlugin - ); - // We iterate over plugins first - this ensures that plugins specified first take precedence. for (const plugin of plugins) { const [pattern, createNodes] = plugin.createNodes ?? []; diff --git a/packages/nx/src/project-graph/utils/retrieve-workspace-files.ts b/packages/nx/src/project-graph/utils/retrieve-workspace-files.ts index 026f0ce984ee1..cce50556cebf3 100644 --- a/packages/nx/src/project-graph/utils/retrieve-workspace-files.ts +++ b/packages/nx/src/project-graph/utils/retrieve-workspace-files.ts @@ -16,14 +16,17 @@ import { ProjectGraphExternalNode, } from '../../config/project-graph'; import type { NxWorkspaceFiles } from '../../native'; -import { getGlobPatternsFromPackageManagerWorkspaces } from '../../../plugins/package-json-workspaces'; +import { + getGlobPatternsFromPackageManagerWorkspaces, + getNxPackageJsonWorkspacesPlugin, +} from '../../../plugins/package-json-workspaces'; import { buildProjectsConfigurationsFromProjectPathsAndPlugins } from './project-configuration-utils'; import { loadNxPlugins, loadNxPluginsSync, - NxPlugin, NxPluginV2, } from '../../utils/nx-plugin'; +import { CreateProjectJsonProjectsPlugin } from '../../plugins/project-json/build-nodes/project-json'; /** * Walks the workspace directory to create the `projectFileMap`, `ProjectConfigurations` and `allWorkspaceFiles` @@ -229,12 +232,10 @@ export function retrieveProjectConfigurationsWithoutPluginInference( root, projectGlobPatterns, (configs: string[]) => { - const { projects } = createProjectConfigurations( - root, - nxJson, - configs, - [] - ); + const { projects } = createProjectConfigurations(root, nxJson, configs, [ + getNxPackageJsonWorkspacesPlugin(root), + CreateProjectJsonProjectsPlugin, + ]); return { projectNodes: projects, externalNodes: {}, diff --git a/packages/nx/src/utils/nx-plugin.ts b/packages/nx/src/utils/nx-plugin.ts index e2de1b37638a9..a538c6bf8846c 100644 --- a/packages/nx/src/utils/nx-plugin.ts +++ b/packages/nx/src/utils/nx-plugin.ts @@ -41,6 +41,8 @@ import { NxAngularJsonPlugin, shouldMergeAngularProjects, } from '../adapter/angular-json'; +import { getNxPackageJsonWorkspacesPlugin } from '../../plugins/package-json-workspaces'; +import { CreateProjectJsonProjectsPlugin } from '../plugins/project-json/build-nodes/project-json'; /** * Context for {@link CreateNodesFunction} @@ -225,6 +227,10 @@ export function loadNxPluginsSync( jsPlugin.name = 'nx-js-graph-plugin'; result.push(jsPlugin as NxPlugin); + if (shouldMergeAngularProjects(root, false)) { + result.push(NxAngularJsonPlugin); + } + plugins ??= []; for (const plugin of plugins) { try { @@ -239,6 +245,12 @@ export function loadNxPluginsSync( } } + // We push the nx core node plugins onto the end, s.t. it overwrites any other plugins + result.push( + getNxPackageJsonWorkspacesPlugin(root), + CreateProjectJsonProjectsPlugin + ); + return result.map(ensurePluginIsV2); } @@ -265,6 +277,12 @@ export async function loadNxPlugins( result.push(await loadNxPluginAsync(plugin, paths, root)); } + // We push the nx core node plugins onto the end, s.t. it overwrites any other plugins + result.push( + getNxPackageJsonWorkspacesPlugin(root), + CreateProjectJsonProjectsPlugin + ); + return result.map(ensurePluginIsV2); }