nx 18.3.3 → 18.3.4

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.
@@ -142,22 +142,22 @@ async function processFilesAndCreateAndSerializeProjectGraph(plugins) {
142
142
  logger_1.serverLogger.requestLog([...deletedFiles]);
143
143
  const nxJson = (0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot);
144
144
  global.NX_GRAPH_CREATION = true;
145
- let graphNodes;
145
+ let projectConfigurationsResult;
146
146
  let projectConfigurationsError;
147
147
  try {
148
- graphNodes = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, workspace_root_1.workspaceRoot, nxJson);
148
+ projectConfigurationsResult = await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, workspace_root_1.workspaceRoot, nxJson);
149
149
  }
150
150
  catch (e) {
151
151
  if (e instanceof error_types_1.ProjectConfigurationsError) {
152
- graphNodes = e.partialProjectConfigurationsResult;
152
+ projectConfigurationsResult = e.partialProjectConfigurationsResult;
153
153
  projectConfigurationsError = e;
154
154
  }
155
155
  else {
156
156
  throw e;
157
157
  }
158
158
  }
159
- await processCollectedUpdatedAndDeletedFiles(graphNodes, updatedFileHashes, deletedFiles);
160
- const g = await createAndSerializeProjectGraph(graphNodes);
159
+ await processCollectedUpdatedAndDeletedFiles(projectConfigurationsResult, updatedFileHashes, deletedFiles);
160
+ const g = await createAndSerializeProjectGraph(projectConfigurationsResult);
161
161
  delete global.NX_GRAPH_CREATION;
162
162
  const errors = [...(projectConfigurationsError?.errors ?? [])];
163
163
  if (g.error) {
@@ -179,7 +179,7 @@ async function processFilesAndCreateAndSerializeProjectGraph(plugins) {
179
179
  }
180
180
  if (errors.length > 0) {
181
181
  return {
182
- error: new error_types_1.DaemonProjectGraphError(errors, g.projectGraph, graphNodes.sourceMaps),
182
+ error: new error_types_1.DaemonProjectGraphError(errors, g.projectGraph, projectConfigurationsResult.sourceMaps),
183
183
  projectGraph: null,
184
184
  projectFileMapCache: null,
185
185
  fileMap: null,
@@ -8,6 +8,7 @@ export { getExecutorInformation } from './command-line/run/executor-utils';
8
8
  export { readNxJson as readNxJsonFromDisk } from './config/nx-json';
9
9
  export { calculateDefaultProjectName } from './config/calculate-default-project-name';
10
10
  export { retrieveProjectConfigurationsWithAngularProjects } from './project-graph/utils/retrieve-workspace-files';
11
+ export { readProjectConfigurationsFromRootMap } from './project-graph/utils/project-configuration-utils';
11
12
  export { splitTarget } from './utils/split-target';
12
13
  export { combineOptionsForExecutor } from './utils/params';
13
14
  export { sortObjectByKeys } from './utils/object-sort';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
3
+ exports.registerTsProject = exports.LoadedNxPlugin = exports.retrieveProjectConfigurations = exports.findProjectForPath = exports.createProjectRootMappingsFromProjectConfigurations = exports.hashWithWorkspaceContext = exports.hashObject = exports.splitByColons = exports.readModulePackageJson = exports.stripIndent = exports.sortObjectByKeys = exports.combineOptionsForExecutor = exports.splitTarget = exports.readProjectConfigurationsFromRootMap = exports.retrieveProjectConfigurationsWithAngularProjects = exports.calculateDefaultProjectName = exports.readNxJsonFromDisk = exports.getExecutorInformation = exports.createTempNpmDirectory = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  /**
6
6
  * Note to developers: STOP! These exports are available via requireNx in @nx/devkit.
@@ -17,6 +17,8 @@ var calculate_default_project_name_1 = require("./config/calculate-default-proje
17
17
  Object.defineProperty(exports, "calculateDefaultProjectName", { enumerable: true, get: function () { return calculate_default_project_name_1.calculateDefaultProjectName; } });
18
18
  var retrieve_workspace_files_1 = require("./project-graph/utils/retrieve-workspace-files");
19
19
  Object.defineProperty(exports, "retrieveProjectConfigurationsWithAngularProjects", { enumerable: true, get: function () { return retrieve_workspace_files_1.retrieveProjectConfigurationsWithAngularProjects; } });
20
+ var project_configuration_utils_1 = require("./project-graph/utils/project-configuration-utils");
21
+ Object.defineProperty(exports, "readProjectConfigurationsFromRootMap", { enumerable: true, get: function () { return project_configuration_utils_1.readProjectConfigurationsFromRootMap; } });
20
22
  var split_target_1 = require("./utils/split-target");
21
23
  Object.defineProperty(exports, "splitTarget", { enumerable: true, get: function () { return split_target_1.splitTarget; } });
22
24
  var params_1 = require("./utils/params");
@@ -22,6 +22,7 @@ export interface RunCommandsOptions extends Json {
22
22
  readyWhen?: string;
23
23
  cwd?: string;
24
24
  env?: Record<string, string>;
25
+ forwardAllArgs?: boolean;
25
26
  args?: string | string[];
26
27
  envFile?: string;
27
28
  __unparsed__: string[];
@@ -39,6 +39,7 @@ const propKeys = [
39
39
  'usePty',
40
40
  'streamOutput',
41
41
  'verbose',
42
+ 'forwardAllArgs',
42
43
  ];
43
44
  async function default_1(options, context) {
44
45
  registerProcessListener();
@@ -135,7 +136,7 @@ function normalizeOptions(options) {
135
136
  options.parsedArgs = parseArgs(unparsedCommandArgs, options.unknownOptions, options.args);
136
137
  options.unparsedCommandArgs = unparsedCommandArgs;
137
138
  options.commands.forEach((c) => {
138
- c.command = interpolateArgsIntoCommand(c.command, options, c.forwardAllArgs ?? true);
139
+ c.command = interpolateArgsIntoCommand(c.command, options, c.forwardAllArgs ?? options.forwardAllArgs ?? true);
139
140
  });
140
141
  return options;
141
142
  }
@@ -135,6 +135,11 @@
135
135
  "$source": "unparsed"
136
136
  },
137
137
  "x-priority": "internal"
138
+ },
139
+ "forwardAllArgs": {
140
+ "type": "boolean",
141
+ "description": "Whether arguments should be forwarded when interpolation is not present.",
142
+ "default": true
138
143
  }
139
144
  },
140
145
  "additionalProperties": true,
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.convertNxExecutor = void 0;
7
7
  const nx_json_1 = require("../../config/nx-json");
8
8
  const retrieve_workspace_files_1 = require("../../project-graph/utils/retrieve-workspace-files");
9
+ const project_configuration_utils_1 = require("../../project-graph/utils/project-configuration-utils");
9
10
  const internal_api_1 = require("../../project-graph/plugins/internal-api");
10
11
  /**
11
12
  * Convert an Nx Executor into an Angular Devkit Builder
@@ -19,7 +20,7 @@ function convertNxExecutor(executor) {
19
20
  const [plugins, cleanup] = await (0, internal_api_1.loadNxPlugins)(nxJsonConfiguration.plugins, builderContext.workspaceRoot);
20
21
  const projectsConfigurations = {
21
22
  version: 2,
22
- projects: (await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, builderContext.workspaceRoot, nxJsonConfiguration)).projects,
23
+ projects: (0, project_configuration_utils_1.readProjectConfigurationsFromRootMap)((await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, builderContext.workspaceRoot, nxJsonConfiguration)).projects),
23
24
  };
24
25
  cleanup();
25
26
  const context = {
@@ -143,7 +143,7 @@ function readAndCombineAllProjectConfigurations(tree) {
143
143
  const createdFiles = findCreatedProjectFiles(tree, patterns);
144
144
  const deletedFiles = findDeletedProjectFiles(tree, patterns);
145
145
  const projectFiles = [...globbedFiles, ...createdFiles].filter((r) => deletedFiles.indexOf(r) === -1);
146
- const rootMap = new Map();
146
+ const rootMap = {};
147
147
  for (const projectFile of projectFiles) {
148
148
  if ((0, path_1.basename)(projectFile) === 'project.json') {
149
149
  const json = (0, json_1.readJson)(tree, projectFile);
@@ -153,7 +153,7 @@ function readAndCombineAllProjectConfigurations(tree) {
153
153
  else if ((0, path_1.basename)(projectFile) === 'package.json') {
154
154
  const packageJson = (0, json_1.readJson)(tree, projectFile);
155
155
  const config = (0, package_json_workspaces_1.buildProjectConfigurationFromPackageJson)(packageJson, projectFile, (0, nx_json_1.readNxJson)(tree));
156
- if (!rootMap.has(config.root)) {
156
+ if (!rootMap[config.root]) {
157
157
  (0, project_configuration_utils_1.mergeProjectConfigurationIntoRootMap)(rootMap,
158
158
  // Inferred targets, tags, etc don't show up when running generators
159
159
  // This is to help avoid running into issues when trying to update the workspace
@@ -9,7 +9,7 @@ export declare function getFileMap(): {
9
9
  allWorkspaceFiles: FileData[];
10
10
  rustReferences: NxWorkspaceFilesExternals | null;
11
11
  };
12
- export declare function buildProjectGraphUsingProjectFileMap(projects: Record<string, ProjectConfiguration>, externalNodes: Record<string, ProjectGraphExternalNode>, fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals, fileMapCache: FileMapCache | null, plugins: LoadedNxPlugin[]): Promise<{
12
+ export declare function buildProjectGraphUsingProjectFileMap(projectRootMap: Record<string, ProjectConfiguration>, externalNodes: Record<string, ProjectGraphExternalNode>, fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals, fileMapCache: FileMapCache | null, plugins: LoadedNxPlugin[]): Promise<{
13
13
  projectGraph: ProjectGraph;
14
14
  projectFileMapCache: FileMapCache;
15
15
  }>;
@@ -38,10 +38,15 @@ function getFileMap() {
38
38
  }
39
39
  }
40
40
  exports.getFileMap = getFileMap;
41
- async function buildProjectGraphUsingProjectFileMap(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, fileMapCache, plugins) {
41
+ async function buildProjectGraphUsingProjectFileMap(projectRootMap, externalNodes, fileMap, allWorkspaceFiles, rustReferences, fileMapCache, plugins) {
42
42
  storedFileMap = fileMap;
43
43
  storedAllWorkspaceFiles = allWorkspaceFiles;
44
44
  storedRustReferences = rustReferences;
45
+ const projects = {};
46
+ for (const root in projectRootMap) {
47
+ const project = projectRootMap[root];
48
+ projects[project.name] = project;
49
+ }
45
50
  const nxJson = (0, configuration_1.readNxJson)();
46
51
  const projectGraphVersion = '6.0';
47
52
  (0, assert_workspace_validity_1.assertWorkspaceValidity)(projects, nxJson);
@@ -138,15 +143,9 @@ async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFile
138
143
  }
139
144
  }
140
145
  function createContext(projects, nxJson, externalNodes, fileMap, filesToProcess) {
141
- const clonedProjects = Object.keys(projects).reduce((map, projectName) => {
142
- map[projectName] = {
143
- ...projects[projectName],
144
- };
145
- return map;
146
- }, {});
147
146
  return {
148
147
  nxJsonConfiguration: nxJson,
149
- projects: clonedProjects,
148
+ projects,
150
149
  externalNodes,
151
150
  workspaceRoot: workspace_root_1.workspaceRoot,
152
151
  fileMap,
@@ -152,7 +152,7 @@ function getProjectsSyncNoInference(root, nxJson) {
152
152
  package_json_next_to_project_json_1.PackageJsonProjectsNextToProjectJsonPlugin,
153
153
  ...(0, nx_plugin_deprecated_1.getDefaultPluginsSync)(root),
154
154
  ];
155
- const projectRootMap = new Map();
155
+ const projectRootMap = {};
156
156
  // We iterate over plugins first - this ensures that plugins specified first take precedence.
157
157
  for (const plugin of plugins) {
158
158
  const [pattern, createNodes] = plugin.createNodes ?? [];
@@ -32,6 +32,9 @@ function readPluginPackageJson(pluginName, projects, paths = (0, installation_di
32
32
  const localPluginPath = resolveLocalNxPlugin(pluginName, projects);
33
33
  if (localPluginPath) {
34
34
  const localPluginPackageJson = path.join(localPluginPath.path, 'package.json');
35
+ if (!exports.unregisterPluginTSTranspiler) {
36
+ registerPluginTSTranspiler();
37
+ }
35
38
  return {
36
39
  path: localPluginPackageJson,
37
40
  json: (0, fileutils_1.readJsonFile)(localPluginPackageJson),
@@ -77,22 +80,27 @@ function registerPluginTSTranspiler() {
77
80
  }
78
81
  exports.registerPluginTSTranspiler = registerPluginTSTranspiler;
79
82
  function lookupLocalPlugin(importPath, projects, root = workspace_root_1.workspaceRoot) {
80
- const plugin = findNxProjectForImportPath(importPath, projects, root);
81
- if (!plugin) {
83
+ const projectConfig = findNxProjectForImportPath(importPath, projects, root);
84
+ if (!projectConfig) {
82
85
  return null;
83
86
  }
84
- const projectConfig = projects[plugin];
85
87
  return { path: path.join(root, projectConfig.root), projectConfig };
86
88
  }
87
89
  function findNxProjectForImportPath(importPath, projects, root = workspace_root_1.workspaceRoot) {
88
90
  const tsConfigPaths = readTsConfigPaths(root);
89
91
  const possiblePaths = tsConfigPaths[importPath]?.map((p) => (0, path_1.normalizePath)(path.relative(root, path.join(root, p))));
90
92
  if (possiblePaths?.length) {
91
- const projectRootMappings = (0, find_project_for_path_1.createProjectRootMappingsFromProjectConfigurations)(projects);
93
+ const projectRootMappings = new Map();
94
+ const projectNameMap = new Map();
95
+ for (const projectRoot in projects) {
96
+ const project = projects[projectRoot];
97
+ projectRootMappings.set(project.root, project.name);
98
+ projectNameMap.set(project.name, project);
99
+ }
92
100
  for (const tsConfigPath of possiblePaths) {
93
101
  const nxProject = (0, find_project_for_path_1.findProjectForPath)(tsConfigPath, projectRootMappings);
94
102
  if (nxProject) {
95
- return nxProject;
103
+ return projectNameMap.get(nxProject);
96
104
  }
97
105
  }
98
106
  logger_1.logger.verbose('Unable to find local plugin', possiblePaths, projectRootMappings);
@@ -12,7 +12,7 @@ export interface CreateNodesContext {
12
12
  /**
13
13
  * The subset of configuration files which match the createNodes pattern
14
14
  */
15
- readonly configFiles: string[];
15
+ readonly configFiles: readonly string[];
16
16
  }
17
17
  /**
18
18
  * A function which parses a configuration file into a set of nodes.
@@ -1,7 +1,7 @@
1
1
  import type { NxPluginV1 } from '../../utils/nx-plugin.deprecated';
2
2
  import type { CreateNodesResultWithContext, LoadedNxPlugin, NormalizedPlugin } from './internal-api';
3
- import type { CreateNodesContext, NxPlugin, NxPluginV2 } from './public-api';
3
+ import { type CreateNodesContext, type NxPlugin, type NxPluginV2 } from './public-api';
4
4
  export declare function isNxPluginV2(plugin: NxPlugin): plugin is NxPluginV2;
5
5
  export declare function isNxPluginV1(plugin: NxPlugin | LoadedNxPlugin): plugin is NxPluginV1;
6
6
  export declare function normalizeNxPlugin(plugin: NxPlugin): NormalizedPlugin;
7
- export declare function runCreateNodesInParallel(configFiles: string[], plugin: NormalizedPlugin, options: unknown, context: CreateNodesContext): Promise<CreateNodesResultWithContext[]>;
7
+ export declare function runCreateNodesInParallel(configFiles: readonly string[], plugin: NormalizedPlugin, options: unknown, context: CreateNodesContext): Promise<CreateNodesResultWithContext[]>;
@@ -43,30 +43,29 @@ async function runCreateNodesInParallel(configFiles, plugin, options, context) {
43
43
  performance.mark(`${plugin.name}:createNodes - start`);
44
44
  const errors = [];
45
45
  const results = [];
46
- const promises = configFiles.map((file) => {
46
+ const promises = configFiles.map(async (file) => {
47
47
  performance.mark(`${plugin.name}:createNodes:${file} - start`);
48
- // Result is either static or a promise, using Promise.resolve lets us
49
- // handle both cases with same logic
50
- const value = Promise.resolve(plugin.createNodes[1](file, options, context));
51
- return value
52
- .catch((e) => {
53
- performance.mark(`${plugin.name}:createNodes:${file} - end`);
48
+ try {
49
+ const value = await plugin.createNodes[1](file, options, context);
50
+ if (value) {
51
+ results.push({
52
+ ...value,
53
+ file,
54
+ pluginName: plugin.name,
55
+ });
56
+ }
57
+ }
58
+ catch (e) {
54
59
  errors.push(new error_types_1.CreateNodesError({
55
60
  error: e,
56
61
  pluginName: plugin.name,
57
62
  file,
58
63
  }));
59
- return null;
60
- })
61
- .then((r) => {
64
+ }
65
+ finally {
62
66
  performance.mark(`${plugin.name}:createNodes:${file} - end`);
63
67
  performance.measure(`${plugin.name}:createNodes:${file}`, `${plugin.name}:createNodes:${file} - start`, `${plugin.name}:createNodes:${file} - end`);
64
- // Existing behavior is to ignore null results of
65
- // createNodes function.
66
- if (r) {
67
- results.push({ ...r, file, pluginName: plugin.name });
68
- }
69
- });
68
+ }
70
69
  });
71
70
  await Promise.all(promises).then(() => {
72
71
  performance.mark(`${plugin.name}:createNodes - end`);
@@ -9,9 +9,8 @@ const path_2 = require("../../utils/path");
9
9
  */
10
10
  function createProjectRootMappingsFromProjectConfigurations(projects) {
11
11
  const projectRootMappings = new Map();
12
- for (const projectName of Object.keys(projects)) {
13
- const root = projects[projectName].root;
14
- projectRootMappings.set(normalizeProjectRoot(root), projectName);
12
+ for (const { name, root } of Object.values(projects)) {
13
+ projectRootMappings.set(normalizeProjectRoot(root), name);
15
14
  }
16
15
  return projectRootMappings;
17
16
  }
@@ -2,7 +2,7 @@ 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
4
  import { CreateDependenciesContext } from '../plugins';
5
- export declare function normalizeProjectNodes(ctx: CreateDependenciesContext, builder: ProjectGraphBuilder): Promise<void>;
5
+ export declare function normalizeProjectNodes({ projects }: CreateDependenciesContext, builder: ProjectGraphBuilder): Promise<void>;
6
6
  /**
7
7
  * Apply target defaults and normalization
8
8
  */
@@ -3,15 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.normalizeImplicitDependencies = exports.normalizeProjectTargets = exports.normalizeProjectNodes = void 0;
4
4
  const find_matching_projects_1 = require("../../utils/find-matching-projects");
5
5
  const project_configuration_utils_1 = require("../utils/project-configuration-utils");
6
- async function normalizeProjectNodes(ctx, builder) {
7
- const toAdd = [];
6
+ async function normalizeProjectNodes({ projects }, builder) {
8
7
  // Sorting projects by name to make sure that the order of projects in the graph is deterministic.
9
8
  // This is important to ensure that expanded properties referencing projects (e.g. implicit dependencies)
10
9
  // are also deterministic, and thus don't cause the calculated project configuration hash to shift.
11
- const projects = Object.keys(ctx.projects).sort();
10
+ const sortedProjectNames = Object.keys(projects).sort();
12
11
  // Used for expanding implicit dependencies (e.g. `@proj/*` or `tag:foo`)
13
- const partialProjectGraphNodes = projects.reduce((graph, project) => {
14
- const projectConfiguration = ctx.projects[project];
12
+ const partialProjectGraphNodes = sortedProjectNames.reduce((graph, project) => {
13
+ const projectConfiguration = projects[project];
15
14
  graph[project] = {
16
15
  name: project,
17
16
  type: projectConfiguration.projectType === 'library' ? 'lib' : 'app', // missing fallback to `e2e`
@@ -21,8 +20,9 @@ async function normalizeProjectNodes(ctx, builder) {
21
20
  };
22
21
  return graph;
23
22
  }, {});
24
- for (const key of projects) {
25
- const p = ctx.projects[key];
23
+ const toAdd = [];
24
+ for (const key of sortedProjectNames) {
25
+ const p = projects[key];
26
26
  p.implicitDependencies = normalizeImplicitDependencies(key, p.implicitDependencies, partialProjectGraphNodes);
27
27
  p.targets = normalizeProjectTargets(p, key);
28
28
  // TODO: remove in v16
@@ -31,7 +31,7 @@ async function normalizeProjectNodes(ctx, builder) {
31
31
  ? 'e2e'
32
32
  : 'app'
33
33
  : 'lib';
34
- const tags = ctx.projects?.[key]?.tags || [];
34
+ const tags = p.tags || [];
35
35
  toAdd.push({
36
36
  name: key,
37
37
  type: projectType,
@@ -5,16 +5,31 @@ import { ONLY_MODIFIES_EXISTING_TARGET } from '../../plugins/target-defaults/sym
5
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
- export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Map<string, ProjectConfiguration>, project: ProjectConfiguration & {
8
+ export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Record<string, ProjectConfiguration>, project: ProjectConfiguration & {
9
9
  targets?: Record<string, TargetConfiguration & {
10
10
  [ONLY_MODIFIES_EXISTING_TARGET]?: boolean;
11
11
  }>;
12
12
  }, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation, skipCommandNormalization?: boolean): void;
13
13
  export type ConfigurationResult = {
14
- projects: Record<string, ProjectConfiguration>;
14
+ /**
15
+ * A map of project configurations, keyed by project root.
16
+ */
17
+ projects: {
18
+ [projectRoot: string]: ProjectConfiguration;
19
+ };
20
+ /**
21
+ * Node Name -> Node info
22
+ */
15
23
  externalNodes: Record<string, ProjectGraphExternalNode>;
24
+ /**
25
+ * Project Root -> Project Name
26
+ */
16
27
  projectRootMap: Record<string, string>;
17
28
  sourceMaps: ConfigurationSourceMaps;
29
+ /**
30
+ * The list of files that were used to create project configurations
31
+ */
32
+ matchingProjectFiles: string[];
18
33
  };
19
34
  /**
20
35
  * Transforms a list of project paths into a map of project configurations.
@@ -26,7 +41,7 @@ export type ConfigurationResult = {
26
41
  */
27
42
  export declare function createProjectConfigurations(root: string, nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
28
43
  plugins: LoadedNxPlugin[]): Promise<ConfigurationResult>;
29
- export declare function readProjectConfigurationsFromRootMap(projectRootMap: Map<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
44
+ export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
30
45
  /**
31
46
  * Merges two targets.
32
47
  *
@@ -17,12 +17,12 @@ skipCommandNormalization) {
17
17
  configurationSourceMaps[project.root] = {};
18
18
  }
19
19
  const sourceMap = configurationSourceMaps?.[project.root];
20
- let matchingProject = projectRootMap.get(project.root);
20
+ let matchingProject = projectRootMap[project.root];
21
21
  if (!matchingProject) {
22
- projectRootMap.set(project.root, {
22
+ projectRootMap[project.root] = {
23
23
  root: project.root,
24
- });
25
- matchingProject = projectRootMap.get(project.root);
24
+ };
25
+ matchingProject = projectRootMap[project.root];
26
26
  if (sourceMap) {
27
27
  sourceMap[`root`] = sourceInformation;
28
28
  }
@@ -138,7 +138,8 @@ skipCommandNormalization) {
138
138
  updatedProjectConfiguration.targets[targetName] = mergedTarget;
139
139
  }
140
140
  }
141
- projectRootMap.set(updatedProjectConfiguration.root, updatedProjectConfiguration);
141
+ projectRootMap[updatedProjectConfiguration.root] =
142
+ updatedProjectConfiguration;
142
143
  }
143
144
  exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRootMap;
144
145
  function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata, matchingMetadata) {
@@ -264,7 +265,7 @@ plugins) {
264
265
  }
265
266
  return Promise.all(results).then((results) => {
266
267
  perf_hooks_1.performance.mark('createNodes:merge - start');
267
- const projectRootMap = new Map();
268
+ const projectRootMap = {};
268
269
  const externalNodes = {};
269
270
  const configurationSourceMaps = {};
270
271
  for (const result of results.flat()) {
@@ -291,14 +292,17 @@ plugins) {
291
292
  }
292
293
  Object.assign(externalNodes, pluginExternalNodes);
293
294
  }
294
- let projects;
295
295
  try {
296
- projects = readProjectConfigurationsFromRootMap(projectRootMap);
296
+ // We still call this just to assert that the root map
297
+ // only contains valid project names. This is a safety check.
298
+ //
299
+ // The signature itself can't be changed as we need it to return
300
+ // project configurations for use in devkit.
301
+ readProjectConfigurationsFromRootMap(projectRootMap);
297
302
  }
298
303
  catch (e) {
299
304
  if ((0, error_types_1.isProjectsWithNoNameError)(e) ||
300
305
  (0, error_types_1.isProjectsWithConflictingNamesError)(e)) {
301
- projects = e.projects;
302
306
  errors.push(e);
303
307
  }
304
308
  else {
@@ -312,18 +316,20 @@ plugins) {
312
316
  perf_hooks_1.performance.measure('build-project-configs', 'build-project-configs:start', 'build-project-configs:end');
313
317
  if (errors.length === 0) {
314
318
  return {
315
- projects,
319
+ projects: projectRootMap,
316
320
  externalNodes,
317
321
  projectRootMap: rootMap,
318
322
  sourceMaps: configurationSourceMaps,
323
+ matchingProjectFiles: projectFiles,
319
324
  };
320
325
  }
321
326
  else {
322
327
  throw new error_types_1.ProjectConfigurationsError(errors, {
323
- projects,
328
+ projects: projectRootMap,
324
329
  externalNodes,
325
330
  projectRootMap: rootMap,
326
331
  sourceMaps: configurationSourceMaps,
332
+ matchingProjectFiles: projectFiles,
327
333
  });
328
334
  }
329
335
  });
@@ -336,7 +342,8 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
336
342
  // to provide better error messaging.
337
343
  const conflicts = new Map();
338
344
  const projectRootsWithNoName = [];
339
- for (const [root, configuration] of projectRootMap.entries()) {
345
+ for (const root in projectRootMap) {
346
+ const configuration = projectRootMap[root];
340
347
  // We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
341
348
  // Strip it before returning configuration for usage.
342
349
  if (configuration['// targets'])
@@ -388,7 +395,7 @@ function mergeTargetConfigurations(target, baseTarget, projectConfigSourceMap, s
388
395
  const { configurations: defaultConfigurations, options: defaultOptions, ...baseTargetProperties } = baseTarget ?? {};
389
396
  // Target is "compatible", e.g. executor is defined only once or is the same
390
397
  // in both places. This means that it is likely safe to merge
391
- const isCompatible = isCompatibleTarget(baseTargetProperties, target);
398
+ const isCompatible = isCompatibleTarget(baseTarget ?? {}, target);
392
399
  // If the targets are not compatible, we would normally overwrite the old target
393
400
  // with the new one. However, we have a special case for targets that have the
394
401
  // ONLY_MODIFIES_EXISTING_TARGET symbol set. This prevents the merged target
@@ -544,7 +551,8 @@ function readTargetDefaultsForTarget(targetName, targetDefaults, executor) {
544
551
  exports.readTargetDefaultsForTarget = readTargetDefaultsForTarget;
545
552
  function createRootMap(projectRootMap) {
546
553
  const map = {};
547
- for (const [projectRoot, { name: projectName }] of projectRootMap) {
554
+ for (const projectRoot in projectRootMap) {
555
+ const projectName = projectRootMap[projectRoot].name;
548
556
  map[projectRoot] = projectName;
549
557
  }
550
558
  return map;
@@ -9,12 +9,12 @@ import { LoadedNxPlugin } from '../plugins/internal-api';
9
9
  * @param nxJson
10
10
  */
11
11
  export declare function retrieveWorkspaceFiles(workspaceRoot: string, projectRootMap: Record<string, string>): Promise<{
12
- allWorkspaceFiles: import("../file-utils").FileData[];
12
+ allWorkspaceFiles: import("nx/src/devkit-exports").FileData[];
13
13
  fileMap: {
14
14
  projectFileMap: ProjectFiles;
15
- nonProjectFiles: import("../../native").FileData[];
15
+ nonProjectFiles: import("nx/src/native").FileData[];
16
16
  };
17
- rustReferences: import("../../native").NxWorkspaceFilesExternals;
17
+ rustReferences: import("nx/src/native").NxWorkspaceFilesExternals;
18
18
  }>;
19
19
  /**
20
20
  * Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const perf_hooks_1 = require("perf_hooks");
4
- if (process.env.NX_PERF_LOGGING === 'true') {
4
+ let initialized = false;
5
+ if (process.env.NX_PERF_LOGGING === 'true' && !initialized) {
6
+ initialized = true;
5
7
  const obs = new perf_hooks_1.PerformanceObserver((list) => {
6
8
  for (const entry of list.getEntries()) {
7
9
  console.log(`Time for '${entry.name}'`, entry.duration);