nx 19.0.0-canary.20240423-b37bfdb → 19.0.0-canary.20240426-ac9ad35
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.
- package/.eslintrc.json +1 -1
- package/package.json +12 -12
- package/src/command-line/init/implementation/react/index.js +1 -1
- package/src/config/nx-json.d.ts +2 -2
- package/src/core/graph/index.html +1 -2
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/runtime.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +8 -8
- package/src/devkit-exports.d.ts +1 -1
- package/src/devkit-internals.d.ts +2 -0
- package/src/devkit-internals.js +5 -1
- package/src/executors/utils/convert-nx-executor.js +2 -1
- package/src/generators/utils/project-configuration.js +2 -2
- package/src/project-graph/build-project-graph.d.ts +8 -18
- package/src/project-graph/build-project-graph.js +58 -54
- package/src/project-graph/error-types.d.ts +26 -3
- package/src/project-graph/error-types.js +57 -1
- package/src/project-graph/file-utils.js +1 -1
- package/src/project-graph/plugins/internal-api.d.ts +3 -2
- package/src/project-graph/plugins/internal-api.js +3 -0
- package/src/project-graph/plugins/isolation/messaging.d.ts +24 -3
- package/src/project-graph/plugins/isolation/plugin-pool.js +20 -0
- package/src/project-graph/plugins/isolation/plugin-worker.js +19 -0
- package/src/project-graph/plugins/loader.js +13 -5
- package/src/project-graph/plugins/public-api.d.ts +11 -1
- package/src/project-graph/plugins/utils.d.ts +2 -2
- package/src/project-graph/plugins/utils.js +15 -16
- package/src/project-graph/project-graph.js +6 -6
- package/src/project-graph/utils/find-project-for-path.js +2 -3
- package/src/project-graph/utils/normalize-project-nodes.d.ts +1 -1
- package/src/project-graph/utils/normalize-project-nodes.js +8 -8
- package/src/project-graph/utils/project-configuration-utils.d.ts +21 -5
- package/src/project-graph/utils/project-configuration-utils.js +23 -14
- package/src/utils/perf-logging.js +3 -1
- package/src/core/graph/3rdpartylicenses.txt +0 -785
@@ -114,6 +114,17 @@ function createWorkerHandler(worker, pending, onload, onloadError) {
|
|
114
114
|
});
|
115
115
|
}
|
116
116
|
: undefined,
|
117
|
+
createMetadata: result.hasCreateMetadata
|
118
|
+
? (graph, ctx) => {
|
119
|
+
const tx = pluginName + ':createMetadata:' + performance.now();
|
120
|
+
return registerPendingPromise(tx, pending, () => {
|
121
|
+
worker.send({
|
122
|
+
type: 'createMetadata',
|
123
|
+
payload: { graph, context: ctx, tx },
|
124
|
+
});
|
125
|
+
});
|
126
|
+
}
|
127
|
+
: undefined,
|
117
128
|
});
|
118
129
|
}
|
119
130
|
else if (result.success === false) {
|
@@ -147,6 +158,15 @@ function createWorkerHandler(worker, pending, onload, onloadError) {
|
|
147
158
|
rejector(result.error);
|
148
159
|
}
|
149
160
|
},
|
161
|
+
createMetadataResult: ({ tx, ...result }) => {
|
162
|
+
const { resolver, rejector } = pending.get(tx);
|
163
|
+
if (result.success) {
|
164
|
+
resolver(result.metadata);
|
165
|
+
}
|
166
|
+
else if (result.success === false) {
|
167
|
+
rejector(result.error);
|
168
|
+
}
|
169
|
+
},
|
150
170
|
});
|
151
171
|
};
|
152
172
|
}
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const messaging_1 = require("./messaging");
|
4
4
|
const loader_1 = require("../loader");
|
5
5
|
const serializable_error_1 = require("../../../utils/serializable-error");
|
6
|
+
if (process.env.NX_PERF_LOGGING === 'true') {
|
7
|
+
require('../../../utils/perf-logging');
|
8
|
+
}
|
6
9
|
global.NX_GRAPH_CREATION = true;
|
7
10
|
let plugin;
|
8
11
|
process.on('message', async (message) => {
|
@@ -22,6 +25,7 @@ process.on('message', async (message) => {
|
|
22
25
|
createNodesPattern: plugin.createNodes?.[0],
|
23
26
|
hasCreateDependencies: 'createDependencies' in plugin && !!plugin.createDependencies,
|
24
27
|
hasProcessProjectGraph: 'processProjectGraph' in plugin && !!plugin.processProjectGraph,
|
28
|
+
hasCreateMetadata: 'createMetadata' in plugin && !!plugin.createMetadata,
|
25
29
|
success: true,
|
26
30
|
},
|
27
31
|
};
|
@@ -93,5 +97,20 @@ process.on('message', async (message) => {
|
|
93
97
|
};
|
94
98
|
}
|
95
99
|
},
|
100
|
+
createMetadata: async ({ graph, context, tx }) => {
|
101
|
+
try {
|
102
|
+
const result = await plugin.createMetadata(graph, context);
|
103
|
+
return {
|
104
|
+
type: 'createMetadataResult',
|
105
|
+
payload: { metadata: result, success: true, tx },
|
106
|
+
};
|
107
|
+
}
|
108
|
+
catch (e) {
|
109
|
+
return {
|
110
|
+
type: 'createMetadataResult',
|
111
|
+
payload: { success: false, error: e.stack, tx },
|
112
|
+
};
|
113
|
+
}
|
114
|
+
},
|
96
115
|
});
|
97
116
|
});
|
@@ -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
|
81
|
-
if (!
|
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 =
|
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.
|
@@ -68,6 +68,12 @@ export interface CreateDependenciesContext {
|
|
68
68
|
* Use {@link validateDependency} to validate dependencies
|
69
69
|
*/
|
70
70
|
export type CreateDependencies<T = unknown> = (options: T | undefined, context: CreateDependenciesContext) => RawProjectGraphDependency[] | Promise<RawProjectGraphDependency[]>;
|
71
|
+
export type CreateMetadataContext = {
|
72
|
+
readonly nxJsonConfiguration: NxJsonConfiguration;
|
73
|
+
readonly workspaceRoot: string;
|
74
|
+
};
|
75
|
+
export type ProjectsMetadata = Record<string, Pick<ProjectConfiguration, 'metadata'>>;
|
76
|
+
export type CreateMetadata<T = unknown> = (graph: ProjectGraph, options: T | undefined, context: CreateMetadataContext) => ProjectsMetadata | Promise<ProjectsMetadata>;
|
71
77
|
/**
|
72
78
|
* A plugin for Nx which creates nodes and dependencies for the {@link ProjectGraph}
|
73
79
|
*/
|
@@ -82,6 +88,10 @@ export type NxPluginV2<TOptions = unknown> = {
|
|
82
88
|
* Provides a function to analyze files to create dependencies for the {@link ProjectGraph}
|
83
89
|
*/
|
84
90
|
createDependencies?: CreateDependencies<TOptions>;
|
91
|
+
/**
|
92
|
+
* Provides a function to create metadata for the {@link ProjectGraph}
|
93
|
+
*/
|
94
|
+
createMetadata?: CreateMetadata<TOptions>;
|
85
95
|
};
|
86
96
|
/**
|
87
97
|
* A plugin for Nx
|
@@ -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
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
|
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
|
-
|
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`);
|
@@ -10,8 +10,8 @@ const output_1 = require("../utils/output");
|
|
10
10
|
const strip_indents_1 = require("../utils/strip-indents");
|
11
11
|
const workspace_root_1 = require("../utils/workspace-root");
|
12
12
|
const build_project_graph_1 = require("./build-project-graph");
|
13
|
-
const nx_deps_cache_1 = require("./nx-deps-cache");
|
14
13
|
const error_types_1 = require("./error-types");
|
14
|
+
const nx_deps_cache_1 = require("./nx-deps-cache");
|
15
15
|
const internal_api_1 = require("./plugins/internal-api");
|
16
16
|
const retrieve_workspace_files_1 = require("./utils/retrieve-workspace-files");
|
17
17
|
/**
|
@@ -92,18 +92,18 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
|
92
92
|
perf_hooks_1.performance.mark('retrieve-workspace-files:end');
|
93
93
|
const cacheEnabled = process.env.NX_CACHE_PROJECT_GRAPH !== 'false';
|
94
94
|
perf_hooks_1.performance.mark('build-project-graph-using-project-file-map:start');
|
95
|
-
let
|
95
|
+
let projectGraphError;
|
96
96
|
let projectGraphResult;
|
97
97
|
try {
|
98
|
-
projectGraphResult = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, cacheEnabled ? (0, nx_deps_cache_1.readFileMapCache)() : null, plugins);
|
98
|
+
projectGraphResult = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, allWorkspaceFiles, rustReferences, cacheEnabled ? (0, nx_deps_cache_1.readFileMapCache)() : null, plugins, sourceMaps);
|
99
99
|
}
|
100
100
|
catch (e) {
|
101
|
-
if (
|
101
|
+
if ((0, error_types_1.isAggregateProjectGraphError)(e)) {
|
102
102
|
projectGraphResult = {
|
103
103
|
projectGraph: e.partialProjectGraph,
|
104
104
|
projectFileMapCache: null,
|
105
105
|
};
|
106
|
-
|
106
|
+
projectGraphError = e;
|
107
107
|
}
|
108
108
|
else {
|
109
109
|
throw e;
|
@@ -117,7 +117,7 @@ async function buildProjectGraphAndSourceMapsWithoutDaemon() {
|
|
117
117
|
delete global.NX_GRAPH_CREATION;
|
118
118
|
const errors = [
|
119
119
|
...(projectConfigurationsError?.errors ?? []),
|
120
|
-
...(
|
120
|
+
...(projectGraphError?.errors ?? []),
|
121
121
|
];
|
122
122
|
if (errors.length > 0) {
|
123
123
|
throw new error_types_1.ProjectGraphError(errors, projectGraph, sourceMaps);
|
@@ -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
|
13
|
-
|
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(
|
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(
|
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
|
10
|
+
const sortedProjectNames = Object.keys(projects).sort();
|
12
11
|
// Used for expanding implicit dependencies (e.g. `@proj/*` or `tag:foo`)
|
13
|
-
const partialProjectGraphNodes =
|
14
|
-
const projectConfiguration =
|
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
|
-
|
25
|
-
|
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 =
|
34
|
+
const tags = p.tags || [];
|
35
35
|
toAdd.push({
|
36
36
|
name: key,
|
37
37
|
type: projectType,
|
@@ -1,20 +1,36 @@
|
|
1
1
|
import { NxJsonConfiguration, TargetDefaults } from '../../config/nx-json';
|
2
2
|
import { ProjectGraphExternalNode } from '../../config/project-graph';
|
3
|
-
import { ProjectConfiguration, TargetConfiguration } from '../../config/workspace-json-project-json';
|
3
|
+
import { ProjectConfiguration, ProjectMetadata, TargetConfiguration, TargetMetadata } from '../../config/workspace-json-project-json';
|
4
4
|
import { ONLY_MODIFIES_EXISTING_TARGET } from '../../plugins/target-defaults/symbols';
|
5
5
|
import { LoadedNxPlugin } from '../plugins/internal-api';
|
6
|
-
export type SourceInformation = [file: string, plugin: string];
|
6
|
+
export type SourceInformation = [file: string | null, plugin: string];
|
7
7
|
export type ConfigurationSourceMaps = Record<string, Record<string, SourceInformation>>;
|
8
|
-
export declare function mergeProjectConfigurationIntoRootMap(projectRootMap:
|
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
|
+
export declare function mergeMetadata<T = ProjectMetadata | TargetMetadata>(sourceMap: Record<string, [file: string, plugin: string]>, sourceInformation: [file: string, plugin: string], baseSourceMapPath: string, metadata: T, matchingMetadata?: T): T;
|
13
14
|
export type ConfigurationResult = {
|
14
|
-
|
15
|
+
/**
|
16
|
+
* A map of project configurations, keyed by project root.
|
17
|
+
*/
|
18
|
+
projects: {
|
19
|
+
[projectRoot: string]: ProjectConfiguration;
|
20
|
+
};
|
21
|
+
/**
|
22
|
+
* Node Name -> Node info
|
23
|
+
*/
|
15
24
|
externalNodes: Record<string, ProjectGraphExternalNode>;
|
25
|
+
/**
|
26
|
+
* Project Root -> Project Name
|
27
|
+
*/
|
16
28
|
projectRootMap: Record<string, string>;
|
17
29
|
sourceMaps: ConfigurationSourceMaps;
|
30
|
+
/**
|
31
|
+
* The list of files that were used to create project configurations
|
32
|
+
*/
|
33
|
+
matchingProjectFiles: string[];
|
18
34
|
};
|
19
35
|
/**
|
20
36
|
* Transforms a list of project paths into a map of project configurations.
|
@@ -26,7 +42,7 @@ export type ConfigurationResult = {
|
|
26
42
|
*/
|
27
43
|
export declare function createProjectConfigurations(root: string, nxJson: NxJsonConfiguration, projectFiles: string[], // making this parameter allows devkit to pick up newly created projects
|
28
44
|
plugins: LoadedNxPlugin[]): Promise<ConfigurationResult>;
|
29
|
-
export declare function readProjectConfigurationsFromRootMap(projectRootMap:
|
45
|
+
export declare function readProjectConfigurationsFromRootMap(projectRootMap: Record<string, ProjectConfiguration>): Record<string, ProjectConfiguration>;
|
30
46
|
/**
|
31
47
|
* Merges two targets.
|
32
48
|
*
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.readProjectConfigurationsFromRootMap = exports.createProjectConfigurations = exports.mergeProjectConfigurationIntoRootMap = void 0;
|
3
|
+
exports.readTargetDefaultsForTarget = exports.resolveNxTokensInOptions = exports.isCompatibleTarget = exports.mergeTargetConfigurations = exports.readProjectConfigurationsFromRootMap = exports.createProjectConfigurations = exports.mergeMetadata = 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");
|
@@ -17,12 +17,12 @@ skipCommandNormalization) {
|
|
17
17
|
configurationSourceMaps[project.root] = {};
|
18
18
|
}
|
19
19
|
const sourceMap = configurationSourceMaps?.[project.root];
|
20
|
-
let matchingProject = projectRootMap
|
20
|
+
let matchingProject = projectRootMap[project.root];
|
21
21
|
if (!matchingProject) {
|
22
|
-
projectRootMap
|
22
|
+
projectRootMap[project.root] = {
|
23
23
|
root: project.root,
|
24
|
-
}
|
25
|
-
matchingProject = projectRootMap
|
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
|
141
|
+
projectRootMap[updatedProjectConfiguration.root] =
|
142
|
+
updatedProjectConfiguration;
|
142
143
|
}
|
143
144
|
exports.mergeProjectConfigurationIntoRootMap = mergeProjectConfigurationIntoRootMap;
|
144
145
|
function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata, matchingMetadata) {
|
@@ -210,6 +211,7 @@ function mergeMetadata(sourceMap, sourceInformation, baseSourceMapPath, metadata
|
|
210
211
|
}
|
211
212
|
return result;
|
212
213
|
}
|
214
|
+
exports.mergeMetadata = mergeMetadata;
|
213
215
|
/**
|
214
216
|
* Transforms a list of project paths into a map of project configurations.
|
215
217
|
*
|
@@ -264,7 +266,7 @@ plugins) {
|
|
264
266
|
}
|
265
267
|
return Promise.all(results).then((results) => {
|
266
268
|
perf_hooks_1.performance.mark('createNodes:merge - start');
|
267
|
-
const projectRootMap =
|
269
|
+
const projectRootMap = {};
|
268
270
|
const externalNodes = {};
|
269
271
|
const configurationSourceMaps = {};
|
270
272
|
for (const result of results.flat()) {
|
@@ -291,14 +293,17 @@ plugins) {
|
|
291
293
|
}
|
292
294
|
Object.assign(externalNodes, pluginExternalNodes);
|
293
295
|
}
|
294
|
-
let projects;
|
295
296
|
try {
|
296
|
-
|
297
|
+
// We still call this just to assert that the root map
|
298
|
+
// only contains valid project names. This is a safety check.
|
299
|
+
//
|
300
|
+
// The signature itself can't be changed as we need it to return
|
301
|
+
// project configurations for use in devkit.
|
302
|
+
readProjectConfigurationsFromRootMap(projectRootMap);
|
297
303
|
}
|
298
304
|
catch (e) {
|
299
305
|
if ((0, error_types_1.isProjectsWithNoNameError)(e) ||
|
300
306
|
(0, error_types_1.isProjectsWithConflictingNamesError)(e)) {
|
301
|
-
projects = e.projects;
|
302
307
|
errors.push(e);
|
303
308
|
}
|
304
309
|
else {
|
@@ -312,18 +317,20 @@ plugins) {
|
|
312
317
|
perf_hooks_1.performance.measure('build-project-configs', 'build-project-configs:start', 'build-project-configs:end');
|
313
318
|
if (errors.length === 0) {
|
314
319
|
return {
|
315
|
-
projects,
|
320
|
+
projects: projectRootMap,
|
316
321
|
externalNodes,
|
317
322
|
projectRootMap: rootMap,
|
318
323
|
sourceMaps: configurationSourceMaps,
|
324
|
+
matchingProjectFiles: projectFiles,
|
319
325
|
};
|
320
326
|
}
|
321
327
|
else {
|
322
328
|
throw new error_types_1.ProjectConfigurationsError(errors, {
|
323
|
-
projects,
|
329
|
+
projects: projectRootMap,
|
324
330
|
externalNodes,
|
325
331
|
projectRootMap: rootMap,
|
326
332
|
sourceMaps: configurationSourceMaps,
|
333
|
+
matchingProjectFiles: projectFiles,
|
327
334
|
});
|
328
335
|
}
|
329
336
|
});
|
@@ -336,7 +343,8 @@ function readProjectConfigurationsFromRootMap(projectRootMap) {
|
|
336
343
|
// to provide better error messaging.
|
337
344
|
const conflicts = new Map();
|
338
345
|
const projectRootsWithNoName = [];
|
339
|
-
for (const
|
346
|
+
for (const root in projectRootMap) {
|
347
|
+
const configuration = projectRootMap[root];
|
340
348
|
// We're setting `// targets` as a comment `targets` is empty due to Project Crystal.
|
341
349
|
// Strip it before returning configuration for usage.
|
342
350
|
if (configuration['// targets'])
|
@@ -544,7 +552,8 @@ function readTargetDefaultsForTarget(targetName, targetDefaults, executor) {
|
|
544
552
|
exports.readTargetDefaultsForTarget = readTargetDefaultsForTarget;
|
545
553
|
function createRootMap(projectRootMap) {
|
546
554
|
const map = {};
|
547
|
-
for (const
|
555
|
+
for (const projectRoot in projectRootMap) {
|
556
|
+
const projectName = projectRootMap[projectRoot].name;
|
548
557
|
map[projectRoot] = projectName;
|
549
558
|
}
|
550
559
|
return map;
|
@@ -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
|
-
|
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);
|