nx 20.2.0-canary.20241203-6b87005 → 20.2.0-canary.20241205-15060e3
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/bin/post-install.js +5 -3
- package/package.json +11 -11
- package/plugins/package-json.d.ts +5 -1
- package/plugins/package-json.js +26 -2
- package/src/command-line/affected/affected.js +3 -1
- package/src/command-line/format/format.js +4 -2
- package/src/command-line/release/utils/github.d.ts +1 -0
- package/src/command-line/release/utils/github.js +2 -0
- package/src/command-line/show/project.js +4 -0
- package/src/command-line/show/projects.js +4 -0
- package/src/command-line/sync/sync.js +3 -3
- package/src/core/graph/main.js +1 -1
- package/src/core/graph/styles.js +1 -1
- package/src/daemon/server/project-graph-incremental-recomputation.js +4 -4
- package/src/daemon/server/shutdown-utils.js +2 -2
- package/src/executors/utils/convert-nx-executor.js +2 -3
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/plugins/package-json/create-nodes.d.ts +3 -4
- package/src/plugins/package-json/create-nodes.js +19 -2
- package/src/project-graph/affected/affected-project-graph.js +3 -0
- package/src/project-graph/affected/locators/project-glob-changes.js +16 -4
- package/src/project-graph/build-project-graph.d.ts +1 -0
- package/src/project-graph/build-project-graph.js +12 -3
- package/src/project-graph/error-types.d.ts +1 -1
- package/src/project-graph/plugins/get-plugins.d.ts +4 -0
- package/src/project-graph/plugins/get-plugins.js +56 -0
- package/src/project-graph/plugins/index.js +1 -0
- package/src/project-graph/plugins/internal-api.d.ts +4 -0
- package/src/project-graph/plugins/internal-api.js +14 -7
- package/src/project-graph/plugins/isolation/index.js +1 -7
- package/src/project-graph/plugins/isolation/messaging.d.ts +3 -0
- package/src/project-graph/plugins/isolation/plugin-pool.js +5 -1
- package/src/project-graph/plugins/isolation/plugin-worker.js +9 -4
- package/src/project-graph/plugins/load-resolved-plugin.d.ts +3 -0
- package/src/project-graph/plugins/load-resolved-plugin.js +19 -0
- package/src/project-graph/plugins/loader.d.ts +7 -1
- package/src/project-graph/plugins/loader.js +22 -34
- package/src/project-graph/project-graph.js +19 -11
- package/src/project-graph/utils/retrieve-workspace-files.d.ts +2 -6
- package/src/project-graph/utils/retrieve-workspace-files.js +3 -5
- package/src/tasks-runner/run-command.js +2 -2
- package/src/utils/sync-generators.js +9 -14
- package/src/daemon/server/plugins.d.ts +0 -3
- package/src/daemon/server/plugins.js +0 -32
package/src/core/graph/styles.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[532],{
|
1
|
+
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[532],{24258:()=>{}},s=>{var e;e=24258,s(s.s=e)}]);
|
@@ -16,8 +16,8 @@ const workspace_context_1 = require("../../utils/workspace-context");
|
|
16
16
|
const workspace_root_1 = require("../../utils/workspace-root");
|
17
17
|
const file_watcher_sockets_1 = require("./file-watching/file-watcher-sockets");
|
18
18
|
const logger_1 = require("./logger");
|
19
|
-
const plugins_1 = require("./plugins");
|
20
19
|
const error_types_1 = require("../../project-graph/error-types");
|
20
|
+
const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
|
21
21
|
let cachedSerializedProjectGraphPromise;
|
22
22
|
const collectedUpdatedFiles = new Set();
|
23
23
|
const collectedDeletedFiles = new Set();
|
@@ -38,7 +38,7 @@ async function getCachedSerializedProjectGraphPromise() {
|
|
38
38
|
// reset the wait time
|
39
39
|
waitPeriod = 100;
|
40
40
|
await resetInternalStateIfNxDepsMissing();
|
41
|
-
const plugins = await (0,
|
41
|
+
const plugins = await (0, get_plugins_1.getPlugins)();
|
42
42
|
if (collectedUpdatedFiles.size == 0 && collectedDeletedFiles.size == 0) {
|
43
43
|
if (!cachedSerializedProjectGraphPromise) {
|
44
44
|
cachedSerializedProjectGraphPromise =
|
@@ -90,7 +90,7 @@ function addUpdatedAndDeletedFiles(createdFiles, updatedFiles, deletedFiles) {
|
|
90
90
|
waitPeriod = waitPeriod * 2;
|
91
91
|
}
|
92
92
|
cachedSerializedProjectGraphPromise =
|
93
|
-
processFilesAndCreateAndSerializeProjectGraph(await (0,
|
93
|
+
processFilesAndCreateAndSerializeProjectGraph(await (0, get_plugins_1.getPlugins)());
|
94
94
|
const { projectGraph } = await cachedSerializedProjectGraphPromise;
|
95
95
|
if (createdFiles.length > 0) {
|
96
96
|
(0, file_watcher_sockets_1.notifyFileWatcherSockets)(createdFiles, null, null);
|
@@ -238,7 +238,7 @@ async function createAndSerializeProjectGraph({ projects, sourceMaps, }) {
|
|
238
238
|
const fileMap = copyFileMap(exports.fileMapWithFiles.fileMap);
|
239
239
|
const allWorkspaceFiles = copyFileData(exports.fileMapWithFiles.allWorkspaceFiles);
|
240
240
|
const rustReferences = exports.fileMapWithFiles.rustReferences;
|
241
|
-
const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, knownExternalNodes, fileMap, allWorkspaceFiles, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)(), await (0,
|
241
|
+
const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, knownExternalNodes, fileMap, allWorkspaceFiles, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)(), await (0, get_plugins_1.getPlugins)(), sourceMaps);
|
242
242
|
exports.currentProjectFileMapCache = projectFileMapCache;
|
243
243
|
exports.currentProjectGraph = projectGraph;
|
244
244
|
perf_hooks_1.performance.mark('create-project-graph-end');
|
@@ -13,9 +13,9 @@ const workspace_root_1 = require("../../utils/workspace-root");
|
|
13
13
|
const logger_1 = require("./logger");
|
14
14
|
const socket_utils_1 = require("../socket-utils");
|
15
15
|
const cache_1 = require("../cache");
|
16
|
-
const plugins_1 = require("./plugins");
|
17
16
|
const error_types_1 = require("../../project-graph/error-types");
|
18
17
|
const db_connection_1 = require("../../utils/db-connection");
|
18
|
+
const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
|
19
19
|
exports.SERVER_INACTIVITY_TIMEOUT_MS = 10800000; // 10800000 ms = 3 hours
|
20
20
|
let watcherInstance;
|
21
21
|
function storeWatcherInstance(instance) {
|
@@ -50,7 +50,7 @@ async function handleServerProcessTermination({ server, reason, sockets, }) {
|
|
50
50
|
logger_1.serverLogger.watcherLog(`Stopping the watcher for ${workspace_root_1.workspaceRoot} (outputs)`);
|
51
51
|
}
|
52
52
|
(0, cache_1.deleteDaemonJsonProcessCache)();
|
53
|
-
(0,
|
53
|
+
(0, get_plugins_1.cleanupPlugins)();
|
54
54
|
(0, db_connection_1.removeDbConnections)();
|
55
55
|
logger_1.serverLogger.log(`Server stopped because: "${reason}"`);
|
56
56
|
}
|
@@ -7,7 +7,7 @@ exports.convertNxExecutor = convertNxExecutor;
|
|
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
9
|
const project_configuration_utils_1 = require("../../project-graph/utils/project-configuration-utils");
|
10
|
-
const
|
10
|
+
const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
|
11
11
|
/**
|
12
12
|
* Convert an Nx Executor into an Angular Devkit Builder
|
13
13
|
*
|
@@ -17,12 +17,11 @@ function convertNxExecutor(executor) {
|
|
17
17
|
const builderFunction = (options, builderContext) => {
|
18
18
|
const promise = async () => {
|
19
19
|
const nxJsonConfiguration = (0, nx_json_1.readNxJson)(builderContext.workspaceRoot);
|
20
|
-
const
|
20
|
+
const plugins = await (0, get_plugins_1.getPlugins)();
|
21
21
|
const projectsConfigurations = {
|
22
22
|
version: 2,
|
23
23
|
projects: (0, project_configuration_utils_1.readProjectConfigurationsFromRootMap)((await (0, retrieve_workspace_files_1.retrieveProjectConfigurations)(plugins, builderContext.workspaceRoot, nxJsonConfiguration)).projects),
|
24
24
|
};
|
25
|
-
cleanup();
|
26
25
|
const context = {
|
27
26
|
root: builderContext.workspaceRoot,
|
28
27
|
projectName: builderContext.target.project,
|
Binary file
|
@@ -2,13 +2,12 @@ import { NxJsonConfiguration } from '../../config/nx-json';
|
|
2
2
|
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
3
3
|
import { PackageJson } from '../../utils/package-json';
|
4
4
|
import { CreateNodesV2 } from '../../project-graph/plugins';
|
5
|
+
import { PackageJsonConfigurationCache } from '../../../plugins/package-json';
|
5
6
|
export declare const createNodesV2: CreateNodesV2;
|
6
7
|
export declare function buildPackageJsonWorkspacesMatcher(workspaceRoot: string, readJson: (string: any) => any): (p: string) => boolean;
|
7
|
-
export declare function createNodeFromPackageJson(pkgJsonPath: string, workspaceRoot: string): {
|
8
|
+
export declare function createNodeFromPackageJson(pkgJsonPath: string, workspaceRoot: string, cache: PackageJsonConfigurationCache): {
|
8
9
|
projects: {
|
9
|
-
[x: string]: ProjectConfiguration
|
10
|
-
name: string;
|
11
|
-
};
|
10
|
+
[x: string]: ProjectConfiguration;
|
12
11
|
};
|
13
12
|
};
|
14
13
|
export declare function buildProjectConfigurationFromPackageJson(packageJson: PackageJson, workspaceRoot: string, packageJsonPath: string, nxJson: NxJsonConfiguration): ProjectConfiguration & {
|
@@ -18,6 +18,8 @@ const package_json_1 = require("../../utils/package-json");
|
|
18
18
|
const path_1 = require("../../utils/path");
|
19
19
|
const plugins_1 = require("../../project-graph/plugins");
|
20
20
|
const path_2 = require("path");
|
21
|
+
const file_hasher_1 = require("../../hasher/file-hasher");
|
22
|
+
const package_json_2 = require("../../../plugins/package-json");
|
21
23
|
exports.createNodesV2 = [
|
22
24
|
(0, globs_1.combineGlobPatterns)('package.json', '**/package.json', 'project.json', '**/project.json'),
|
23
25
|
(configFiles, _, context) => {
|
@@ -27,13 +29,14 @@ exports.createNodesV2 = [
|
|
27
29
|
const isNextToProjectJson = (packageJsonPath) => {
|
28
30
|
return projectJsonRoots.has((0, node_path_1.dirname)(packageJsonPath));
|
29
31
|
};
|
32
|
+
const cache = (0, package_json_2.readPackageJsonConfigurationCache)();
|
30
33
|
return (0, plugins_1.createNodesFromFiles)((packageJsonPath, options, context) => {
|
31
34
|
if (!isInPackageJsonWorkspaces(packageJsonPath) &&
|
32
35
|
!isNextToProjectJson(packageJsonPath)) {
|
33
36
|
// Skip if package.json is not part of the package.json workspaces and not next to a project.json.
|
34
37
|
return null;
|
35
38
|
}
|
36
|
-
return createNodeFromPackageJson(packageJsonPath, context.workspaceRoot);
|
39
|
+
return createNodeFromPackageJson(packageJsonPath, context.workspaceRoot, cache);
|
37
40
|
}, packageJsons, _, context);
|
38
41
|
},
|
39
42
|
];
|
@@ -75,9 +78,23 @@ function buildPackageJsonWorkspacesMatcher(workspaceRoot, readJson) {
|
|
75
78
|
*/
|
76
79
|
negativePatterns.every((negative) => (0, minimatch_1.minimatch)(p, negative));
|
77
80
|
}
|
78
|
-
function createNodeFromPackageJson(pkgJsonPath, workspaceRoot) {
|
81
|
+
function createNodeFromPackageJson(pkgJsonPath, workspaceRoot, cache) {
|
79
82
|
const json = (0, fileutils_1.readJsonFile)((0, node_path_1.join)(workspaceRoot, pkgJsonPath));
|
83
|
+
const projectRoot = (0, node_path_1.dirname)(pkgJsonPath);
|
84
|
+
const hash = (0, file_hasher_1.hashObject)({
|
85
|
+
...json,
|
86
|
+
root: projectRoot,
|
87
|
+
});
|
88
|
+
const cached = cache[hash];
|
89
|
+
if (cached) {
|
90
|
+
return {
|
91
|
+
projects: {
|
92
|
+
[cached.root]: cached,
|
93
|
+
},
|
94
|
+
};
|
95
|
+
}
|
80
96
|
const project = buildProjectConfigurationFromPackageJson(json, workspaceRoot, pkgJsonPath, (0, nx_json_1.readNxJson)(workspaceRoot));
|
97
|
+
cache[hash] = project;
|
81
98
|
return {
|
82
99
|
projects: {
|
83
100
|
[project.root]: project,
|
@@ -17,7 +17,10 @@ async function filterAffected(graph, touchedFiles, nxJson = (0, configuration_1.
|
|
17
17
|
];
|
18
18
|
const touchedProjects = [];
|
19
19
|
for (const locator of touchedProjectLocators) {
|
20
|
+
performance.mark(locator.name + ':start');
|
20
21
|
const projects = await locator(touchedFiles, graph.nodes, nxJson, packageJson, graph);
|
22
|
+
performance.mark(locator.name + ':end');
|
23
|
+
performance.measure(locator.name, locator.name + ':start', locator.name + ':end');
|
21
24
|
touchedProjects.push(...projects);
|
22
25
|
}
|
23
26
|
return filterAffectedProjects(graph, {
|
@@ -6,11 +6,23 @@ const workspace_root_1 = require("../../../utils/workspace-root");
|
|
6
6
|
const path_1 = require("path");
|
7
7
|
const fs_1 = require("fs");
|
8
8
|
const retrieve_workspace_files_1 = require("../../utils/retrieve-workspace-files");
|
9
|
-
const internal_api_1 = require("../../plugins/internal-api");
|
10
9
|
const globs_1 = require("../../../utils/globs");
|
11
|
-
const
|
12
|
-
|
13
|
-
const globPattern =
|
10
|
+
const get_plugins_1 = require("../../plugins/get-plugins");
|
11
|
+
const getTouchedProjectsFromProjectGlobChanges = async (touchedFiles, projectGraphNodes) => {
|
12
|
+
const globPattern = await (async () => {
|
13
|
+
// TODO: We need a quicker way to get patterns that should not
|
14
|
+
// require starting up plugin workers
|
15
|
+
if (process.env.NX_FORCE_REUSE_CACHED_GRAPH === 'true') {
|
16
|
+
return (0, globs_1.combineGlobPatterns)([
|
17
|
+
'**/package.json',
|
18
|
+
'**/project.json',
|
19
|
+
'project.json',
|
20
|
+
'package.json',
|
21
|
+
]);
|
22
|
+
}
|
23
|
+
const plugins = await (0, get_plugins_1.getPlugins)();
|
24
|
+
return (0, globs_1.combineGlobPatterns)((0, retrieve_workspace_files_1.configurationGlobs)(plugins));
|
25
|
+
})();
|
14
26
|
const touchedProjects = new Set();
|
15
27
|
for (const touchedFile of touchedFiles) {
|
16
28
|
const isProjectFile = (0, minimatch_1.minimatch)(touchedFile.file, globPattern, {
|
@@ -12,6 +12,7 @@ export declare function getFileMap(): {
|
|
12
12
|
allWorkspaceFiles: FileData[];
|
13
13
|
rustReferences: NxWorkspaceFilesExternals | null;
|
14
14
|
};
|
15
|
+
export declare function hydrateFileMap(fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals): void;
|
15
16
|
export declare function buildProjectGraphUsingProjectFileMap(projectRootMap: Record<string, ProjectConfiguration>, externalNodes: Record<string, ProjectGraphExternalNode>, fileMap: FileMap, allWorkspaceFiles: FileData[], rustReferences: NxWorkspaceFilesExternals, fileMapCache: FileMapCache | null, plugins: LoadedNxPlugin[], sourceMap: ConfigurationSourceMaps): Promise<{
|
16
17
|
projectGraph: ProjectGraph;
|
17
18
|
projectFileMapCache: FileMapCache;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.getFileMap = getFileMap;
|
4
|
+
exports.hydrateFileMap = hydrateFileMap;
|
4
5
|
exports.buildProjectGraphUsingProjectFileMap = buildProjectGraphUsingProjectFileMap;
|
5
6
|
exports.applyProjectMetadata = applyProjectMetadata;
|
6
7
|
const workspace_root_1 = require("../utils/workspace-root");
|
@@ -39,6 +40,11 @@ function getFileMap() {
|
|
39
40
|
};
|
40
41
|
}
|
41
42
|
}
|
43
|
+
function hydrateFileMap(fileMap, allWorkspaceFiles, rustReferences) {
|
44
|
+
storedFileMap = fileMap;
|
45
|
+
storedAllWorkspaceFiles = allWorkspaceFiles;
|
46
|
+
storedRustReferences = rustReferences;
|
47
|
+
}
|
42
48
|
async function buildProjectGraphUsingProjectFileMap(projectRootMap, externalNodes, fileMap, allWorkspaceFiles, rustReferences, fileMapCache, plugins, sourceMap) {
|
43
49
|
storedFileMap = fileMap;
|
44
50
|
storedAllWorkspaceFiles = allWorkspaceFiles;
|
@@ -119,7 +125,6 @@ function readCombinedDeps() {
|
|
119
125
|
};
|
120
126
|
}
|
121
127
|
async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFileData, projectGraphVersion, plugins, sourceMap) {
|
122
|
-
perf_hooks_1.performance.mark('build project graph:start');
|
123
128
|
const builder = new project_graph_builder_1.ProjectGraphBuilder(null, ctx.fileMap.projectFileMap);
|
124
129
|
builder.setVersion(projectGraphVersion);
|
125
130
|
for (const node in knownExternalNodes) {
|
@@ -158,8 +163,6 @@ async function buildProjectGraphUsingContext(knownExternalNodes, ctx, cachedFile
|
|
158
163
|
}
|
159
164
|
(0, implicit_project_dependencies_1.applyImplicitDependencies)(ctx.projects, updatedBuilder);
|
160
165
|
const finalGraph = updatedBuilder.getUpdatedProjectGraph();
|
161
|
-
perf_hooks_1.performance.mark('build project graph:end');
|
162
|
-
perf_hooks_1.performance.measure('build project graph', 'build project graph:start', 'build project graph:end');
|
163
166
|
if (!error) {
|
164
167
|
return finalGraph;
|
165
168
|
}
|
@@ -182,6 +185,7 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins,
|
|
182
185
|
const errors = [];
|
183
186
|
const builder = new project_graph_builder_1.ProjectGraphBuilder(graph, context.fileMap.projectFileMap, context.fileMap.nonProjectFiles);
|
184
187
|
const createDependencyPlugins = plugins.filter((plugin) => plugin.createDependencies);
|
188
|
+
perf_hooks_1.performance.mark('createDependencies:start');
|
185
189
|
await Promise.all(createDependencyPlugins.map(async (plugin) => {
|
186
190
|
perf_hooks_1.performance.mark(`${plugin.name}:createDependencies - start`);
|
187
191
|
try {
|
@@ -200,6 +204,8 @@ async function updateProjectGraphWithPlugins(context, initProjectGraph, plugins,
|
|
200
204
|
perf_hooks_1.performance.mark(`${plugin.name}:createDependencies - end`);
|
201
205
|
perf_hooks_1.performance.measure(`${plugin.name}:createDependencies`, `${plugin.name}:createDependencies - start`, `${plugin.name}:createDependencies - end`);
|
202
206
|
}));
|
207
|
+
perf_hooks_1.performance.mark('createDependencies:end');
|
208
|
+
perf_hooks_1.performance.measure(`createDependencies`, `createDependencies:start`, `createDependencies:end`);
|
203
209
|
const graphWithDeps = builder.getUpdatedProjectGraph();
|
204
210
|
const { errors: metadataErrors, graph: updatedGraph } = await applyProjectMetadata(graphWithDeps, plugins, {
|
205
211
|
nxJsonConfiguration: context.nxJsonConfiguration,
|
@@ -225,6 +231,7 @@ function readRootTsConfig() {
|
|
225
231
|
async function applyProjectMetadata(graph, plugins, context, sourceMap) {
|
226
232
|
const results = [];
|
227
233
|
const errors = [];
|
234
|
+
perf_hooks_1.performance.mark('createMetadata:start');
|
228
235
|
const promises = plugins.map(async (plugin) => {
|
229
236
|
if (plugin.createMetadata) {
|
230
237
|
perf_hooks_1.performance.mark(`${plugin.name}:createMetadata - start`);
|
@@ -250,5 +257,7 @@ async function applyProjectMetadata(graph, plugins, context, sourceMap) {
|
|
250
257
|
}
|
251
258
|
}
|
252
259
|
}
|
260
|
+
perf_hooks_1.performance.mark('createMetadata:end');
|
261
|
+
perf_hooks_1.performance.measure(`createMetadata`, `createMetadata:start`, `createMetadata:end`);
|
253
262
|
return { errors, graph };
|
254
263
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ConfigurationResult, ConfigurationSourceMaps } from './utils/project-configuration-utils';
|
2
2
|
import { ProjectConfiguration } from '../config/workspace-json-project-json';
|
3
3
|
import { ProjectGraph } from '../config/project-graph';
|
4
|
-
import { CreateNodesFunctionV2 } from './plugins';
|
4
|
+
import { CreateNodesFunctionV2 } from './plugins/public-api';
|
5
5
|
export declare class ProjectGraphError extends Error {
|
6
6
|
#private;
|
7
7
|
constructor(errors: Array<AggregateCreateNodesError | MergeNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | ProcessDependenciesError | CreateMetadataError | WorkspaceValidityError>, partialProjectGraph: ProjectGraph, partialSourceMaps: ConfigurationSourceMaps);
|
@@ -0,0 +1,56 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getPlugins = getPlugins;
|
4
|
+
exports.getOnlyDefaultPlugins = getOnlyDefaultPlugins;
|
5
|
+
exports.cleanupPlugins = cleanupPlugins;
|
6
|
+
const file_hasher_1 = require("../../hasher/file-hasher");
|
7
|
+
const nx_json_1 = require("../../config/nx-json");
|
8
|
+
const internal_api_1 = require("./internal-api");
|
9
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
10
|
+
let currentPluginsConfigurationHash;
|
11
|
+
let loadedPlugins;
|
12
|
+
let pendingPluginsPromise;
|
13
|
+
let cleanup;
|
14
|
+
async function getPlugins() {
|
15
|
+
const pluginsConfiguration = (0, nx_json_1.readNxJson)().plugins ?? [];
|
16
|
+
const pluginsConfigurationHash = (0, file_hasher_1.hashObject)(pluginsConfiguration);
|
17
|
+
// If the plugins configuration has not changed, reuse the current plugins
|
18
|
+
if (loadedPlugins &&
|
19
|
+
pluginsConfigurationHash === currentPluginsConfigurationHash) {
|
20
|
+
return loadedPlugins;
|
21
|
+
}
|
22
|
+
// Cleanup current plugins before loading new ones
|
23
|
+
if (cleanup) {
|
24
|
+
cleanup();
|
25
|
+
}
|
26
|
+
pendingPluginsPromise ??= (0, internal_api_1.loadNxPlugins)(pluginsConfiguration, workspace_root_1.workspaceRoot);
|
27
|
+
currentPluginsConfigurationHash = pluginsConfigurationHash;
|
28
|
+
const [result, cleanupFn] = await pendingPluginsPromise;
|
29
|
+
cleanup = cleanupFn;
|
30
|
+
loadedPlugins = result;
|
31
|
+
return result;
|
32
|
+
}
|
33
|
+
let loadedDefaultPlugins;
|
34
|
+
let cleanupDefaultPlugins;
|
35
|
+
let pendingDefaultPluginPromise;
|
36
|
+
async function getOnlyDefaultPlugins() {
|
37
|
+
// If the plugins configuration has not changed, reuse the current plugins
|
38
|
+
if (loadedDefaultPlugins) {
|
39
|
+
return loadedPlugins;
|
40
|
+
}
|
41
|
+
// Cleanup current plugins before loading new ones
|
42
|
+
if (cleanupDefaultPlugins) {
|
43
|
+
cleanupDefaultPlugins();
|
44
|
+
}
|
45
|
+
pendingDefaultPluginPromise ??= (0, internal_api_1.loadNxPlugins)([], workspace_root_1.workspaceRoot);
|
46
|
+
const [result, cleanupFn] = await pendingDefaultPluginPromise;
|
47
|
+
cleanupDefaultPlugins = cleanupFn;
|
48
|
+
loadedPlugins = result;
|
49
|
+
return result;
|
50
|
+
}
|
51
|
+
function cleanupPlugins() {
|
52
|
+
pendingPluginsPromise = undefined;
|
53
|
+
pendingDefaultPluginPromise = undefined;
|
54
|
+
cleanup();
|
55
|
+
cleanupDefaultPlugins();
|
56
|
+
}
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodesFromFiles = exports.registerPluginTSTranspiler = exports.readPluginPackageJson = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
tslib_1.__exportStar(require("./public-api"), exports);
|
6
|
+
// export * from './get-plugins';
|
6
7
|
var loader_1 = require("./loader");
|
7
8
|
Object.defineProperty(exports, "readPluginPackageJson", { enumerable: true, get: function () { return loader_1.readPluginPackageJson; } });
|
8
9
|
Object.defineProperty(exports, "registerPluginTSTranspiler", { enumerable: true, get: function () { return loader_1.registerPluginTSTranspiler; } });
|
@@ -18,5 +18,9 @@ export type CreateNodesResultWithContext = CreateNodesResult & {
|
|
18
18
|
file: string;
|
19
19
|
pluginName: string;
|
20
20
|
};
|
21
|
+
/**
|
22
|
+
* Use `getPlugins` instead.
|
23
|
+
* @deprecated Do not use this. Use `getPlugins` instead.
|
24
|
+
*/
|
21
25
|
export declare function loadNxPlugins(plugins: PluginConfiguration[], root?: string): Promise<readonly [LoadedNxPlugin[], () => void]>;
|
22
26
|
export declare function getDefaultPlugins(root: string): Promise<string[]>;
|
@@ -80,21 +80,28 @@ function isIsolationEnabled() {
|
|
80
80
|
// Default value
|
81
81
|
return true;
|
82
82
|
}
|
83
|
+
/**
|
84
|
+
* Use `getPlugins` instead.
|
85
|
+
* @deprecated Do not use this. Use `getPlugins` instead.
|
86
|
+
*/
|
83
87
|
async function loadNxPlugins(plugins, root = workspace_root_1.workspaceRoot) {
|
84
88
|
performance.mark('loadNxPlugins:start');
|
85
89
|
const loadingMethod = isIsolationEnabled()
|
86
90
|
? isolation_1.loadNxPluginInIsolation
|
87
91
|
: loader_1.loadNxPlugin;
|
88
92
|
plugins = await normalizePlugins(plugins, root);
|
89
|
-
const result = new Array(plugins?.length);
|
90
93
|
const cleanupFunctions = [];
|
91
|
-
await Promise.all(plugins.map(async (plugin, idx) => {
|
92
|
-
const [loadedPluginPromise, cleanup] = await loadingMethod(plugin, root);
|
93
|
-
result[idx] = loadedPluginPromise;
|
94
|
-
cleanupFunctions.push(cleanup);
|
95
|
-
}));
|
96
94
|
const ret = [
|
97
|
-
await Promise.all(
|
95
|
+
await Promise.all(plugins.map(async (plugin) => {
|
96
|
+
const pluginPath = typeof plugin === 'string' ? plugin : plugin.plugin;
|
97
|
+
performance.mark(`Load Nx Plugin: ${pluginPath} - start`);
|
98
|
+
const [loadedPluginPromise, cleanup] = await loadingMethod(plugin, root);
|
99
|
+
cleanupFunctions.push(cleanup);
|
100
|
+
const res = await loadedPluginPromise;
|
101
|
+
performance.mark(`Load Nx Plugin: ${pluginPath} - end`);
|
102
|
+
performance.measure(`Load Nx Plugin: ${pluginPath}`, `Load Nx Plugin: ${pluginPath} - start`, `Load Nx Plugin: ${pluginPath} - end`);
|
103
|
+
return res;
|
104
|
+
})),
|
98
105
|
() => {
|
99
106
|
for (const fn of cleanupFunctions) {
|
100
107
|
fn();
|
@@ -4,11 +4,5 @@ exports.loadNxPluginInIsolation = loadNxPluginInIsolation;
|
|
4
4
|
const workspace_root_1 = require("../../../utils/workspace-root");
|
5
5
|
const plugin_pool_1 = require("./plugin-pool");
|
6
6
|
async function loadNxPluginInIsolation(plugin, root = workspace_root_1.workspaceRoot) {
|
7
|
-
|
8
|
-
return [
|
9
|
-
loadingPlugin,
|
10
|
-
() => {
|
11
|
-
cleanup();
|
12
|
-
},
|
13
|
-
];
|
7
|
+
return (0, plugin_pool_1.loadRemoteNxPlugin)(plugin, root);
|
14
8
|
}
|
@@ -7,6 +7,8 @@ const net_1 = require("net");
|
|
7
7
|
const socket_utils_1 = require("../../../daemon/socket-utils");
|
8
8
|
const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
|
9
9
|
const messaging_1 = require("./messaging");
|
10
|
+
const installation_directory_1 = require("../../../utils/installation-directory");
|
11
|
+
const loader_1 = require("../loader");
|
10
12
|
const cleanupFunctions = new Set();
|
11
13
|
const pluginNames = new Map();
|
12
14
|
const PLUGIN_TIMEOUT_HINT_TEXT = 'As a last resort, you can set NX_PLUGIN_NO_TIMEOUTS=true to bypass this timeout.';
|
@@ -28,6 +30,8 @@ async function loadRemoteNxPlugin(plugin, root) {
|
|
28
30
|
if (nxPluginWorkerCache.has(cacheKey)) {
|
29
31
|
return [nxPluginWorkerCache.get(cacheKey), () => { }];
|
30
32
|
}
|
33
|
+
const moduleName = typeof plugin === 'string' ? plugin : plugin.plugin;
|
34
|
+
const { name, pluginPath, shouldRegisterTSTranspiler } = await (0, loader_1.resolveNxPlugin)(moduleName, root, (0, installation_directory_1.getNxRequirePaths)(root));
|
31
35
|
const { worker, socket } = await startPluginWorker();
|
32
36
|
const pendingPromises = new Map();
|
33
37
|
const exitHandler = createWorkerExitHandler(worker, pendingPromises);
|
@@ -40,7 +44,7 @@ async function loadRemoteNxPlugin(plugin, root) {
|
|
40
44
|
const pluginPromise = new Promise((res, rej) => {
|
41
45
|
(0, messaging_1.sendMessageOverSocket)(socket, {
|
42
46
|
type: 'load',
|
43
|
-
payload: { plugin, root },
|
47
|
+
payload: { plugin, root, name, pluginPath, shouldRegisterTSTranspiler },
|
44
48
|
});
|
45
49
|
// logger.verbose(`[plugin-worker] started worker: ${worker.pid}`);
|
46
50
|
const loadTimeout = setTimeout(() => {
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const messaging_1 = require("./messaging");
|
4
|
-
const loader_1 = require("../loader");
|
5
4
|
const serializable_error_1 = require("../../../utils/serializable-error");
|
6
5
|
const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
|
7
6
|
const net_1 = require("net");
|
8
7
|
const fs_1 = require("fs");
|
8
|
+
const loader_1 = require("../loader");
|
9
9
|
if (process.env.NX_PERF_LOGGING === 'true') {
|
10
10
|
require('../../../utils/perf-logging');
|
11
11
|
}
|
@@ -29,13 +29,18 @@ const server = (0, net_1.createServer)((socket) => {
|
|
29
29
|
return;
|
30
30
|
}
|
31
31
|
return (0, messaging_1.consumeMessage)(socket, message, {
|
32
|
-
load: async ({ plugin: pluginConfiguration, root }) => {
|
32
|
+
load: async ({ plugin: pluginConfiguration, root, name, pluginPath, shouldRegisterTSTranspiler, }) => {
|
33
33
|
if (loadTimeout)
|
34
34
|
clearTimeout(loadTimeout);
|
35
35
|
process.chdir(root);
|
36
36
|
try {
|
37
|
-
const
|
38
|
-
|
37
|
+
const { loadResolvedNxPluginAsync } = await Promise.resolve().then(() => require('../load-resolved-plugin'));
|
38
|
+
// Register the ts-transpiler if we are pointing to a
|
39
|
+
// plain ts file that's not part of a plugin project
|
40
|
+
if (shouldRegisterTSTranspiler) {
|
41
|
+
(0, loader_1.registerPluginTSTranspiler)();
|
42
|
+
}
|
43
|
+
plugin = await loadResolvedNxPluginAsync(pluginConfiguration, pluginPath, name);
|
39
44
|
return {
|
40
45
|
type: 'load-result',
|
41
46
|
payload: {
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.loadResolvedNxPluginAsync = loadResolvedNxPluginAsync;
|
4
|
+
const internal_api_1 = require("./internal-api");
|
5
|
+
async function loadResolvedNxPluginAsync(pluginConfiguration, pluginPath, name) {
|
6
|
+
const plugin = await importPluginModule(pluginPath);
|
7
|
+
plugin.name ??= name;
|
8
|
+
return new internal_api_1.LoadedNxPlugin(plugin, pluginConfiguration);
|
9
|
+
}
|
10
|
+
async function importPluginModule(pluginPath) {
|
11
|
+
const m = await Promise.resolve(`${pluginPath}`).then(s => require(s));
|
12
|
+
if (m.default &&
|
13
|
+
('createNodes' in m.default ||
|
14
|
+
'createNodesV2' in m.default ||
|
15
|
+
'createDependencies' in m.default)) {
|
16
|
+
return m.default;
|
17
|
+
}
|
18
|
+
return m;
|
19
|
+
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
|
2
2
|
import { PackageJson } from '../../utils/package-json';
|
3
|
-
import { PluginConfiguration } from '../../config/nx-json';
|
3
|
+
import type { PluginConfiguration } from '../../config/nx-json';
|
4
4
|
import { LoadedNxPlugin } from './internal-api';
|
5
5
|
export declare function readPluginPackageJson(pluginName: string, projects: Record<string, ProjectConfiguration>, paths?: string[]): {
|
6
6
|
path: string;
|
@@ -19,6 +19,12 @@ export declare function registerPluginTSTranspiler(): void;
|
|
19
19
|
export declare function getPluginPathAndName(moduleName: string, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): {
|
20
20
|
pluginPath: string;
|
21
21
|
name: any;
|
22
|
+
shouldRegisterTSTranspiler: boolean;
|
22
23
|
};
|
23
24
|
export declare function loadNxPlugin(plugin: PluginConfiguration, root: string): readonly [Promise<LoadedNxPlugin>, () => void];
|
25
|
+
export declare function resolveNxPlugin(moduleName: string, root: string, paths: string[]): Promise<{
|
26
|
+
pluginPath: string;
|
27
|
+
name: any;
|
28
|
+
shouldRegisterTSTranspiler: boolean;
|
29
|
+
}>;
|
24
30
|
export declare function loadNxPluginAsync(pluginConfiguration: PluginConfiguration, paths: string[], root: string): Promise<LoadedNxPlugin>;
|