nx 20.5.0-beta.1 → 20.5.0-beta.3

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 (54) hide show
  1. package/package.json +11 -11
  2. package/src/adapter/compat.d.ts +1 -1
  3. package/src/adapter/compat.js +1 -0
  4. package/src/command-line/init/command-object.js +13 -6
  5. package/src/command-line/init/implementation/add-nx-to-turborepo.d.ts +4 -0
  6. package/src/command-line/init/implementation/add-nx-to-turborepo.js +49 -0
  7. package/src/command-line/init/implementation/deduce-default-base.d.ts +1 -0
  8. package/src/command-line/init/implementation/deduce-default-base.js +53 -0
  9. package/src/command-line/init/implementation/utils.d.ts +3 -1
  10. package/src/command-line/init/implementation/utils.js +91 -42
  11. package/src/command-line/init/init-v2.js +34 -14
  12. package/src/command-line/migrate/migrate.js +21 -18
  13. package/src/config/nx-json.d.ts +3 -2
  14. package/src/core/graph/main.js +1 -1
  15. package/src/core/graph/runtime.js +1 -1
  16. package/src/core/graph/styles.css +2 -2
  17. package/src/core/graph/styles.js +1 -1
  18. package/src/daemon/client/client.d.ts +2 -1
  19. package/src/daemon/client/client.js +17 -60
  20. package/src/daemon/client/enabled.d.ts +2 -0
  21. package/src/daemon/client/enabled.js +64 -0
  22. package/src/daemon/message-types/glob.d.ts +7 -0
  23. package/src/daemon/message-types/glob.js +9 -1
  24. package/src/daemon/message-types/hash-glob.d.ts +6 -0
  25. package/src/daemon/message-types/hash-glob.js +9 -1
  26. package/src/daemon/server/handle-glob.d.ts +1 -0
  27. package/src/daemon/server/handle-glob.js +8 -0
  28. package/src/daemon/server/handle-hash-glob.d.ts +1 -0
  29. package/src/daemon/server/handle-hash-glob.js +8 -0
  30. package/src/daemon/server/server.js +6 -0
  31. package/src/devkit-exports.d.ts +1 -1
  32. package/src/devkit-exports.js +2 -2
  33. package/src/devkit-internals.d.ts +1 -1
  34. package/src/devkit-internals.js +2 -1
  35. package/src/native/index.d.ts +8 -0
  36. package/src/native/nx.wasi.cjs +7 -7
  37. package/src/native/nx.wasm32-wasi.wasm +0 -0
  38. package/src/project-graph/affected/locators/project-glob-changes.js +2 -2
  39. package/src/project-graph/error-types.js +4 -1
  40. package/src/project-graph/nx-deps-cache.js +7 -2
  41. package/src/project-graph/plugins/get-plugins.js +2 -1
  42. package/src/project-graph/plugins/isolation/plugin-worker.js +4 -0
  43. package/src/project-graph/plugins/loaded-nx-plugin.d.ts +2 -1
  44. package/src/project-graph/plugins/loaded-nx-plugin.js +6 -9
  45. package/src/project-graph/plugins/tasks-execution-hooks.js +4 -3
  46. package/src/project-graph/plugins/utils.d.ts +2 -2
  47. package/src/project-graph/plugins/utils.js +2 -2
  48. package/src/project-graph/project-graph.js +5 -2
  49. package/src/project-graph/utils/project-configuration-utils.d.ts +1 -1
  50. package/src/project-graph/utils/project-configuration-utils.js +11 -9
  51. package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
  52. package/src/project-graph/utils/retrieve-workspace-files.js +14 -18
  53. package/src/utils/workspace-context.d.ts +2 -0
  54. package/src/utils/workspace-context.js +16 -0
@@ -93,6 +93,14 @@ export declare class WorkspaceContext {
93
93
  constructor(workspaceRoot: string, cacheDir: string)
94
94
  getWorkspaceFiles(projectRootMap: Record<string, string>): NxWorkspaceFiles
95
95
  glob(globs: Array<string>, exclude?: Array<string> | undefined | null): Array<string>
96
+ /**
97
+ * Performs multiple glob pattern matches against workspace files in parallel
98
+ * @returns An array of arrays, where each inner array contains the file paths
99
+ * that matched the corresponding glob pattern in the input. The outer array maintains the same order
100
+ * as the input globs.
101
+ */
102
+ multiGlob(globs: Array<string>, exclude?: Array<string> | undefined | null): Array<Array<string>>
103
+ hashFilesMatchingGlobs(globGroups: Array<Array<string>>): Array<string>
96
104
  hashFilesMatchingGlob(globs: Array<string>, exclude?: Array<string> | undefined | null): string
97
105
  incrementalUpdate(updatedFiles: Array<string>, deletedFiles: Array<string>): Record<string, string>
98
106
  updateProjectFiles(projectRootMappings: ProjectRootMappings, projectFiles: ExternalObject<ProjectFiles>, globalFiles: ExternalObject<Array<FileData>>, updatedFiles: Record<string, string>, deletedFiles: Array<string>): UpdatedWorkspaceFiles
@@ -119,13 +119,13 @@ function __napi_rs_initialize_modules(__napiInstance) {
119
119
  __napiInstance.exports['__napi_register__FileLock_struct_39']?.()
120
120
  __napiInstance.exports['__napi_register__FileLock_impl_41']?.()
121
121
  __napiInstance.exports['__napi_register__WorkspaceContext_struct_42']?.()
122
- __napiInstance.exports['__napi_register__WorkspaceContext_impl_51']?.()
123
- __napiInstance.exports['__napi_register__WorkspaceErrors_52']?.()
124
- __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_53']?.()
125
- __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_54']?.()
126
- __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_55']?.()
127
- __napiInstance.exports['__napi_register__FileMap_struct_56']?.()
128
- __napiInstance.exports['__napi_register____test_only_transfer_file_map_57']?.()
122
+ __napiInstance.exports['__napi_register__WorkspaceContext_impl_53']?.()
123
+ __napiInstance.exports['__napi_register__WorkspaceErrors_54']?.()
124
+ __napiInstance.exports['__napi_register__NxWorkspaceFiles_struct_55']?.()
125
+ __napiInstance.exports['__napi_register__NxWorkspaceFilesExternals_struct_56']?.()
126
+ __napiInstance.exports['__napi_register__UpdatedWorkspaceFiles_struct_57']?.()
127
+ __napiInstance.exports['__napi_register__FileMap_struct_58']?.()
128
+ __napiInstance.exports['__napi_register____test_only_transfer_file_map_59']?.()
129
129
  }
130
130
  module.exports.FileLock = __napiModule.exports.FileLock
131
131
  module.exports.HashPlanner = __napiModule.exports.HashPlanner
Binary file
@@ -20,8 +20,8 @@ const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGra
20
20
  'package.json',
21
21
  ]);
22
22
  }
23
- const plugins = await (0, get_plugins_1.getPlugins)();
24
- return (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(plugins));
23
+ const plugins = (await (0, get_plugins_1.getPlugins)()).filter((p) => !!p.createNodes);
24
+ return (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.getGlobPatternsOfPlugins)(plugins));
25
25
  })();
26
26
  const touchedProjects = new Set();
27
27
  for (const touchedFile of touchedFiles) {
@@ -216,7 +216,10 @@ class AggregateCreateNodesError extends Error {
216
216
  exports.AggregateCreateNodesError = AggregateCreateNodesError;
217
217
  function formatAggregateCreateNodesError(error, pluginName) {
218
218
  const errorBodyLines = [
219
- `${error.errors.length > 1 ? `${error.errors.length} errors` : 'An error'} occurred while processing files for the ${pluginName} plugin.`,
219
+ `${error.errors.length > 1 ? `${error.errors.length} errors` : 'An error'} occurred while processing files for the ${pluginName} plugin${error.pluginIndex
220
+ ? ` (Defined at nx.json#plugins[${error.pluginIndex}])`
221
+ : ''}`,
222
+ `.`,
220
223
  ];
221
224
  const errorStackLines = [];
222
225
  const innerErrors = error.errors;
@@ -150,10 +150,15 @@ function writeCache(cache, projectGraph, sourceMaps, errors) {
150
150
  computedAt: Date.now(),
151
151
  });
152
152
  (0, node_fs_1.renameSync)(tmpProjectGraphPath, exports.nxProjectGraph);
153
- (0, fileutils_1.writeJsonFile)(tmpFileMapPath, cache);
154
- (0, node_fs_1.renameSync)(tmpFileMapPath, exports.nxFileMap);
155
153
  (0, fileutils_1.writeJsonFile)(tmpSourceMapPath, sourceMaps);
156
154
  (0, node_fs_1.renameSync)(tmpSourceMapPath, exports.nxSourceMaps);
155
+ // only write the file map if there are no errors
156
+ // if there were errors, the errors make the filemap invalid
157
+ // TODO: We should be able to keep the valid part of the filemap if the errors being thrown told us which parts of the filemap were invalid
158
+ if (errors.length === 0) {
159
+ (0, fileutils_1.writeJsonFile)(tmpFileMapPath, cache);
160
+ (0, node_fs_1.renameSync)(tmpFileMapPath, exports.nxFileMap);
161
+ }
157
162
  done = true;
158
163
  }
159
164
  catch (err) {
@@ -108,12 +108,13 @@ async function loadSpecifiedNxPlugins(plugins, root = workspace_root_1.workspace
108
108
  plugins ??= [];
109
109
  const cleanupFunctions = [];
110
110
  const ret = [
111
- await Promise.all(plugins.map(async (plugin) => {
111
+ await Promise.all(plugins.map(async (plugin, index) => {
112
112
  const pluginPath = typeof plugin === 'string' ? plugin : plugin.plugin;
113
113
  performance.mark(`Load Nx Plugin: ${pluginPath} - start`);
114
114
  const [loadedPluginPromise, cleanup] = await loadingMethod(plugin, root);
115
115
  cleanupFunctions.push(cleanup);
116
116
  const res = await loadedPluginPromise;
117
+ res.index = index;
117
118
  performance.mark(`Load Nx Plugin: ${pluginPath} - end`);
118
119
  performance.measure(`Load Nx Plugin: ${pluginPath}`, `Load Nx Plugin: ${pluginPath} - start`, `Load Nx Plugin: ${pluginPath} - end`);
119
120
  return res;
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_perf_hooks_1 = require("node:perf_hooks");
4
+ node_perf_hooks_1.performance.mark(`plugin worker ${process.pid} code loading -- start`);
3
5
  const messaging_1 = require("./messaging");
4
6
  const serializable_error_1 = require("../../../utils/serializable-error");
5
7
  const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
@@ -8,6 +10,8 @@ const fs_1 = require("fs");
8
10
  if (process.env.NX_PERF_LOGGING === 'true') {
9
11
  require('../../../utils/perf-logging');
10
12
  }
13
+ node_perf_hooks_1.performance.mark(`plugin worker ${process.pid} code loading -- end`);
14
+ node_perf_hooks_1.performance.measure(`plugin worker ${process.pid} code loading`, `plugin worker ${process.pid} code loading -- start`, `plugin worker ${process.pid} code loading -- end`);
11
15
  global.NX_GRAPH_CREATION = true;
12
16
  global.NX_PLUGIN_WORKER = true;
13
17
  let connected = false;
@@ -1,8 +1,9 @@
1
1
  import type { ProjectGraph } from '../../config/project-graph';
2
- import type { PluginConfiguration } from '../../config/nx-json';
2
+ import { type PluginConfiguration } from '../../config/nx-json';
3
3
  import type { RawProjectGraphDependency } from '../project-graph-builder';
4
4
  import type { CreateDependenciesContext, CreateMetadataContext, CreateNodesContextV2, CreateNodesResult, NxPluginV2, PostTasksExecutionContext, PreTasksExecutionContext, ProjectsMetadata } from './public-api';
5
5
  export declare class LoadedNxPlugin {
6
+ index?: number;
6
7
  readonly name: string;
7
8
  readonly createNodes?: [
8
9
  filePattern: string,
@@ -4,7 +4,7 @@ exports.LoadedNxPlugin = void 0;
4
4
  const error_types_1 = require("../error-types");
5
5
  const utils_1 = require("./utils");
6
6
  const enabled_1 = require("./isolation/enabled");
7
- const client_1 = require("../../daemon/client/client");
7
+ const enabled_2 = require("../../daemon/client/enabled");
8
8
  class LoadedNxPlugin {
9
9
  constructor(plugin, pluginDefinition) {
10
10
  this.name = plugin.name;
@@ -57,22 +57,19 @@ class LoadedNxPlugin {
57
57
  if (plugin.preTasksExecution) {
58
58
  this.preTasksExecution = async (context) => {
59
59
  const updates = {};
60
- let revokeFn;
61
- if ((0, enabled_1.isIsolationEnabled)() || (0, client_1.isDaemonEnabled)()) {
62
- const { proxy, revoke } = Proxy.revocable(process.env, {
60
+ let originalEnv = process.env;
61
+ if ((0, enabled_1.isIsolationEnabled)() ||
62
+ (0, enabled_2.isDaemonEnabled)(context.nxJsonConfiguration)) {
63
+ process.env = new Proxy(originalEnv, {
63
64
  set: (target, key, value) => {
64
65
  target[key] = value;
65
66
  updates[key] = value;
66
67
  return true;
67
68
  },
68
69
  });
69
- process.env = proxy;
70
- revokeFn = revoke;
71
70
  }
72
71
  await plugin.preTasksExecution(this.options, context);
73
- if (revokeFn) {
74
- revokeFn();
75
- }
72
+ process.env = originalEnv;
76
73
  return updates;
77
74
  };
78
75
  }
@@ -5,8 +5,9 @@ exports.runPostTasksExecution = runPostTasksExecution;
5
5
  const get_plugins_1 = require("./get-plugins");
6
6
  const is_on_daemon_1 = require("../../daemon/is-on-daemon");
7
7
  const client_1 = require("../../daemon/client/client");
8
+ const enabled_1 = require("../../daemon/client/enabled");
8
9
  async function runPreTasksExecution(pluginContext) {
9
- if ((0, is_on_daemon_1.isOnDaemon)() || !(0, client_1.isDaemonEnabled)()) {
10
+ if ((0, is_on_daemon_1.isOnDaemon)() || !(0, enabled_1.isDaemonEnabled)(pluginContext.nxJsonConfiguration)) {
10
11
  performance.mark(`preTasksExecution:start`);
11
12
  const plugins = await (0, get_plugins_1.getPlugins)(pluginContext.workspaceRoot);
12
13
  const envs = await Promise.all(plugins
@@ -21,7 +22,7 @@ async function runPreTasksExecution(pluginContext) {
21
22
  performance.measure(`${plugin.name}:preTasksExecution`, `${plugin.name}:preTasksExecution:start`, `${plugin.name}:preTasksExecution:end`);
22
23
  }
23
24
  }));
24
- if (!(0, client_1.isDaemonEnabled)()) {
25
+ if (!(0, enabled_1.isDaemonEnabled)(pluginContext.nxJsonConfiguration)) {
25
26
  applyProcessEnvs(envs);
26
27
  }
27
28
  performance.mark(`preTasksExecution:end`);
@@ -41,7 +42,7 @@ function applyProcessEnvs(envs) {
41
42
  }
42
43
  }
43
44
  async function runPostTasksExecution(context) {
44
- if ((0, is_on_daemon_1.isOnDaemon)() || !(0, client_1.isDaemonEnabled)()) {
45
+ if ((0, is_on_daemon_1.isOnDaemon)() || !(0, enabled_1.isDaemonEnabled)(context.nxJsonConfiguration)) {
45
46
  performance.mark(`postTasksExecution:start`);
46
47
  const plugins = await (0, get_plugins_1.getPlugins)();
47
48
  await Promise.all(plugins
@@ -1,2 +1,2 @@
1
- import { CreateNodesContextV2, CreateNodesFunction, CreateNodesResult } from './public-api';
2
- export declare function createNodesFromFiles<T = unknown>(createNodes: CreateNodesFunction<T>, configFiles: readonly string[], options: T, context: CreateNodesContextV2): Promise<[file: string, value: CreateNodesResult][]>;
1
+ import { CreateNodesContext, CreateNodesContextV2, CreateNodesResult } from './public-api';
2
+ export declare function createNodesFromFiles<T = unknown>(createNodes: (projectConfigurationFile: string, options: T | undefined, context: CreateNodesContext, idx: number) => CreateNodesResult | Promise<CreateNodesResult>, configFiles: readonly string[], options: T, context: CreateNodesContextV2): Promise<[file: string, value: CreateNodesResult][]>;
@@ -5,12 +5,12 @@ const error_types_1 = require("../error-types");
5
5
  async function createNodesFromFiles(createNodes, configFiles, options, context) {
6
6
  const results = [];
7
7
  const errors = [];
8
- await Promise.all(configFiles.map(async (file) => {
8
+ await Promise.all(configFiles.map(async (file, idx) => {
9
9
  try {
10
10
  const value = await createNodes(file, options, {
11
11
  ...context,
12
12
  configFiles,
13
- });
13
+ }, idx);
14
14
  if (value) {
15
15
  results.push([file, value]);
16
16
  }
@@ -149,7 +149,7 @@ function handleProjectGraphError(opts, e) {
149
149
  bodyLines: bodyLines,
150
150
  });
151
151
  }
152
- else {
152
+ else if (typeof e.message === 'string') {
153
153
  const lines = e.message.split('\n');
154
154
  output_1.output.error({
155
155
  title: lines[0],
@@ -159,6 +159,9 @@ function handleProjectGraphError(opts, e) {
159
159
  console.error(e);
160
160
  }
161
161
  }
162
+ else {
163
+ console.error(e);
164
+ }
162
165
  process.exit(1);
163
166
  }
164
167
  else {
@@ -277,7 +280,7 @@ async function createProjectGraphAndSourceMapsAsync(opts = {
277
280
  handleProjectGraphError(opts, e);
278
281
  }
279
282
  finally {
280
- lock.unlock();
283
+ lock?.unlock();
281
284
  }
282
285
  }
283
286
  else {
@@ -35,7 +35,7 @@ export type ConfigurationResult = {
35
35
  * @param workspaceFiles A list of non-ignored workspace files
36
36
  * @param plugins The plugins that should be used to infer project configuration
37
37
  */
38
- export declare function createProjectConfigurations(root: string, nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
38
+ export declare function createProjectConfigurationsWithPlugins(root: string, nxJson: NxJsonConfiguration, projectFiles: string[][], // making this parameter allows devkit to pick up newly created projects
39
39
  plugins: LoadedNxPlugin[]): Promise<ConfigurationResult>;
40
40
  export declare function findMatchingConfigFiles(projectFiles: string[], pattern: string, include: string[], exclude: string[]): string[];
41
41
  export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRootMap;
4
4
  exports.mergeMetadata = mergeMetadata;
5
- exports.createProjectConfigurations = createProjectConfigurations;
5
+ exports.createProjectConfigurationsWithPlugins = createProjectConfigurationsWithPlugins;
6
6
  exports.findMatchingConfigFiles = findMatchingConfigFiles;
7
7
  exports.readProjectConfigurationsFromRootMap = readProjectConfigurationsFromRootMap;
8
8
  exports.validateProject = validateProject;
@@ -222,7 +222,7 @@ function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata
222
222
  * @param workspaceFiles A list of non-ignored workspace files
223
223
  * @param plugins The plugins that should be used to infer project configuration
224
224
  */
225
- async function createProjectConfigurations(root = workspace_root_1.workspaceRoot, nxJson, projectFiles, // making this parameter allows devkit to pick up newly created projects
225
+ async function createProjectConfigurationsWithPlugins(root = workspace_root_1.workspaceRoot, nxJson, projectFiles, // making this parameter allows devkit to pick up newly created projects
226
226
  plugins) {
227
227
  perf_hooks_1.performance.mark('build-project-configs:start');
228
228
  let spinner;
@@ -248,12 +248,12 @@ plugins) {
248
248
  const results = [];
249
249
  const errors = [];
250
250
  // We iterate over plugins first - this ensures that plugins specified first take precedence.
251
- for (const [index, { createNodes: createNodesTuple, include, exclude, name: pluginName },] of plugins.entries()) {
251
+ for (const [index, { index: pluginIndex, createNodes: createNodesTuple, include, exclude, name: pluginName, },] of plugins.entries()) {
252
252
  const [pattern, createNodes] = createNodesTuple ?? [];
253
253
  if (!pattern) {
254
254
  continue;
255
255
  }
256
- const matchingConfigFiles = findMatchingConfigFiles(projectFiles, pattern, include, exclude);
256
+ const matchingConfigFiles = findMatchingConfigFiles(projectFiles[index], pattern, include, exclude);
257
257
  inProgressPlugins.add(pluginName);
258
258
  let r = createNodes(matchingConfigFiles, {
259
259
  nxJsonConfiguration: nxJson,
@@ -265,8 +265,10 @@ plugins) {
265
265
  e
266
266
  : // This represents a single plugin erroring out with a hard error.
267
267
  new error_types_1.AggregateCreateNodesError([[null, e]], []);
268
+ if (pluginIndex) {
269
+ error.pluginIndex = pluginIndex;
270
+ }
268
271
  (0, error_types_1.formatAggregateCreateNodesError)(error, pluginName);
269
- error.pluginIndex = index;
270
272
  // This represents a single plugin erroring out with a hard error.
271
273
  errors.push(error);
272
274
  // The plugin didn't return partial results, so we return an empty array.
@@ -289,7 +291,7 @@ plugins) {
289
291
  externalNodes,
290
292
  projectRootMap: rootMap,
291
293
  sourceMaps: configurationSourceMaps,
292
- matchingProjectFiles: projectFiles,
294
+ matchingProjectFiles: projectFiles.flat(),
293
295
  };
294
296
  }
295
297
  else {
@@ -298,7 +300,7 @@ plugins) {
298
300
  externalNodes,
299
301
  projectRootMap: rootMap,
300
302
  sourceMaps: configurationSourceMaps,
301
- matchingProjectFiles: projectFiles,
303
+ matchingProjectFiles: projectFiles.flat(),
302
304
  });
303
305
  }
304
306
  });
@@ -309,7 +311,7 @@ function mergeCreateNodesResults(results, nxJsonConfiguration, errors) {
309
311
  const externalNodes = {};
310
312
  const configurationSourceMaps = {};
311
313
  for (const result of results.flat()) {
312
- const [pluginName, file, nodes, index] = result;
314
+ const [pluginName, file, nodes, pluginIndex] = result;
313
315
  const { projects: projectNodes, externalNodes: pluginExternalNodes } = nodes;
314
316
  const sourceInfo = [file, pluginName];
315
317
  for (const node in projectNodes) {
@@ -329,7 +331,7 @@ function mergeCreateNodesResults(results, nxJsonConfiguration, errors) {
329
331
  file,
330
332
  pluginName,
331
333
  error,
332
- pluginIndex: index,
334
+ pluginIndex,
333
335
  }));
334
336
  }
335
337
  }
@@ -23,4 +23,4 @@ export declare function retrieveProjectConfigurations(plugins: LoadedNxPlugin[],
23
23
  export declare function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot: string, nxJson: NxJsonConfiguration): Promise<ConfigurationResult>;
24
24
  export declare function retrieveProjectConfigurationPaths(root: string, plugins: Array<LoadedNxPlugin>): Promise<string[]>;
25
25
  export declare function retrieveProjectConfigurationsWithoutPluginInference(root: string): Promise<Record<string, ProjectConfiguration>>;
26
- export declare function configurationGlobs(plugins: Array<LoadedNxPlugin>): string[];
26
+ export declare function getGlobPatternsOfPlugins(plugins: Array<LoadedNxPlugin>): string[];
@@ -5,7 +5,7 @@ exports.retrieveProjectConfigurations = retrieveProjectConfigurations;
5
5
  exports.retrieveProjectConfigurationsWithAngularProjects = retrieveProjectConfigurationsWithAngularProjects;
6
6
  exports.retrieveProjectConfigurationPaths = retrieveProjectConfigurationPaths;
7
7
  exports.retrieveProjectConfigurationsWithoutPluginInference = retrieveProjectConfigurationsWithoutPluginInference;
8
- exports.configurationGlobs = configurationGlobs;
8
+ exports.getGlobPatternsOfPlugins = getGlobPatternsOfPlugins;
9
9
  const perf_hooks_1 = require("perf_hooks");
10
10
  const angular_json_1 = require("../../adapter/angular-json");
11
11
  const nx_json_1 = require("../../config/nx-json");
@@ -41,9 +41,10 @@ async function retrieveWorkspaceFiles(workspaceRoot, projectRootMap) {
41
41
  * Walk through the workspace and return `ProjectConfigurations`. Only use this if the projectFileMap is not needed.
42
42
  */
43
43
  async function retrieveProjectConfigurations(plugins, workspaceRoot, nxJson) {
44
- const globPatterns = configurationGlobs(plugins);
45
- const workspaceFiles = await (0, workspace_context_1.globWithWorkspaceContext)(workspaceRoot, globPatterns);
46
- return (0, project_configuration_utils_1.createProjectConfigurations)(workspaceRoot, nxJson, workspaceFiles, plugins);
44
+ const pluginsWithCreateNodes = plugins.filter((p) => !!p.createNodes);
45
+ const globPatterns = getGlobPatternsOfPlugins(pluginsWithCreateNodes);
46
+ const pluginConfigFiles = await (0, workspace_context_1.multiGlobWithWorkspaceContext)(workspaceRoot, globPatterns);
47
+ return (0, project_configuration_utils_1.createProjectConfigurationsWithPlugins)(workspaceRoot, nxJson, pluginConfigFiles, pluginsWithCreateNodes);
47
48
  }
48
49
  async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, nxJson) {
49
50
  const pluginsToLoad = nxJson?.plugins ?? [];
@@ -56,31 +57,26 @@ async function retrieveProjectConfigurationsWithAngularProjects(workspaceRoot, n
56
57
  const res = await retrieveProjectConfigurations(plugins, workspaceRoot, nxJson);
57
58
  return res;
58
59
  }
59
- function retrieveProjectConfigurationPaths(root, plugins) {
60
- const projectGlobPatterns = configurationGlobs(plugins);
61
- return (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns);
60
+ async function retrieveProjectConfigurationPaths(root, plugins) {
61
+ const projectGlobPatterns = getGlobPatternsOfPlugins(plugins);
62
+ const pluginConfigFiles = await (0, workspace_context_1.multiGlobWithWorkspaceContext)(root, projectGlobPatterns);
63
+ return pluginConfigFiles.flat();
62
64
  }
63
65
  const projectsWithoutPluginCache = new Map();
64
66
  // TODO: This function is called way too often, it should be optimized without this cache
65
67
  async function retrieveProjectConfigurationsWithoutPluginInference(root) {
66
68
  const nxJson = (0, nx_json_1.readNxJson)(root);
67
69
  const plugins = await (0, get_plugins_1.getOnlyDefaultPlugins)(); // only load default plugins
68
- const projectGlobPatterns = await retrieveProjectConfigurationPaths(root, plugins);
70
+ const projectGlobPatterns = getGlobPatternsOfPlugins(plugins);
69
71
  const cacheKey = root + ',' + projectGlobPatterns.join(',');
70
72
  if (projectsWithoutPluginCache.has(cacheKey)) {
71
73
  return projectsWithoutPluginCache.get(cacheKey);
72
74
  }
73
- const projectFiles = (await (0, workspace_context_1.globWithWorkspaceContext)(root, projectGlobPatterns)) ?? [];
74
- const { projects } = await (0, project_configuration_utils_1.createProjectConfigurations)(root, nxJson, projectFiles, plugins);
75
+ const projectFiles = (await (0, workspace_context_1.multiGlobWithWorkspaceContext)(root, projectGlobPatterns)) ?? [];
76
+ const { projects } = await (0, project_configuration_utils_1.createProjectConfigurationsWithPlugins)(root, nxJson, projectFiles, plugins);
75
77
  projectsWithoutPluginCache.set(cacheKey, projects);
76
78
  return projects;
77
79
  }
78
- function configurationGlobs(plugins) {
79
- const globPatterns = [];
80
- for (const plugin of plugins) {
81
- if ('createNodes' in plugin && plugin.createNodes) {
82
- globPatterns.push(plugin.createNodes[0]);
83
- }
84
- }
85
- return globPatterns;
80
+ function getGlobPatternsOfPlugins(plugins) {
81
+ return plugins.map((p) => p.createNodes[0]);
86
82
  }
@@ -10,7 +10,9 @@ export declare function getNxWorkspaceFilesFromContext(workspaceRoot: string, pr
10
10
  */
11
11
  export declare function globWithWorkspaceContextSync(workspaceRoot: string, globs: string[], exclude?: string[]): string[];
12
12
  export declare function globWithWorkspaceContext(workspaceRoot: string, globs: string[], exclude?: string[]): Promise<string[]>;
13
+ export declare function multiGlobWithWorkspaceContext(workspaceRoot: string, globs: string[], exclude?: string[]): Promise<string[][]>;
13
14
  export declare function hashWithWorkspaceContext(workspaceRoot: string, globs: string[], exclude?: string[]): Promise<string>;
15
+ export declare function hashMultiGlobWithWorkspaceContext(workspaceRoot: string, globGroups: string[][]): Promise<string[]>;
14
16
  export declare function updateContextWithChangedFiles(workspaceRoot: string, createdFiles: string[], updatedFiles: string[], deletedFiles: string[]): Promise<void>;
15
17
  export declare function updateFilesInContext(workspaceRoot: string, updatedFiles: string[], deletedFiles: string[]): Record<string, string>;
16
18
  export declare function getAllFileDataInContext(workspaceRoot: string): Promise<import("../native").FileData[]>;
@@ -4,7 +4,9 @@ exports.setupWorkspaceContext = setupWorkspaceContext;
4
4
  exports.getNxWorkspaceFilesFromContext = getNxWorkspaceFilesFromContext;
5
5
  exports.globWithWorkspaceContextSync = globWithWorkspaceContextSync;
6
6
  exports.globWithWorkspaceContext = globWithWorkspaceContext;
7
+ exports.multiGlobWithWorkspaceContext = multiGlobWithWorkspaceContext;
7
8
  exports.hashWithWorkspaceContext = hashWithWorkspaceContext;
9
+ exports.hashMultiGlobWithWorkspaceContext = hashMultiGlobWithWorkspaceContext;
8
10
  exports.updateContextWithChangedFiles = updateContextWithChangedFiles;
9
11
  exports.updateFilesInContext = updateFilesInContext;
10
12
  exports.getAllFileDataInContext = getAllFileDataInContext;
@@ -50,6 +52,13 @@ async function globWithWorkspaceContext(workspaceRoot, globs, exclude) {
50
52
  return client_1.daemonClient.glob(globs, exclude);
51
53
  }
52
54
  }
55
+ async function multiGlobWithWorkspaceContext(workspaceRoot, globs, exclude) {
56
+ if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
57
+ ensureContextAvailable(workspaceRoot);
58
+ return workspaceContext.multiGlob(globs, exclude);
59
+ }
60
+ return client_1.daemonClient.multiGlob(globs, exclude);
61
+ }
53
62
  async function hashWithWorkspaceContext(workspaceRoot, globs, exclude) {
54
63
  if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
55
64
  ensureContextAvailable(workspaceRoot);
@@ -57,6 +66,13 @@ async function hashWithWorkspaceContext(workspaceRoot, globs, exclude) {
57
66
  }
58
67
  return client_1.daemonClient.hashGlob(globs, exclude);
59
68
  }
69
+ async function hashMultiGlobWithWorkspaceContext(workspaceRoot, globGroups) {
70
+ if ((0, is_on_daemon_1.isOnDaemon)() || !client_1.daemonClient.enabled()) {
71
+ ensureContextAvailable(workspaceRoot);
72
+ return workspaceContext.hashFilesMatchingGlobs(globGroups);
73
+ }
74
+ return client_1.daemonClient.hashMultiGlob(globGroups);
75
+ }
60
76
  async function updateContextWithChangedFiles(workspaceRoot, createdFiles, updatedFiles, deletedFiles) {
61
77
  if (!client_1.daemonClient.enabled()) {
62
78
  updateFilesInContext(workspaceRoot, [...createdFiles, ...updatedFiles], deletedFiles);