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

fix(core): load core plugins as part of loading plugins #18826

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -90,12 +88,6 @@ export function buildProjectsConfigurationsFromProjectPathsAndPlugins(
const projectRootMap: Map<string, ProjectConfiguration> = new Map();
const externalNodes: Record<string, ProjectGraphExternalNode> = {};

// 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 ?? [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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: {},
Expand Down
18 changes: 18 additions & 0 deletions packages/nx/src/utils/nx-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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 {
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand Down