nx 22.7.0 → 23.0.0-beta.0

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 (33) hide show
  1. package/dist/src/config/workspace-json-project-json.d.ts +10 -0
  2. package/dist/src/daemon/server/handle-hash-tasks.js +1 -1
  3. package/dist/src/daemon/server/project-graph-incremental-recomputation.d.ts +1 -4
  4. package/dist/src/daemon/server/project-graph-incremental-recomputation.js +11 -20
  5. package/dist/src/executors/utils/convert-nx-executor.js +2 -2
  6. package/dist/src/hasher/create-task-hasher.js +1 -1
  7. package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
  8. package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
  9. package/dist/src/project-graph/build-project-graph.d.ts +2 -4
  10. package/dist/src/project-graph/build-project-graph.js +2 -7
  11. package/dist/src/project-graph/file-map-utils.d.ts +2 -4
  12. package/dist/src/project-graph/file-map-utils.js +0 -3
  13. package/dist/src/project-graph/plugins/get-plugins.d.ts +15 -0
  14. package/dist/src/project-graph/plugins/get-plugins.js +21 -3
  15. package/dist/src/project-graph/project-graph.js +7 -6
  16. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.d.ts +40 -64
  17. package/dist/src/project-graph/utils/project-configuration/name-substitution-manager.js +182 -411
  18. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.d.ts +10 -4
  19. package/dist/src/project-graph/utils/project-configuration/project-nodes-manager.js +22 -8
  20. package/dist/src/project-graph/utils/project-configuration/source-maps.d.ts +4 -61
  21. package/dist/src/project-graph/utils/project-configuration/source-maps.js +14 -59
  22. package/dist/src/project-graph/utils/project-configuration/target-defaults.d.ts +16 -0
  23. package/dist/src/project-graph/utils/project-configuration/target-defaults.js +117 -0
  24. package/dist/src/project-graph/utils/project-configuration/target-merging.d.ts +1 -4
  25. package/dist/src/project-graph/utils/project-configuration/target-merging.js +261 -136
  26. package/dist/src/project-graph/utils/project-configuration/target-normalization.js +0 -7
  27. package/dist/src/project-graph/utils/project-configuration/utils.d.ts +23 -0
  28. package/dist/src/project-graph/utils/project-configuration/utils.js +164 -0
  29. package/dist/src/project-graph/utils/project-configuration-utils.d.ts +33 -9
  30. package/dist/src/project-graph/utils/project-configuration-utils.js +153 -65
  31. package/dist/src/project-graph/utils/retrieve-workspace-files.d.ts +6 -3
  32. package/dist/src/project-graph/utils/retrieve-workspace-files.js +32 -13
  33. package/package.json +11 -11
@@ -1,7 +1,7 @@
1
1
  import { ProjectConfiguration } from '../../../config/workspace-json-project-json';
2
2
  import type { ConfigurationSourceMaps, SourceInformation } from './source-maps';
3
3
  export { validateProject } from './target-normalization';
4
- export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Record<string, ProjectConfiguration>, project: ProjectConfiguration, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation, skipTargetNormalization?: boolean): {
4
+ export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Record<string, ProjectConfiguration>, project: ProjectConfiguration, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation, skipTargetNormalization?: boolean, deferSpreadsWithoutBase?: boolean): {
5
5
  nameChanged: boolean;
6
6
  };
7
7
  export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
@@ -27,10 +27,16 @@ export declare class ProjectNodesManager {
27
27
  */
28
28
  mergeProjectNode(project: ProjectConfiguration, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation): void;
29
29
  /**
30
- * Registers substitutors for a plugin result's project references
31
- * in `inputs` and `dependsOn`.
30
+ * Inserts project-name sentinels into `inputs` and `dependsOn` on the
31
+ * merged objects from `mergedRootMap` (defaulting to this manager's
32
+ * rootMap). Walking the merged entries matters because a spread-produced
33
+ * array is a fresh instance.
34
+ *
35
+ * Pass a different `mergedRootMap` for the default-plugin intermediate
36
+ * pass, then call again with `this.rootMap` after it's applied so
37
+ * sentinel parents rebind onto the final arrays.
32
38
  */
33
- registerSubstitutors(pluginResultProjects?: Record<string, Omit<ProjectConfiguration, 'root'> & Partial<ProjectConfiguration>>): void;
39
+ registerNameRefs(pluginResultProjects?: Record<string, Omit<ProjectConfiguration, 'root'> & Partial<ProjectConfiguration>>, mergedRootMap?: Record<string, ProjectConfiguration>): void;
34
40
  /**
35
41
  * Applies all pending name substitutions. Call once after all plugin
36
42
  * results have been merged.
@@ -16,7 +16,7 @@ Object.defineProperty(exports, "validateProject", { enumerable: true, get: funct
16
16
  function mergeProjectConfigurationIntoRootMap(projectRootMap, project, configurationSourceMaps, sourceInformation,
17
17
  // This function is used when reading project configuration
18
18
  // in generators, where we don't want to do this.
19
- skipTargetNormalization) {
19
+ skipTargetNormalization, deferSpreadsWithoutBase) {
20
20
  project.root = project.root === '' ? '.' : project.root;
21
21
  if (configurationSourceMaps && !configurationSourceMaps[project.root]) {
22
22
  configurationSourceMaps[project.root] = {};
@@ -143,7 +143,7 @@ skipTargetNormalization) {
143
143
  }
144
144
  for (const matchingTargetName of matchingTargets) {
145
145
  updatedProjectConfiguration.targets[matchingTargetName] =
146
- (0, target_merging_1.mergeTargetConfigurations)(normalizedTarget, matchingProject.targets?.[matchingTargetName], sourceMap, sourceInformation, `targets.${matchingTargetName}`);
146
+ (0, target_merging_1.mergeTargetConfigurations)(normalizedTarget, matchingProject.targets?.[matchingTargetName], sourceMap, sourceInformation, `targets.${matchingTargetName}`, deferSpreadsWithoutBase);
147
147
  }
148
148
  }
149
149
  }
@@ -217,8 +217,8 @@ class ProjectNodesManager {
217
217
  this.rootMap = {};
218
218
  // name → ProjectConfiguration (same object references as rootMap)
219
219
  this.nameMap = {};
220
- // Pass a lazy accessor so the substitution manager always sees
221
- // the current nameMap without manual synchronization.
220
+ // Pass a lazy accessor so the substitution manager always sees the
221
+ // current nameMap without manual synchronization.
222
222
  this.nameSubstitutionManager = new name_substitution_manager_1.ProjectNameInNodePropsManager(() => this.nameMap);
223
223
  }
224
224
  getRootMap() {
@@ -247,11 +247,25 @@ class ProjectNodesManager {
247
247
  }
248
248
  }
249
249
  /**
250
- * Registers substitutors for a plugin result's project references
251
- * in `inputs` and `dependsOn`.
250
+ * Inserts project-name sentinels into `inputs` and `dependsOn` on the
251
+ * merged objects from `mergedRootMap` (defaulting to this manager's
252
+ * rootMap). Walking the merged entries matters because a spread-produced
253
+ * array is a fresh instance.
254
+ *
255
+ * Pass a different `mergedRootMap` for the default-plugin intermediate
256
+ * pass, then call again with `this.rootMap` after it's applied so
257
+ * sentinel parents rebind onto the final arrays.
252
258
  */
253
- registerSubstitutors(pluginResultProjects) {
254
- this.nameSubstitutionManager.registerSubstitutorsForNodeResults(pluginResultProjects);
259
+ registerNameRefs(pluginResultProjects, mergedRootMap = this.rootMap) {
260
+ if (!pluginResultProjects)
261
+ return;
262
+ const scoped = {};
263
+ for (const root in pluginResultProjects) {
264
+ if (mergedRootMap[root]) {
265
+ scoped[root] = mergedRootMap[root];
266
+ }
267
+ }
268
+ this.nameSubstitutionManager.registerNameRefs(scoped);
255
269
  }
256
270
  /**
257
271
  * Applies all pending name substitutions. Call once after all plugin
@@ -1,69 +1,12 @@
1
- /**
2
- * Utilities for constructing source map keys used to track the origin
3
- * of project configuration properties. Source map keys are dot-delimited
4
- * paths into a ProjectConfiguration, e.g. `targets.build.inputs.0.projects`.
5
- *
6
- * Centralizing key construction here prevents typos and ensures consistent
7
- * key shapes across the project graph build pipeline.
8
- */
9
- /** Describes the file and plugin that contributed a given configuration property. */
1
+ /** [file, plugin] that contributed a configuration property. */
10
2
  export type SourceInformation = [file: string | null, plugin: string];
11
- /** Maps each project root to a source map for its configuration properties. */
3
+ /** Source map per project root. */
12
4
  export type ConfigurationSourceMaps = Record<string, Record<string, SourceInformation>>;
13
- /**
14
- * Calls `callback` with the source map key for each index of `array` under
15
- * `prefixKey`, producing keys like `${prefixKey}.0`, `${prefixKey}.1`, etc.
16
- *
17
- * Use this when you need the keys themselves — e.g. to register or clear
18
- * entries in a name substitution manager — without necessarily writing to a
19
- * source map.
20
- *
21
- * @param prefixKey The dot-delimited path prefix for the array (e.g. `"targets.build.inputs"`).
22
- * @param array The array whose indices should be iterated.
23
- * @param callback Called with the key for each index.
24
- * @param startIndex Index to start from. Useful when appending to an existing array.
25
- */
26
5
  export declare function forEachSourceMapKeyForArray(prefixKey: string, array: unknown[], callback: (key: string, index: number) => void, startIndex?: number): void;
27
- /**
28
- * Records a single source map entry. Prefer this over direct bracket
29
- * assignment to keep writes consistent with the rest of the source map API.
30
- */
6
+ export declare function readArrayItemSourceInfo(sourceMap: Record<string, SourceInformation>, arrayKey: string, itemIndex: number): SourceInformation | undefined;
7
+ export declare function readObjectPropertySourceInfo(sourceMap: Record<string, SourceInformation>, objectKey: string, propertyKey: string): SourceInformation | undefined;
31
8
  export declare function recordSourceMapInfo(sourceMap: Record<string, SourceInformation>, key: string, sourceInfo: SourceInformation): void;
32
- /**
33
- * Convenience wrapper that records a source map entry for each index of
34
- * `array` under `prefixKey`. Equivalent to calling {@link forEachSourceMapKeyForArray}
35
- * and {@link recordSourceMapInfo} together.
36
- *
37
- * @param sourceMap The source map to write into.
38
- * @param prefixKey The dot-delimited path prefix for the array (e.g. `"targets.build.inputs"`).
39
- * @param array The array whose indices should be recorded.
40
- * @param sourceInfo The source information to associate with each index key.
41
- * @param startIndex Index to start writing from. Useful when appending to an existing array.
42
- */
43
9
  export declare function recordSourceMapKeysByIndex(sourceMap: Record<string, SourceInformation>, prefixKey: string, array: unknown[], sourceInfo: SourceInformation, startIndex?: number): void;
44
- /**
45
- * Builds a source map key for a target entry.
46
- *
47
- * @example
48
- * // Returns "targets.build"
49
- * targetSourceMapKey('build')
50
- */
51
10
  export declare function targetSourceMapKey(targetName: string): string;
52
- /**
53
- * Builds a source map key for a specific option within a target.
54
- *
55
- * @example
56
- * // Returns "targets.build.options.outputPath"
57
- * targetOptionSourceMapKey('build', 'outputPath')
58
- */
59
11
  export declare function targetOptionSourceMapKey(targetName: string, optionKey: string): string;
60
- /**
61
- * Builds a source map key for a target's configurations section, optionally
62
- * scoped to a specific configuration name and key within it.
63
- *
64
- * @example
65
- * targetConfigurationsSourceMapKey('build') // "targets.build.configurations"
66
- * targetConfigurationsSourceMapKey('build', 'production') // "targets.build.configurations.production"
67
- * targetConfigurationsSourceMapKey('build', 'production', 'outputHashing') // "targets.build.configurations.production.outputHashing"
68
- */
69
12
  export declare function targetConfigurationsSourceMapKey(targetName: string, configurationName?: string, configurationKey?: string): string;
@@ -1,87 +1,42 @@
1
1
  "use strict";
2
- /**
3
- * Utilities for constructing source map keys used to track the origin
4
- * of project configuration properties. Source map keys are dot-delimited
5
- * paths into a ProjectConfiguration, e.g. `targets.build.inputs.0.projects`.
6
- *
7
- * Centralizing key construction here prevents typos and ensures consistent
8
- * key shapes across the project graph build pipeline.
9
- */
2
+ // Source map keys are dot-delimited paths into a ProjectConfiguration,
3
+ // e.g. `targets.build.inputs.0.projects`.
10
4
  Object.defineProperty(exports, "__esModule", { value: true });
11
5
  exports.forEachSourceMapKeyForArray = forEachSourceMapKeyForArray;
6
+ exports.readArrayItemSourceInfo = readArrayItemSourceInfo;
7
+ exports.readObjectPropertySourceInfo = readObjectPropertySourceInfo;
12
8
  exports.recordSourceMapInfo = recordSourceMapInfo;
13
9
  exports.recordSourceMapKeysByIndex = recordSourceMapKeysByIndex;
14
10
  exports.targetSourceMapKey = targetSourceMapKey;
15
11
  exports.targetOptionSourceMapKey = targetOptionSourceMapKey;
16
12
  exports.targetConfigurationsSourceMapKey = targetConfigurationsSourceMapKey;
17
- /**
18
- * Calls `callback` with the source map key for each index of `array` under
19
- * `prefixKey`, producing keys like `${prefixKey}.0`, `${prefixKey}.1`, etc.
20
- *
21
- * Use this when you need the keys themselves — e.g. to register or clear
22
- * entries in a name substitution manager — without necessarily writing to a
23
- * source map.
24
- *
25
- * @param prefixKey The dot-delimited path prefix for the array (e.g. `"targets.build.inputs"`).
26
- * @param array The array whose indices should be iterated.
27
- * @param callback Called with the key for each index.
28
- * @param startIndex Index to start from. Useful when appending to an existing array.
29
- */
13
+ // Iterates `${prefixKey}.0`, `${prefixKey}.1`, ... for each index of `array`.
30
14
  function forEachSourceMapKeyForArray(prefixKey, array, callback, startIndex = 0) {
31
15
  for (let i = startIndex; i < array.length; i++) {
32
16
  callback(`${prefixKey}.${i}`, i);
33
17
  }
34
18
  }
35
- /**
36
- * Records a single source map entry. Prefer this over direct bracket
37
- * assignment to keep writes consistent with the rest of the source map API.
38
- */
19
+ // Reads per-index source info, falling back to the array's top-level entry.
20
+ function readArrayItemSourceInfo(sourceMap, arrayKey, itemIndex) {
21
+ return sourceMap[`${arrayKey}.${itemIndex}`] ?? sourceMap[arrayKey];
22
+ }
23
+ // Reads per-property source info, falling back to the object's top-level entry.
24
+ function readObjectPropertySourceInfo(sourceMap, objectKey, propertyKey) {
25
+ return sourceMap[`${objectKey}.${propertyKey}`] ?? sourceMap[objectKey];
26
+ }
39
27
  function recordSourceMapInfo(sourceMap, key, sourceInfo) {
40
28
  sourceMap[key] = sourceInfo;
41
29
  }
42
- /**
43
- * Convenience wrapper that records a source map entry for each index of
44
- * `array` under `prefixKey`. Equivalent to calling {@link forEachSourceMapKeyForArray}
45
- * and {@link recordSourceMapInfo} together.
46
- *
47
- * @param sourceMap The source map to write into.
48
- * @param prefixKey The dot-delimited path prefix for the array (e.g. `"targets.build.inputs"`).
49
- * @param array The array whose indices should be recorded.
50
- * @param sourceInfo The source information to associate with each index key.
51
- * @param startIndex Index to start writing from. Useful when appending to an existing array.
52
- */
30
+ // Records the same source info under every `${prefixKey}.${i}` entry.
53
31
  function recordSourceMapKeysByIndex(sourceMap, prefixKey, array, sourceInfo, startIndex = 0) {
54
32
  forEachSourceMapKeyForArray(prefixKey, array, (key) => recordSourceMapInfo(sourceMap, key, sourceInfo), startIndex);
55
33
  }
56
- /**
57
- * Builds a source map key for a target entry.
58
- *
59
- * @example
60
- * // Returns "targets.build"
61
- * targetSourceMapKey('build')
62
- */
63
34
  function targetSourceMapKey(targetName) {
64
35
  return `targets.${targetName}`;
65
36
  }
66
- /**
67
- * Builds a source map key for a specific option within a target.
68
- *
69
- * @example
70
- * // Returns "targets.build.options.outputPath"
71
- * targetOptionSourceMapKey('build', 'outputPath')
72
- */
73
37
  function targetOptionSourceMapKey(targetName, optionKey) {
74
38
  return `targets.${targetName}.options.${optionKey}`;
75
39
  }
76
- /**
77
- * Builds a source map key for a target's configurations section, optionally
78
- * scoped to a specific configuration name and key within it.
79
- *
80
- * @example
81
- * targetConfigurationsSourceMapKey('build') // "targets.build.configurations"
82
- * targetConfigurationsSourceMapKey('build', 'production') // "targets.build.configurations.production"
83
- * targetConfigurationsSourceMapKey('build', 'production', 'outputHashing') // "targets.build.configurations.production.outputHashing"
84
- */
85
40
  function targetConfigurationsSourceMapKey(targetName, configurationName, configurationKey) {
86
41
  let key = `targets.${targetName}.configurations`;
87
42
  if (configurationName) {
@@ -0,0 +1,16 @@
1
+ import { NxJsonConfiguration, TargetDefaults } from '../../../config/nx-json';
2
+ import { ProjectConfiguration } from '../../../config/workspace-json-project-json';
3
+ import type { CreateNodesResult } from '../../plugins/public-api';
4
+ type CreateNodesResultEntry = readonly [
5
+ plugin: string,
6
+ file: string,
7
+ result: CreateNodesResult,
8
+ pluginIndex?: number
9
+ ];
10
+ /**
11
+ * Builds a synthetic plugin result from nx.json's `targetDefaults`, layered
12
+ * between specified-plugin and default-plugin results during merging.
13
+ */
14
+ export declare function createTargetDefaultsResults(specifiedPluginRootMap: Record<string, ProjectConfiguration>, defaultPluginRootMap: Record<string, ProjectConfiguration>, nxJsonConfiguration: NxJsonConfiguration): CreateNodesResultEntry[];
15
+ export declare function readTargetDefaultsForTarget(targetName: string, targetDefaults: TargetDefaults, executor?: string): TargetDefaults[string];
16
+ export {};
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTargetDefaultsResults = createTargetDefaultsResults;
4
+ exports.readTargetDefaultsForTarget = readTargetDefaultsForTarget;
5
+ const minimatch_1 = require("minimatch");
6
+ const globs_1 = require("../../../utils/globs");
7
+ const target_merging_1 = require("./target-merging");
8
+ const utils_1 = require("./utils");
9
+ /**
10
+ * Builds a synthetic plugin result from nx.json's `targetDefaults`, layered
11
+ * between specified-plugin and default-plugin results during merging.
12
+ */
13
+ function createTargetDefaultsResults(specifiedPluginRootMap, defaultPluginRootMap, nxJsonConfiguration) {
14
+ const targetDefaultsConfig = nxJsonConfiguration.targetDefaults;
15
+ if (!targetDefaultsConfig) {
16
+ return [];
17
+ }
18
+ const syntheticProjects = {};
19
+ const allRoots = new Set([
20
+ ...Object.keys(specifiedPluginRootMap),
21
+ ...Object.keys(defaultPluginRootMap),
22
+ ]);
23
+ for (const root of allRoots) {
24
+ const specifiedTargets = specifiedPluginRootMap[root]?.targets ?? {};
25
+ const defaultTargets = defaultPluginRootMap[root]?.targets ?? {};
26
+ for (const targetName of (0, utils_1.uniqueKeysInObjects)(specifiedTargets, defaultTargets)) {
27
+ const syntheticTarget = buildSyntheticTargetForRoot(targetName, root, specifiedTargets[targetName], defaultTargets[targetName], targetDefaultsConfig);
28
+ if (!syntheticTarget)
29
+ continue;
30
+ syntheticProjects[root] ??= { root, targets: {} };
31
+ syntheticProjects[root].targets[targetName] = syntheticTarget;
32
+ }
33
+ }
34
+ if (Object.keys(syntheticProjects).length === 0) {
35
+ return [];
36
+ }
37
+ return [
38
+ [
39
+ 'nx/target-defaults',
40
+ 'nx.json',
41
+ {
42
+ projects: syntheticProjects,
43
+ },
44
+ ],
45
+ ];
46
+ }
47
+ // Returns the synthetic defaults target to insert for `targetName` at
48
+ // `root`, or undefined if no defaults apply.
49
+ // Layering: specified plugins < target defaults < default plugins.
50
+ function buildSyntheticTargetForRoot(targetName, root, specifiedTarget, defaultTarget, targetDefaultsConfig) {
51
+ const resolvedSpecified = specifiedTarget
52
+ ? (0, target_merging_1.resolveCommandSyntacticSugar)(specifiedTarget, root)
53
+ : undefined;
54
+ const resolvedDefault = defaultTarget
55
+ ? (0, target_merging_1.resolveCommandSyntacticSugar)(defaultTarget, root)
56
+ : undefined;
57
+ // Specified-only: layer defaults on top; the downstream merge handles
58
+ // executor mismatches by replacing.
59
+ if (resolvedSpecified && !resolvedDefault) {
60
+ return readAndPrepareTargetDefaults(targetName, resolvedSpecified.executor, root, targetDefaultsConfig);
61
+ }
62
+ // Default-only.
63
+ if (resolvedDefault && !resolvedSpecified) {
64
+ return readAndPrepareTargetDefaults(targetName, resolvedDefault.executor, root, targetDefaultsConfig);
65
+ }
66
+ if (!resolvedSpecified || !resolvedDefault)
67
+ return undefined;
68
+ // Both compatible: use the default plugin's executor for the lookup.
69
+ if ((0, target_merging_1.isCompatibleTarget)(resolvedSpecified, resolvedDefault)) {
70
+ return readAndPrepareTargetDefaults(targetName, resolvedDefault.executor || resolvedSpecified.executor, root, targetDefaultsConfig);
71
+ }
72
+ // Incompatible: default plugin will replace specified; only defaults
73
+ // matching the default plugin's executor are useful.
74
+ const targetDefaults = readAndPrepareTargetDefaults(targetName, resolvedDefault.executor, root, targetDefaultsConfig);
75
+ if (targetDefaults && (0, target_merging_1.isCompatibleTarget)(resolvedDefault, targetDefaults)) {
76
+ // Stamp executor/command so the default layer merges cleanly on top.
77
+ return {
78
+ ...targetDefaults,
79
+ executor: resolvedDefault.executor,
80
+ command: resolvedDefault.command,
81
+ };
82
+ }
83
+ return undefined;
84
+ }
85
+ function readAndPrepareTargetDefaults(targetName, executor, root, targetDefaultsConfig) {
86
+ const rawTargetDefaults = readTargetDefaultsForTarget(targetName, targetDefaultsConfig, executor);
87
+ if (!rawTargetDefaults)
88
+ return undefined;
89
+ return (0, target_merging_1.resolveCommandSyntacticSugar)((0, target_merging_1.deepClone)(rawTargetDefaults), root);
90
+ }
91
+ function readTargetDefaultsForTarget(targetName, targetDefaults, executor) {
92
+ if (executor && targetDefaults?.[executor]) {
93
+ // If an executor is defined in project.json, defaults should be read
94
+ // from the most specific key that matches that executor.
95
+ // e.g. If executor === run-commands, and the target is named build:
96
+ // Use, use nx:run-commands if it is present
97
+ // If not, use build if it is present.
98
+ return targetDefaults?.[executor];
99
+ }
100
+ else if (targetDefaults?.[targetName]) {
101
+ // If the executor is not defined, the only key we have is the target name.
102
+ return targetDefaults?.[targetName];
103
+ }
104
+ let matchingTargetDefaultKey = null;
105
+ for (const key in targetDefaults ?? {}) {
106
+ if ((0, globs_1.isGlobPattern)(key) && (0, minimatch_1.minimatch)(targetName, key)) {
107
+ if (!matchingTargetDefaultKey ||
108
+ matchingTargetDefaultKey.length < key.length) {
109
+ matchingTargetDefaultKey = key;
110
+ }
111
+ }
112
+ }
113
+ if (matchingTargetDefaultKey) {
114
+ return targetDefaults[matchingTargetDefaultKey];
115
+ }
116
+ return null;
117
+ }
@@ -1,5 +1,4 @@
1
1
  import { ProjectConfiguration, ProjectMetadata, TargetConfiguration, TargetMetadata } from '../../../config/workspace-json-project-json';
2
- import { TargetDefaults } from '../../../config/nx-json';
3
2
  import type { SourceInformation } from './source-maps';
4
3
  export declare function deepClone<T>(obj: T): T;
5
4
  export declare function resolveCommandSyntacticSugar(target: TargetConfiguration, key: string): TargetConfiguration;
@@ -17,7 +16,7 @@ export declare function mergeMetadata<T = ProjectMetadata | TargetMetadata>(sour
17
16
  * @param targetIdentifier The identifier for the target to merge, used for source map
18
17
  * @returns A merged target configuration
19
18
  */
20
- export declare function mergeTargetConfigurations(target: TargetConfiguration, baseTarget?: TargetConfiguration, projectConfigSourceMap?: Record<string, SourceInformation>, sourceInformation?: SourceInformation, targetIdentifier?: string): TargetConfiguration;
19
+ export declare function mergeTargetConfigurations(target: TargetConfiguration, baseTarget?: TargetConfiguration, projectConfigSourceMap?: Record<string, SourceInformation>, sourceInformation?: SourceInformation, targetIdentifier?: string, deferSpreadsWithoutBase?: boolean): TargetConfiguration;
21
20
  /**
22
21
  * Checks if targets options are compatible - used when merging configurations
23
22
  * to avoid merging options for @nx/js:tsc into something like @nx/webpack:webpack.
@@ -26,6 +25,4 @@ export declare function mergeTargetConfigurations(target: TargetConfiguration, b
26
25
  * "compatible" and shouldn't be merged.
27
26
  */
28
27
  export declare function isCompatibleTarget(a: TargetConfiguration, b: TargetConfiguration): boolean;
29
- export declare function mergeTargetDefaultWithTargetDefinition(targetName: string, project: ProjectConfiguration, targetDefault: Partial<TargetConfiguration>, sourceMap: Record<string, SourceInformation>): TargetConfiguration;
30
28
  export declare function resolveNxTokensInOptions<T extends Object | Array<unknown>>(object: T, project: ProjectConfiguration, key: string): T;
31
- export declare function readTargetDefaultsForTarget(targetName: string, targetDefaults: TargetDefaults, executor?: string): TargetDefaults[string];