nx 18.3.0-canary.20240409-32144bb → 18.3.0-canary.20240411-c8f179d

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/bin/post-install.js +7 -5
  2. package/package.json +12 -12
  3. package/src/adapter/angular-json.d.ts +2 -1
  4. package/src/adapter/angular-json.js +1 -0
  5. package/src/adapter/ngcli-adapter.js +3 -3
  6. package/src/command-line/generate/generator-utils.js +2 -2
  7. package/src/command-line/run/executor-utils.js +2 -2
  8. package/src/config/nx-json.d.ts +2 -1
  9. package/src/config/schema-utils.js +2 -2
  10. package/src/daemon/server/plugins.d.ts +3 -0
  11. package/src/daemon/server/plugins.js +22 -0
  12. package/src/daemon/server/project-graph-incremental-recomputation.js +10 -9
  13. package/src/daemon/server/shutdown-utils.js +2 -0
  14. package/src/devkit-exports.d.ts +3 -2
  15. package/src/executors/run-commands/run-commands.impl.js +1 -1
  16. package/src/executors/utils/convert-nx-executor.js +4 -1
  17. package/src/generators/utils/project-configuration.js +2 -2
  18. package/src/migrations/update-15-1-0/set-project-names.js +4 -2
  19. package/src/plugins/js/index.d.ts +1 -1
  20. package/src/plugins/js/lock-file/lock-file.d.ts +1 -1
  21. package/src/plugins/js/lock-file/npm-parser.d.ts +1 -1
  22. package/src/plugins/js/lock-file/pnpm-parser.d.ts +1 -1
  23. package/src/plugins/js/lock-file/yarn-parser.d.ts +1 -1
  24. package/src/plugins/js/project-graph/build-dependencies/build-dependencies.d.ts +1 -1
  25. package/src/plugins/js/project-graph/build-dependencies/explicit-package-json-dependencies.d.ts +1 -1
  26. package/src/plugins/js/project-graph/build-dependencies/explicit-project-dependencies.d.ts +1 -1
  27. package/src/plugins/package-json-workspaces/create-nodes.d.ts +2 -2
  28. package/src/plugins/package-json-workspaces/create-nodes.js +24 -31
  29. package/src/plugins/package-json-workspaces/index.d.ts +1 -0
  30. package/src/plugins/package-json-workspaces/index.js +2 -0
  31. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.d.ts +2 -1
  32. package/src/plugins/project-json/build-nodes/package-json-next-to-project-json.js +1 -0
  33. package/src/plugins/project-json/build-nodes/project-json.d.ts +2 -1
  34. package/src/plugins/project-json/build-nodes/project-json.js +1 -0
  35. package/src/plugins/target-defaults/symbols.d.ts +17 -0
  36. package/src/plugins/target-defaults/symbols.js +20 -0
  37. package/src/plugins/target-defaults/target-defaults-plugin.d.ts +2 -18
  38. package/src/plugins/target-defaults/target-defaults-plugin.js +5 -20
  39. package/src/project-graph/affected/locators/project-glob-changes.js +3 -3
  40. package/src/project-graph/build-project-graph.d.ts +2 -1
  41. package/src/project-graph/build-project-graph.js +11 -13
  42. package/src/project-graph/error-types.d.ts +34 -0
  43. package/src/project-graph/error-types.js +65 -0
  44. package/src/project-graph/file-utils.js +3 -3
  45. package/src/project-graph/plugins/index.d.ts +2 -0
  46. package/src/project-graph/plugins/index.js +8 -0
  47. package/src/project-graph/plugins/internal-api.d.ts +28 -0
  48. package/src/project-graph/plugins/internal-api.js +85 -0
  49. package/src/project-graph/plugins/isolation/index.d.ts +3 -0
  50. package/src/project-graph/plugins/isolation/index.js +16 -0
  51. package/src/project-graph/plugins/isolation/messaging.d.ts +94 -0
  52. package/src/project-graph/plugins/isolation/messaging.js +23 -0
  53. package/src/project-graph/plugins/isolation/plugin-pool.d.ts +3 -0
  54. package/src/project-graph/plugins/isolation/plugin-pool.js +189 -0
  55. package/src/project-graph/plugins/isolation/plugin-worker.d.ts +1 -0
  56. package/src/project-graph/plugins/isolation/plugin-worker.js +81 -0
  57. package/src/project-graph/plugins/loader.d.ts +24 -0
  58. package/src/project-graph/plugins/loader.js +206 -0
  59. package/src/{utils/nx-plugin.d.ts → project-graph/plugins/public-api.d.ts} +8 -44
  60. package/src/project-graph/plugins/public-api.js +4 -0
  61. package/src/project-graph/plugins/utils.d.ts +7 -0
  62. package/src/project-graph/plugins/utils.js +88 -0
  63. package/src/project-graph/project-graph-builder.d.ts +1 -1
  64. package/src/project-graph/project-graph.d.ts +3 -2
  65. package/src/project-graph/project-graph.js +9 -7
  66. package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
  67. package/src/project-graph/utils/project-configuration-utils.d.ts +3 -26
  68. package/src/project-graph/utils/project-configuration-utils.js +29 -97
  69. package/src/project-graph/utils/retrieve-workspace-files.d.ts +8 -7
  70. package/src/project-graph/utils/retrieve-workspace-files.js +18 -21
  71. package/src/utils/logger.d.ts +1 -0
  72. package/src/utils/logger.js +5 -0
  73. package/src/utils/nx-plugin.deprecated.d.ts +2 -2
  74. package/src/utils/nx-plugin.deprecated.js +5 -7
  75. package/src/utils/plugins/plugin-capabilities.d.ts +1 -1
  76. package/src/utils/plugins/plugin-capabilities.js +18 -12
  77. package/src/utils/nx-plugin.js +0 -309
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runCreateNodesInParallel = exports.normalizeNxPlugin = exports.isNxPluginV1 = exports.isNxPluginV2 = void 0;
4
+ const node_path_1 = require("node:path");
5
+ const workspaces_1 = require("../../config/workspaces");
6
+ const globs_1 = require("../../utils/globs");
7
+ const error_types_1 = require("../error-types");
8
+ function isNxPluginV2(plugin) {
9
+ return 'createNodes' in plugin || 'createDependencies' in plugin;
10
+ }
11
+ exports.isNxPluginV2 = isNxPluginV2;
12
+ function isNxPluginV1(plugin) {
13
+ return 'processProjectGraph' in plugin || 'projectFilePatterns' in plugin;
14
+ }
15
+ exports.isNxPluginV1 = isNxPluginV1;
16
+ function normalizeNxPlugin(plugin) {
17
+ if (isNxPluginV2(plugin)) {
18
+ return plugin;
19
+ }
20
+ if (isNxPluginV1(plugin) && plugin.projectFilePatterns) {
21
+ return {
22
+ ...plugin,
23
+ createNodes: [
24
+ `*/**/${(0, globs_1.combineGlobPatterns)(plugin.projectFilePatterns)}`,
25
+ (configFilePath) => {
26
+ const root = (0, node_path_1.dirname)(configFilePath);
27
+ return {
28
+ projects: {
29
+ [root]: {
30
+ name: (0, workspaces_1.toProjectName)(configFilePath),
31
+ targets: plugin.registerProjectTargets?.(configFilePath),
32
+ },
33
+ },
34
+ };
35
+ },
36
+ ],
37
+ };
38
+ }
39
+ return plugin;
40
+ }
41
+ exports.normalizeNxPlugin = normalizeNxPlugin;
42
+ async function runCreateNodesInParallel(configFiles, plugin, options, context) {
43
+ performance.mark(`${plugin.name}:createNodes - start`);
44
+ const promises = configFiles.map((file) => {
45
+ performance.mark(`${plugin.name}:createNodes:${file} - start`);
46
+ // Result is either static or a promise, using Promise.resolve lets us
47
+ // handle both cases with same logic
48
+ const value = Promise.resolve(plugin.createNodes[1](file, options, context));
49
+ return value
50
+ .catch((e) => {
51
+ performance.mark(`${plugin.name}:createNodes:${file} - end`);
52
+ return new error_types_1.CreateNodesError({
53
+ error: e,
54
+ pluginName: plugin.name,
55
+ file,
56
+ });
57
+ })
58
+ .then((r) => {
59
+ performance.mark(`${plugin.name}:createNodes:${file} - end`);
60
+ performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
61
+ return { ...r, pluginName: plugin.name, file };
62
+ });
63
+ });
64
+ const results = await Promise.all(promises).then((results) => {
65
+ performance.mark(`${plugin.name}:createNodes - end`);
66
+ performance.measure(`${plugin.name}:createNodes`, `${plugin.name}:createNodes - start`, `${plugin.name}:createNodes - end`);
67
+ return results;
68
+ });
69
+ const [errors, successful] = partition(results, (r) => r instanceof error_types_1.CreateNodesError);
70
+ if (errors.length > 0) {
71
+ throw new error_types_1.AggregateCreateNodesError(plugin.name, errors, successful);
72
+ }
73
+ return results;
74
+ }
75
+ exports.runCreateNodesInParallel = runCreateNodesInParallel;
76
+ function partition(arr, test) {
77
+ const pass = [];
78
+ const fail = [];
79
+ for (const item of arr) {
80
+ if (test(item)) {
81
+ pass.push(item);
82
+ }
83
+ else {
84
+ fail.push(item);
85
+ }
86
+ }
87
+ return [pass, fail];
88
+ }
@@ -2,7 +2,7 @@
2
2
  * Builder for adding nodes and dependencies to a {@link ProjectGraph}
3
3
  */
4
4
  import { DependencyType, FileMap, ProjectFileMap, ProjectGraph, ProjectGraphExternalNode, ProjectGraphProjectNode } from '../config/project-graph';
5
- import { CreateDependenciesContext } from '../utils/nx-plugin';
5
+ import { CreateDependenciesContext } from './plugins';
6
6
  /**
7
7
  * A class which builds up a project graph
8
8
  * @deprecated The {@link ProjectGraphProcessor} has been deprecated. Use a {@link CreateNodes} and/or a {@link CreateDependencies} instead. This will be removed in Nx 19.
@@ -1,7 +1,8 @@
1
1
  import { ProcessDependenciesError, ProcessProjectGraphError } from './build-project-graph';
2
2
  import { ProjectGraph } from '../config/project-graph';
3
3
  import { ProjectConfiguration, ProjectsConfigurations } from '../config/workspace-json-project-json';
4
- import { ConfigurationSourceMaps, CreateNodesError, MergeNodesError } from './utils/project-configuration-utils';
4
+ import { ConfigurationSourceMaps } from './utils/project-configuration-utils';
5
+ import { CreateNodesError, MergeNodesError } from './error-types';
5
6
  import { DaemonProjectGraphError } from '../daemon/daemon-project-graph-error';
6
7
  /**
7
8
  * Synchronously reads the latest cached copy of the workspace's ProjectGraph.
@@ -33,7 +34,7 @@ export declare class ProjectGraphError extends Error {
33
34
  */
34
35
  getPartialProjectGraph(): ProjectGraph;
35
36
  getPartialSourcemaps(): ConfigurationSourceMaps;
36
- getErrors(): (ProcessDependenciesError | ProcessProjectGraphError | CreateNodesError)[];
37
+ getErrors(): (CreateNodesError | ProcessDependenciesError | ProcessProjectGraphError)[];
37
38
  }
38
39
  /**
39
40
  * Computes and returns a ProjectGraph.
@@ -14,8 +14,8 @@ const workspace_root_1 = require("../utils/workspace-root");
14
14
  const perf_hooks_1 = require("perf_hooks");
15
15
  const retrieve_workspace_files_1 = require("./utils/retrieve-workspace-files");
16
16
  const nx_json_1 = require("../config/nx-json");
17
- const nx_plugin_1 = require("../utils/nx-plugin");
18
- const project_configuration_utils_1 = require("./utils/project-configuration-utils");
17
+ const error_types_1 = require("./error-types");
18
+ const internal_api_1 = require("./plugins/internal-api");
19
19
  /**
20
20
  * Synchronously reads the latest cached copy of the workspace's ProjectGraph.
21
21
  * @throws {Error} if there is no cached ProjectGraph to read from
@@ -69,17 +69,17 @@ function readProjectsConfigurationFromProjectGraph(projectGraph) {
69
69
  }
70
70
  exports.readProjectsConfigurationFromProjectGraph = readProjectsConfigurationFromProjectGraph;
71
71
  async function buildProjectGraphAndSourceMapsWithoutDaemon() {
72
- // Set this globally to allow plugins to know if they are being called from the project graph creation
73
72
  global.NX_GRAPH_CREATION = true;
74
73
  const nxJson = (0, nx_json_1.readNxJson)();
75
74
  perf_hooks_1.performance.mark('retrieve-project-configurations:start');
76
75
  let configurationResult;
77
76
  let projectConfigurationsError;
77
+ const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)(nxJson.plugins);
78
78
  try {
79
- configurationResult = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(workspace_root_1.workspaceRoot, nxJson);
79
+ configurationResult = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, workspace_root_1.workspaceRoot, nxJson);
80
80
  }
81
81
  catch (e) {
82
- if (e instanceof project_configuration_utils_1.ProjectConfigurationsError) {
82
+ if (e instanceof error_types_1.ProjectConfigurationsError) {
83
83
  projectConfigurationsError = e;
84
84
  configurationResult = e.partialProjectConfigurationsResult;
85
85
  }
@@ -97,7 +97,7 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
97
97
  let createDependenciesError;
98
98
  let projectGraphResult;
99
99
  try {
100
- projectGraphResult = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, cacheEnabled ? (0, nx_deps_cache_1.readFileMapCache)() : null);
100
+ projectGraphResult = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, cacheEnabled ? (0, nx_deps_cache_1.readFileMapCache)() : null, plugins);
101
101
  }
102
102
  catch (e) {
103
103
  if (e instanceof build_project_graph_1.CreateDependenciesError) {
@@ -111,9 +111,11 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
111
111
  throw e;
112
112
  }
113
113
  }
114
+ finally {
115
+ cleanup();
116
+ }
114
117
  const { projectGraph, projectFileMapCache } = projectGraphResult;
115
118
  perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:end');
116
- (0, nx_plugin_1.unregisterPluginTSTranspiler)();
117
119
  delete global.NX_GRAPH_CREATION;
118
120
  const errors = [
119
121
  ...(projectConfigurationsError?.errors ?? []),
@@ -1,7 +1,7 @@
1
1
  import { ProjectGraphProjectNode } from '../../config/project-graph';
2
2
  import { ProjectGraphBuilder } from '../project-graph-builder';
3
3
  import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
4
- import { CreateDependenciesContext } from '../../utils/nx-plugin';
4
+ import { CreateDependenciesContext } from '../plugins';
5
5
  export declare function normalizeProjectNodes(ctx: CreateDependenciesContext, builder: ProjectGraphBuilder): Promise<void>;
6
6
  /**
7
7
  * Apply target defaults and normalization
@@ -1,8 +1,8 @@
1
1
  import { NxJsonConfiguration, TargetDefaults } from '../../config/nx-json';
2
2
  import { ProjectGraphExternalNode } from '../../config/project-graph';
3
3
  import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
4
- import { LoadedNxPlugin } from '../../utils/nx-plugin';
5
- import { ONLY_MODIFIES_EXISTING_TARGET } from '../../plugins/target-defaults/target-defaults-plugin';
4
+ import { ONLY_MODIFIES_EXISTING_TARGET } from '../../plugins/target-defaults/symbols';
5
+ import { LoadedNxPlugin } from '../plugins/internal-api';
6
6
  export type SourceInformation = [file: string, plugin: string];
7
7
  export type ConfigurationSourceMaps = Record<string, Record<string, SourceInformation>>;
8
8
  export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Map<string, ProjectConfiguration>, project: ProjectConfiguration & {
@@ -24,32 +24,9 @@ export type ConfigurationResult = {
24
24
  * @param workspaceFiles A list of non-ignored workspace files
25
25
  * @param plugins The plugins that should be used to infer project configuration
26
26
  */
27
- export declare function createProjectConfigurations(root: string, nxJson: NxJsonConfiguration, workspaceFiles: string[], // making this parameter allows devkit to pick up newly created projects
27
+ export declare function createProjectConfigurations(root: string, nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
28
28
  plugins: LoadedNxPlugin[]): Promise<ConfigurationResult>;
29
29
  export declare function readProjectConfigurationsFromRootMap(projectRootMap: Map<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
30
- export declare class ProjectConfigurationsError extends Error {
31
- readonly errors: Array<MergeNodesError | CreateNodesError>;
32
- readonly partialProjectConfigurationsResult: ConfigurationResult;
33
- constructor(errors: Array<MergeNodesError | CreateNodesError>, partialProjectConfigurationsResult: ConfigurationResult);
34
- }
35
- export declare class CreateNodesError extends Error {
36
- file: string;
37
- pluginName: string;
38
- constructor({ file, pluginName, error, }: {
39
- file: string;
40
- pluginName: string;
41
- error: Error;
42
- });
43
- }
44
- export declare class MergeNodesError extends Error {
45
- file: string;
46
- pluginName: string;
47
- constructor({ file, pluginName, error, }: {
48
- file: string;
49
- pluginName: string;
50
- error: Error;
51
- });
52
- }
53
30
  /**
54
31
  * Merges two targets.
55
32
  *
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.MergeNodesError = exports.CreateNodesError = exports.ProjectConfigurationsError = exports.readProjectConfigurationsFromRootMap = exports.createProjectConfigurations = exports.mergeProjectConfigurationIntoRootMap = void 0;
3
+ exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.readProjectConfigurationsFromRootMap = exports.createProjectConfigurations = exports.mergeProjectConfigurationIntoRootMap = void 0;
4
4
  const logger_1 = require("../../utils/logger");
5
5
  const fileutils_1 = require("../../utils/fileutils");
6
6
  const workspace_root_1 = require("../../utils/workspace-root");
7
- const target_defaults_plugin_1 = require("../../plugins/target-defaults/target-defaults-plugin");
7
+ const symbols_1 = require("../../plugins/target-defaults/symbols");
8
8
  const minimatch_1 = require("minimatch");
9
9
  const path_1 = require("path");
10
10
  const perf_hooks_1 = require("perf_hooks");
11
+ const error_types_1 = require("../error-types");
11
12
  function mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInformation,
12
13
  // This function is used when reading project configuration
13
14
  // in generators, where we don't want to do this.
@@ -119,12 +120,12 @@ skipCommandNormalization) {
119
120
  // Always set source map info for the target, but don't overwrite info already there
120
121
  // if augmenting an existing target.
121
122
  const target = project.targets?.[targetName];
122
- if (sourceMap && !target?.[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET]) {
123
+ if (sourceMap && !target?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET]) {
123
124
  sourceMap[`targets.${targetName}`] = sourceInformation;
124
125
  }
125
126
  // If ONLY_MODIFIES_EXISTING_TARGET is true, and its not on the matching project
126
127
  // we shouldn't merge its info into the graph
127
- if (target?.[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET] &&
128
+ if (target?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET] &&
128
129
  !matchingProject.targets?.[targetName]) {
129
130
  continue;
130
131
  }
@@ -132,8 +133,8 @@ skipCommandNormalization) {
132
133
  ? target
133
134
  : resolveCommandSyntacticSugar(target, project.root), matchingProject.targets?.[targetName], sourceMap, sourceInformation, `targets.${targetName}`);
134
135
  // We don't want the symbol to live on past the merge process
135
- if (mergedTarget?.[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET])
136
- delete mergedTarget?.[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET];
136
+ if (mergedTarget?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET])
137
+ delete mergedTarget?.[symbols_1.ONLY_MODIFIES_EXISTING_TARGET];
137
138
  updatedProjectConfiguration.targets[targetName] = mergedTarget;
138
139
  }
139
140
  }
@@ -217,21 +218,19 @@ function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata
217
218
  * @param workspaceFiles A list of non-ignored workspace files
218
219
  * @param plugins The plugins that should be used to infer project configuration
219
220
  */
220
- function createProjectConfigurations(root = workspace_root_1.workspaceRoot, nxJson, workspaceFiles, // making this parameter allows devkit to pick up newly created projects
221
+ async function createProjectConfigurations(root = workspace_root_1.workspaceRoot, nxJson, projectFiles, // making this parameter allows devkit to pick up newly created projects
221
222
  plugins) {
222
223
  perf_hooks_1.performance.mark('build-project-configs:start');
223
224
  const results = [];
224
225
  const errors = [];
225
226
  // We iterate over plugins first - this ensures that plugins specified first take precedence.
226
- for (const { plugin, options, include, exclude } of plugins) {
227
- const [pattern, createNodes] = plugin.createNodes ?? [];
228
- const pluginResults = [];
229
- perf_hooks_1.performance.mark(`${plugin.name}:createNodes - start`);
227
+ for (const { name: pluginName, createNodes: createNodesTuple, include, exclude, } of plugins) {
228
+ const [pattern, createNodes] = createNodesTuple ?? [];
230
229
  if (!pattern) {
231
230
  continue;
232
231
  }
233
232
  const matchingConfigFiles = [];
234
- for (const file of workspaceFiles) {
233
+ for (const file of projectFiles) {
235
234
  if ((0, minimatch_1.minimatch)(file, pattern, { dot: true })) {
236
235
  if (include) {
237
236
  const included = include.some((includedPattern) => (0, minimatch_1.minimatch)(file, includedPattern, { dot: true }));
@@ -240,7 +239,7 @@ plugins) {
240
239
  }
241
240
  }
242
241
  if (exclude) {
243
- const excluded = include.some((excludedPattern) => (0, minimatch_1.minimatch)(file, excludedPattern, { dot: true }));
242
+ const excluded = exclude.some((excludedPattern) => (0, minimatch_1.minimatch)(file, excludedPattern, { dot: true }));
244
243
  if (excluded) {
245
244
  continue;
246
245
  }
@@ -248,56 +247,20 @@ plugins) {
248
247
  matchingConfigFiles.push(file);
249
248
  }
250
249
  }
251
- for (const file of matchingConfigFiles) {
252
- perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - start`);
253
- try {
254
- let r = createNodes(file, options, {
255
- nxJsonConfiguration: nxJson,
256
- workspaceRoot: root,
257
- configFiles: matchingConfigFiles,
258
- });
259
- if (r instanceof Promise) {
260
- pluginResults.push(r
261
- .catch((error) => {
262
- perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - end`);
263
- errors.push(new CreateNodesError({
264
- file,
265
- pluginName: plugin.name,
266
- error,
267
- }));
268
- return {
269
- projects: {},
270
- };
271
- })
272
- .then((r) => {
273
- perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - end`);
274
- perf_hooks_1.performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
275
- return { ...r, file, pluginName: plugin.name };
276
- }));
277
- }
278
- else {
279
- perf_hooks_1.performance.mark(`${plugin.name}:createNodes:${file} - end`);
280
- perf_hooks_1.performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
281
- pluginResults.push({
282
- ...r,
283
- file,
284
- pluginName: plugin.name,
285
- });
286
- }
250
+ let r = createNodes(matchingConfigFiles, {
251
+ nxJsonConfiguration: nxJson,
252
+ workspaceRoot: root,
253
+ configFiles: matchingConfigFiles,
254
+ }).catch((e) => {
255
+ if ((0, error_types_1.isAggregateCreateNodesError)(e)) {
256
+ errors.push(...e.errors);
257
+ return e.partialResults;
287
258
  }
288
- catch (error) {
289
- errors.push(new CreateNodesError({
290
- file,
291
- pluginName: plugin.name,
292
- error,
293
- }));
259
+ else {
260
+ throw e;
294
261
  }
295
- }
296
- results.push(Promise.all(pluginResults).then((results) => {
297
- perf_hooks_1.performance.mark(`${plugin.name}:createNodes - end`);
298
- perf_hooks_1.performance.measure(`${plugin.name}:createNodes`, `${plugin.name}:createNodes - start`, `${plugin.name}:createNodes - end`);
299
- return results;
300
- }));
262
+ });
263
+ results.push(r);
301
264
  }
302
265
  return Promise.all(results).then((results) => {
303
266
  perf_hooks_1.performance.mark('createNodes:merge - start');
@@ -307,8 +270,8 @@ plugins) {
307
270
  for (const result of results.flat()) {
308
271
  const { projects: projectNodes, externalNodes: pluginExternalNodes, file, pluginName, } = result;
309
272
  const sourceInfo = [file, pluginName];
310
- if (result[target_defaults_plugin_1.OVERRIDE_SOURCE_FILE]) {
311
- sourceInfo[0] = result[target_defaults_plugin_1.OVERRIDE_SOURCE_FILE];
273
+ if (result[symbols_1.OVERRIDE_SOURCE_FILE]) {
274
+ sourceInfo[0] = result[symbols_1.OVERRIDE_SOURCE_FILE];
312
275
  }
313
276
  for (const node in projectNodes) {
314
277
  const project = {
@@ -319,7 +282,7 @@ plugins) {
319
282
  mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInfo);
320
283
  }
321
284
  catch (error) {
322
- errors.push(new MergeNodesError({
285
+ errors.push(new error_types_1.MergeNodesError({
323
286
  file,
324
287
  pluginName,
325
288
  error,
@@ -343,7 +306,7 @@ plugins) {
343
306
  };
344
307
  }
345
308
  else {
346
- throw new ProjectConfigurationsError(errors, {
309
+ throw new error_types_1.ProjectConfigurationsError(errors, {
347
310
  projects,
348
311
  externalNodes,
349
312
  projectRootMap: rootMap,
@@ -395,37 +358,6 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
395
358
  return projects;
396
359
  }
397
360
  exports.readProjectConfigurationsFromRootMap = readProjectConfigurationsFromRootMap;
398
- class ProjectConfigurationsError extends Error {
399
- constructor(errors, partialProjectConfigurationsResult) {
400
- super('Failed to create project configurations');
401
- this.errors = errors;
402
- this.partialProjectConfigurationsResult = partialProjectConfigurationsResult;
403
- this.name = this.constructor.name;
404
- }
405
- }
406
- exports.ProjectConfigurationsError = ProjectConfigurationsError;
407
- class CreateNodesError extends Error {
408
- constructor({ file, pluginName, error, }) {
409
- const msg = `The "${pluginName}" plugin threw an error while creating nodes from ${file}:`;
410
- super(msg, { cause: error });
411
- this.name = this.constructor.name;
412
- this.file = file;
413
- this.pluginName = pluginName;
414
- this.stack = `${this.message}\n ${error.stack.split('\n').join('\n ')}`;
415
- }
416
- }
417
- exports.CreateNodesError = CreateNodesError;
418
- class MergeNodesError extends Error {
419
- constructor({ file, pluginName, error, }) {
420
- const msg = `The nodes created from ${file} by the "${pluginName}" could not be merged into the project graph:`;
421
- super(msg, { cause: error });
422
- this.name = this.constructor.name;
423
- this.file = file;
424
- this.pluginName = pluginName;
425
- this.stack = `${this.message}\n ${error.stack.split('\n').join('\n ')}`;
426
- }
427
- }
428
- exports.MergeNodesError = MergeNodesError;
429
361
  /**
430
362
  * Merges two targets.
431
363
  *
@@ -448,7 +380,7 @@ function mergeTargetConfigurations(target, baseTarget, projectConfigSourceMap, s
448
380
  // with the new one. However, we have a special case for targets that have the
449
381
  // ONLY_MODIFIES_EXISTING_TARGET symbol set. This prevents the merged target
450
382
  // equaling info that should have only been used to modify the existing target.
451
- if (!isCompatible && target[target_defaults_plugin_1.ONLY_MODIFIES_EXISTING_TARGET]) {
383
+ if (!isCompatible && target[symbols_1.ONLY_MODIFIES_EXISTING_TARGET]) {
452
384
  return baseTarget;
453
385
  }
454
386
  if (!isCompatible && projectConfigSourceMap) {
@@ -1,7 +1,7 @@
1
1
  import { ProjectConfiguration } from '../../config/workspace-json-project-json';
2
2
  import { NxJsonConfiguration } from '../../config/nx-json';
3
3
  import { ConfigurationResult } from './project-configuration-utils';
4
- import { LoadedNxPlugin } from '../../utils/nx-plugin';
4
+ import { LoadedNxPlugin } from '../plugins/internal-api';
5
5
  /**
6
6
  * Walks the workspace directory to create the `projectFileMap`, `ProjectConfigurations` and `allWorkspaceFiles`
7
7
  * @throws
@@ -18,12 +18,13 @@ export declare function retrieveWorkspaceFiles(workspaceRoot: string, projectRoo
18
18
  }>;
19
19
  /**
20
20
  * Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
21
- *
22
- * @param workspaceRoot
23
- * @param nxJson
24
21
  */
25
- export declare function retrieveProjectConfigurations(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
22
+ export declare function retrieveProjectConfigurations(plugins: LoadedNxPlugin[], workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
26
23
  export declare function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
27
- export declare function retrieveProjectConfigurationPaths(root: string, plugins: LoadedNxPlugin[]): string[];
24
+ export declare function retrieveProjectConfigurationPaths(root: string, plugins: Array<{
25
+ createNodes?: readonly [string, ...unknown[]];
26
+ } & unknown>): string[];
28
27
  export declare function retrieveProjectConfigurationsWithoutPluginInference(root: string): Promise<Record<string, ProjectConfiguration>>;
29
- export declare function configurationGlobs(plugins: LoadedNxPlugin[]): string[];
28
+ export declare function configurationGlobs(plugins: Array<{
29
+ createNodes?: readonly [string, ...unknown[]];
30
+ }>): string[];
@@ -2,15 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.configurationGlobs = exports.retrieveProjectConfigurationsWithoutPluginInference = exports.retrieveProjectConfigurationPaths = exports.retrieveProjectConfigurationsWithAngularProjects = exports.retrieveProjectConfigurations = exports.retrieveWorkspaceFiles = void 0;
4
4
  const perf_hooks_1 = require("perf_hooks");
5
- const installation_directory_1 = require("../../utils/installation-directory");
6
5
  const angular_json_1 = require("../../adapter/angular-json");
7
6
  const nx_json_1 = require("../../config/nx-json");
8
- const package_json_workspaces_1 = require("../../plugins/package-json-workspaces");
9
7
  const project_configuration_utils_1 = require("./project-configuration-utils");
10
- const nx_plugin_1 = require("../../utils/nx-plugin");
11
- const project_json_1 = require("../../plugins/project-json/build-nodes/project-json");
8
+ const internal_api_1 = require("../plugins/internal-api");
12
9
  const workspace_context_1 = require("../../utils/workspace-context");
13
10
  const build_all_workspace_files_1 = require("./build-all-workspace-files");
11
+ const path_1 = require("path");
14
12
  /**
15
13
  * Walks the workspace directory to create the `projectFileMap`, `ProjectConfigurations` and `allWorkspaceFiles`
16
14
  * @throws
@@ -37,22 +35,23 @@ async function retrieveWorkspaceFiles(workspaceRoot, projectRootMap) {
37
35
  exports.retrieveWorkspaceFiles = retrieveWorkspaceFiles;
38
36
  /**
39
37
  * Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
40
- *
41
- * @param workspaceRoot
42
- * @param nxJson
43
38
  */
44
- async function retrieveProjectConfigurations(workspaceRoot, nxJson) {
45
- const plugins = await (0, nx_plugin_1.loadNxPlugins)(nxJson?.plugins ?? [], (0, installation_directory_1.getNxRequirePaths)(workspaceRoot), workspaceRoot);
46
- return _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins);
39
+ async function retrieveProjectConfigurations(plugins, workspaceRoot, nxJson) {
40
+ const projects = await _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins);
41
+ return projects;
47
42
  }
48
43
  exports.retrieveProjectConfigurations = retrieveProjectConfigurations;
49
44
  async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, nxJson) {
50
- const plugins = await (0, nx_plugin_1.loadNxPlugins)(nxJson?.plugins ?? [], (0, installation_directory_1.getNxRequirePaths)(workspaceRoot), workspaceRoot);
45
+ const pluginsToLoad = nxJson?.plugins ?? [];
51
46
  if ((0, angular_json_1.shouldMergeAngularProjects)(workspaceRoot, true) &&
52
- !plugins.some((p) => p.plugin.name === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME)) {
53
- plugins.push({ plugin: angular_json_1.NxAngularJsonPlugin });
47
+ !pluginsToLoad.some((p) => p === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME ||
48
+ (typeof p === 'object' && p.plugin === angular_json_1.NX_ANGULAR_JSON_PLUGIN_NAME))) {
49
+ pluginsToLoad.push((0, path_1.join)(__dirname, '../../adapter/angular-json'));
54
50
  }
55
- return _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins);
51
+ const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)(nxJson?.plugins ?? [], workspaceRoot);
52
+ const res = _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins);
53
+ cleanup();
54
+ return res;
56
55
  }
57
56
  exports.retrieveProjectConfigurationsWithAngularProjects = retrieveProjectConfigurationsWithAngularProjects;
58
57
  function _retrieveProjectConfigurations(workspaceRoot, nxJson, plugins) {
@@ -69,25 +68,23 @@ const projectsWithoutPluginCache = new Map();
69
68
  // TODO: This function is called way too often, it should be optimized without this cache
70
69
  async function retrieveProjectConfigurationsWithoutPluginInference(root) {
71
70
  const nxJson = (0, nx_json_1.readNxJson)(root);
72
- const plugins = await (0, nx_plugin_1.getDefaultPlugins)(root);
71
+ const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)([]); // only load default plugins
73
72
  const projectGlobPatterns = retrieveProjectConfigurationPaths(root, plugins);
74
73
  const cacheKey = root + ',' + projectGlobPatterns.join(',');
75
74
  if (projectsWithoutPluginCache.has(cacheKey)) {
76
75
  return projectsWithoutPluginCache.get(cacheKey);
77
76
  }
78
77
  const projectFiles = (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns) ?? [];
79
- const { projects } = await (0, project_configuration_utils_1.createProjectConfigurations)(root, nxJson, projectFiles, [
80
- { plugin: (0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(root) },
81
- { plugin: project_json_1.ProjectJsonProjectsPlugin },
82
- ]);
78
+ const { projects } = await (0, project_configuration_utils_1.createProjectConfigurations)(root, nxJson, projectFiles, plugins);
83
79
  projectsWithoutPluginCache.set(cacheKey, projects);
80
+ cleanup();
84
81
  return projects;
85
82
  }
86
83
  exports.retrieveProjectConfigurationsWithoutPluginInference = retrieveProjectConfigurationsWithoutPluginInference;
87
84
  function configurationGlobs(plugins) {
88
85
  const globPatterns = [];
89
- for (const { plugin } of plugins) {
90
- if (plugin.createNodes) {
86
+ for (const plugin of plugins) {
87
+ if ('createNodes' in plugin && plugin.createNodes) {
91
88
  globPatterns.push(plugin.createNodes[0]);
92
89
  }
93
90
  }
@@ -7,5 +7,6 @@ export declare const logger: {
7
7
  log: (...s: any[]) => void;
8
8
  debug: (...s: any[]) => void;
9
9
  fatal: (...s: any[]) => void;
10
+ verbose: (...s: any[]) => void;
10
11
  };
11
12
  export declare function stripIndent(str: string): string;
@@ -34,6 +34,11 @@ exports.logger = {
34
34
  fatal: (...s) => {
35
35
  console.error(...s);
36
36
  },
37
+ verbose: (...s) => {
38
+ if (process.env.NX_VERBOSE_LOGGING) {
39
+ console.log(...s);
40
+ }
41
+ },
37
42
  };
38
43
  function stripIndent(str) {
39
44
  const match = str.match(/^[ \t]*(?=\S)/gm);
@@ -1,6 +1,6 @@
1
1
  import { ProjectGraphProcessor } from '../config/project-graph';
2
2
  import { TargetConfiguration } from '../config/workspace-json-project-json';
3
- import { LoadedNxPlugin } from './nx-plugin';
3
+ import { NxPluginV2 } from '../project-graph/plugins';
4
4
  /**
5
5
  * @deprecated Add targets to the projects in a {@link CreateNodes} function instead. This will be removed in Nx 19
6
6
  */
@@ -28,4 +28,4 @@ export type NxPluginV1 = {
28
28
  /**
29
29
  * @todo(@agentender) v19: Remove this fn when we remove readWorkspaceConfig
30
30
  */
31
- export declare function getDefaultPluginsSync(root: string): LoadedNxPlugin[];
31
+ export declare function getDefaultPluginsSync(root: string): NxPluginV2[];
@@ -4,7 +4,7 @@ exports.getDefaultPluginsSync = void 0;
4
4
  const angular_json_1 = require("../adapter/angular-json");
5
5
  const project_json_1 = require("../plugins/project-json/build-nodes/project-json");
6
6
  const target_defaults_plugin_1 = require("../plugins/target-defaults/target-defaults-plugin");
7
- const package_json_workspaces_1 = require("../plugins/package-json-workspaces");
7
+ const PackageJsonWorkspacesPlugin = require("../plugins/package-json-workspaces");
8
8
  /**
9
9
  * @todo(@agentender) v19: Remove this fn when we remove readWorkspaceConfig
10
10
  */
@@ -14,12 +14,10 @@ function getDefaultPluginsSync(root) {
14
14
  ...((0, angular_json_1.shouldMergeAngularProjects)(root, false)
15
15
  ? [require('../adapter/angular-json').NxAngularJsonPlugin]
16
16
  : []),
17
- target_defaults_plugin_1.TargetDefaultsPlugin,
18
- (0, package_json_workspaces_1.getNxPackageJsonWorkspacesPlugin)(root),
19
- project_json_1.ProjectJsonProjectsPlugin,
17
+ target_defaults_plugin_1.default,
18
+ PackageJsonWorkspacesPlugin,
19
+ project_json_1.default,
20
20
  ];
21
- return plugins.map((p) => ({
22
- plugin: p,
23
- }));
21
+ return plugins;
24
22
  }
25
23
  exports.getDefaultPluginsSync = getDefaultPluginsSync;
@@ -1,4 +1,4 @@
1
- import type { PluginCapabilities } from './models';
2
1
  import { ProjectConfiguration } from '../../config/workspace-json-project-json';
2
+ import type { PluginCapabilities } from './models';
3
3
  export declare function getPluginCapabilities(workspaceRoot: string, pluginName: string, projects: Record<string, ProjectConfiguration>, includeRuntimeCapabilities?: boolean): Promise<PluginCapabilities | null>;
4
4
  export declare function listPluginCapabilities(pluginName: string, projects: Record<string, ProjectConfiguration>): Promise<void>;