nx 20.2.0-beta.6 → 20.2.0-beta.7
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/package.json +11 -11
- package/src/native/nx.wasm32-wasi.wasm +0 -0
- package/src/project-graph/plugins/get-plugins.js +8 -2
- 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 +6 -0
- package/src/project-graph/plugins/loader.js +22 -31
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "20.2.0-beta.
|
3
|
+
"version": "20.2.0-beta.7",
|
4
4
|
"private": false,
|
5
5
|
"description": "The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.",
|
6
6
|
"repository": {
|
@@ -80,16 +80,16 @@
|
|
80
80
|
}
|
81
81
|
},
|
82
82
|
"optionalDependencies": {
|
83
|
-
"@nx/nx-darwin-x64": "20.2.0-beta.
|
84
|
-
"@nx/nx-darwin-arm64": "20.2.0-beta.
|
85
|
-
"@nx/nx-linux-x64-gnu": "20.2.0-beta.
|
86
|
-
"@nx/nx-linux-x64-musl": "20.2.0-beta.
|
87
|
-
"@nx/nx-win32-x64-msvc": "20.2.0-beta.
|
88
|
-
"@nx/nx-linux-arm64-gnu": "20.2.0-beta.
|
89
|
-
"@nx/nx-linux-arm64-musl": "20.2.0-beta.
|
90
|
-
"@nx/nx-linux-arm-gnueabihf": "20.2.0-beta.
|
91
|
-
"@nx/nx-win32-arm64-msvc": "20.2.0-beta.
|
92
|
-
"@nx/nx-freebsd-x64": "20.2.0-beta.
|
83
|
+
"@nx/nx-darwin-x64": "20.2.0-beta.7",
|
84
|
+
"@nx/nx-darwin-arm64": "20.2.0-beta.7",
|
85
|
+
"@nx/nx-linux-x64-gnu": "20.2.0-beta.7",
|
86
|
+
"@nx/nx-linux-x64-musl": "20.2.0-beta.7",
|
87
|
+
"@nx/nx-win32-x64-msvc": "20.2.0-beta.7",
|
88
|
+
"@nx/nx-linux-arm64-gnu": "20.2.0-beta.7",
|
89
|
+
"@nx/nx-linux-arm64-musl": "20.2.0-beta.7",
|
90
|
+
"@nx/nx-linux-arm-gnueabihf": "20.2.0-beta.7",
|
91
|
+
"@nx/nx-win32-arm64-msvc": "20.2.0-beta.7",
|
92
|
+
"@nx/nx-freebsd-x64": "20.2.0-beta.7"
|
93
93
|
},
|
94
94
|
"nx-migrations": {
|
95
95
|
"migrations": "./migrations.json",
|
Binary file
|
@@ -9,6 +9,7 @@ const internal_api_1 = require("./internal-api");
|
|
9
9
|
const workspace_root_1 = require("../../utils/workspace-root");
|
10
10
|
let currentPluginsConfigurationHash;
|
11
11
|
let loadedPlugins;
|
12
|
+
let pendingPluginsPromise;
|
12
13
|
let cleanup;
|
13
14
|
async function getPlugins() {
|
14
15
|
const pluginsConfiguration = (0, nx_json_1.readNxJson)().plugins ?? [];
|
@@ -22,14 +23,16 @@ async function getPlugins() {
|
|
22
23
|
if (cleanup) {
|
23
24
|
cleanup();
|
24
25
|
}
|
26
|
+
pendingPluginsPromise ??= (0, internal_api_1.loadNxPlugins)(pluginsConfiguration, workspace_root_1.workspaceRoot);
|
25
27
|
currentPluginsConfigurationHash = pluginsConfigurationHash;
|
26
|
-
const [result, cleanupFn] = await
|
28
|
+
const [result, cleanupFn] = await pendingPluginsPromise;
|
27
29
|
cleanup = cleanupFn;
|
28
30
|
loadedPlugins = result;
|
29
31
|
return result;
|
30
32
|
}
|
31
33
|
let loadedDefaultPlugins;
|
32
34
|
let cleanupDefaultPlugins;
|
35
|
+
let pendingDefaultPluginPromise;
|
33
36
|
async function getOnlyDefaultPlugins() {
|
34
37
|
// If the plugins configuration has not changed, reuse the current plugins
|
35
38
|
if (loadedDefaultPlugins) {
|
@@ -39,12 +42,15 @@ async function getOnlyDefaultPlugins() {
|
|
39
42
|
if (cleanupDefaultPlugins) {
|
40
43
|
cleanupDefaultPlugins();
|
41
44
|
}
|
42
|
-
|
45
|
+
pendingDefaultPluginPromise ??= (0, internal_api_1.loadNxPlugins)([], workspace_root_1.workspaceRoot);
|
46
|
+
const [result, cleanupFn] = await pendingDefaultPluginPromise;
|
43
47
|
cleanupDefaultPlugins = cleanupFn;
|
44
48
|
loadedPlugins = result;
|
45
49
|
return result;
|
46
50
|
}
|
47
51
|
function cleanupPlugins() {
|
52
|
+
pendingPluginsPromise = undefined;
|
53
|
+
pendingDefaultPluginPromise = undefined;
|
48
54
|
cleanup();
|
49
55
|
cleanupDefaultPlugins();
|
50
56
|
}
|
@@ -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(() => {
|
@@ -5,6 +5,7 @@ const serializable_error_1 = require("../../../utils/serializable-error");
|
|
5
5
|
const consume_messages_from_socket_1 = require("../../../utils/consume-messages-from-socket");
|
6
6
|
const net_1 = require("net");
|
7
7
|
const fs_1 = require("fs");
|
8
|
+
const loader_1 = require("../loader");
|
8
9
|
if (process.env.NX_PERF_LOGGING === 'true') {
|
9
10
|
require('../../../utils/perf-logging');
|
10
11
|
}
|
@@ -28,14 +29,18 @@ const server = (0, net_1.createServer)((socket) => {
|
|
28
29
|
return;
|
29
30
|
}
|
30
31
|
return (0, messaging_1.consumeMessage)(socket, message, {
|
31
|
-
load: async ({ plugin: pluginConfiguration, root }) => {
|
32
|
+
load: async ({ plugin: pluginConfiguration, root, name, pluginPath, shouldRegisterTSTranspiler, }) => {
|
32
33
|
if (loadTimeout)
|
33
34
|
clearTimeout(loadTimeout);
|
34
35
|
process.chdir(root);
|
35
36
|
try {
|
36
|
-
const {
|
37
|
-
|
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
|
+
}
|
@@ -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>;
|
@@ -7,6 +7,7 @@ exports.resolveLocalNxPlugin = resolveLocalNxPlugin;
|
|
7
7
|
exports.registerPluginTSTranspiler = registerPluginTSTranspiler;
|
8
8
|
exports.getPluginPathAndName = getPluginPathAndName;
|
9
9
|
exports.loadNxPlugin = loadNxPlugin;
|
10
|
+
exports.resolveNxPlugin = resolveNxPlugin;
|
10
11
|
exports.loadNxPluginAsync = loadNxPluginAsync;
|
11
12
|
const posix_1 = require("node:path/posix");
|
12
13
|
const installation_directory_1 = require("../../utils/installation-directory");
|
@@ -20,10 +21,10 @@ const path_1 = require("../../utils/path");
|
|
20
21
|
const logger_1 = require("../../utils/logger");
|
21
22
|
const node_path_1 = require("node:path");
|
22
23
|
const retrieve_workspace_files_1 = require("../utils/retrieve-workspace-files");
|
23
|
-
const internal_api_1 = require("./internal-api");
|
24
24
|
const error_types_1 = require("../error-types");
|
25
25
|
const path = require("node:path/posix");
|
26
26
|
const typescript_1 = require("../../plugins/js/utils/typescript");
|
27
|
+
const load_resolved_plugin_1 = require("./load-resolved-plugin");
|
27
28
|
function readPluginPackageJson(pluginName, projects, paths = (0, installation_directory_1.getNxRequirePaths)()) {
|
28
29
|
try {
|
29
30
|
const result = (0, package_json_1.readModulePackageJsonWithoutFallbacks)(pluginName, paths);
|
@@ -138,19 +139,19 @@ function readPluginMainFromProjectConfiguration(plugin) {
|
|
138
139
|
}
|
139
140
|
function getPluginPathAndName(moduleName, paths, projects, root) {
|
140
141
|
let pluginPath;
|
141
|
-
let
|
142
|
+
let shouldRegisterTSTranspiler = false;
|
142
143
|
try {
|
143
144
|
pluginPath = require.resolve(moduleName, {
|
144
145
|
paths,
|
145
146
|
});
|
146
147
|
const extension = path.extname(pluginPath);
|
147
|
-
|
148
|
+
shouldRegisterTSTranspiler = extension === '.ts';
|
148
149
|
}
|
149
150
|
catch (e) {
|
150
151
|
if (e.code === 'MODULE_NOT_FOUND') {
|
151
152
|
const plugin = resolveLocalNxPlugin(moduleName, projects, root);
|
152
153
|
if (plugin) {
|
153
|
-
|
154
|
+
shouldRegisterTSTranspiler = true;
|
154
155
|
const main = readPluginMainFromProjectConfiguration(plugin.projectConfig);
|
155
156
|
pluginPath = main ? path.join(root, main) : plugin.path;
|
156
157
|
}
|
@@ -164,16 +165,11 @@ function getPluginPathAndName(moduleName, paths, projects, root) {
|
|
164
165
|
}
|
165
166
|
}
|
166
167
|
const packageJsonPath = path.join(pluginPath, 'package.json');
|
167
|
-
// Register the ts-transpiler if we are pointing to a
|
168
|
-
// plain ts file that's not part of a plugin project
|
169
|
-
if (registerTSTranspiler) {
|
170
|
-
registerPluginTSTranspiler();
|
171
|
-
}
|
172
168
|
const { name } = !['.ts', '.js'].some((x) => (0, node_path_1.extname)(moduleName) === x) && // Not trying to point to a ts or js file
|
173
169
|
(0, node_fs_1.existsSync)(packageJsonPath) // plugin has a package.json
|
174
170
|
? (0, fileutils_1.readJsonFile)(packageJsonPath) // read name from package.json
|
175
171
|
: { name: moduleName };
|
176
|
-
return { pluginPath, name };
|
172
|
+
return { pluginPath, name, shouldRegisterTSTranspiler };
|
177
173
|
}
|
178
174
|
let projectsWithoutInference;
|
179
175
|
function loadNxPlugin(plugin, root) {
|
@@ -182,35 +178,30 @@ function loadNxPlugin(plugin, root) {
|
|
182
178
|
() => { },
|
183
179
|
];
|
184
180
|
}
|
181
|
+
async function resolveNxPlugin(moduleName, root, paths) {
|
182
|
+
try {
|
183
|
+
require.resolve(moduleName);
|
184
|
+
}
|
185
|
+
catch {
|
186
|
+
// If a plugin cannot be resolved, we will need projects to resolve it
|
187
|
+
projectsWithoutInference ??=
|
188
|
+
await (0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
|
189
|
+
}
|
190
|
+
const { pluginPath, name, shouldRegisterTSTranspiler } = getPluginPathAndName(moduleName, paths, projectsWithoutInference, root);
|
191
|
+
return { pluginPath, name, shouldRegisterTSTranspiler };
|
192
|
+
}
|
185
193
|
async function loadNxPluginAsync(pluginConfiguration, paths, root) {
|
186
194
|
const moduleName = typeof pluginConfiguration === 'string'
|
187
195
|
? pluginConfiguration
|
188
196
|
: pluginConfiguration.plugin;
|
189
197
|
try {
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
catch {
|
194
|
-
// If a plugin cannot be resolved, we will need projects to resolve it
|
195
|
-
projectsWithoutInference ??=
|
196
|
-
await (0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
|
198
|
+
const { pluginPath, name, shouldRegisterTSTranspiler } = await resolveNxPlugin(moduleName, root, paths);
|
199
|
+
if (shouldRegisterTSTranspiler) {
|
200
|
+
registerPluginTSTranspiler();
|
197
201
|
}
|
198
|
-
|
199
|
-
const plugin = await importPluginModule(pluginPath);
|
200
|
-
plugin.name ??= name;
|
201
|
-
return new internal_api_1.LoadedNxPlugin(plugin, pluginConfiguration);
|
202
|
+
return (0, load_resolved_plugin_1.loadResolvedNxPluginAsync)(pluginConfiguration, pluginPath, name);
|
202
203
|
}
|
203
204
|
catch (e) {
|
204
205
|
throw new error_types_1.LoadPluginError(moduleName, e);
|
205
206
|
}
|
206
207
|
}
|
207
|
-
async function importPluginModule(pluginPath) {
|
208
|
-
const m = await Promise.resolve(`${pluginPath}`).then(s => require(s));
|
209
|
-
if (m.default &&
|
210
|
-
('createNodes' in m.default ||
|
211
|
-
'createNodesV2' in m.default ||
|
212
|
-
'createDependencies' in m.default)) {
|
213
|
-
return m.default;
|
214
|
-
}
|
215
|
-
return m;
|
216
|
-
}
|