nx 20.3.0 → 20.3.2

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 (42) hide show
  1. package/LICENSE +1 -1
  2. package/package.json +11 -11
  3. package/src/command-line/release/version.js +8 -0
  4. package/src/daemon/server/server.js +2 -2
  5. package/src/devkit-internals.d.ts +1 -1
  6. package/src/devkit-internals.js +2 -2
  7. package/src/native/nx.wasm32-wasi.wasm +0 -0
  8. package/src/nx-cloud/update-manager.js +13 -1
  9. package/src/plugins/js/project-graph/build-dependencies/target-project-locator.js +4 -1
  10. package/src/plugins/js/utils/packages.js +16 -2
  11. package/src/project-graph/build-project-graph.d.ts +1 -1
  12. package/src/project-graph/error-types.d.ts +2 -0
  13. package/src/project-graph/error-types.js +66 -8
  14. package/src/project-graph/plugins/get-plugins.d.ts +3 -3
  15. package/src/project-graph/plugins/get-plugins.js +112 -12
  16. package/src/project-graph/plugins/in-process-loader.d.ts +10 -0
  17. package/src/project-graph/plugins/in-process-loader.js +60 -0
  18. package/src/project-graph/plugins/index.d.ts +2 -1
  19. package/src/project-graph/plugins/index.js +4 -3
  20. package/src/project-graph/plugins/isolation/index.d.ts +2 -2
  21. package/src/project-graph/plugins/isolation/messaging.d.ts +1 -1
  22. package/src/project-graph/plugins/isolation/plugin-pool.d.ts +1 -1
  23. package/src/project-graph/plugins/isolation/plugin-pool.js +2 -2
  24. package/src/project-graph/plugins/isolation/plugin-worker.js +1 -2
  25. package/src/project-graph/plugins/load-resolved-plugin.d.ts +1 -1
  26. package/src/project-graph/plugins/load-resolved-plugin.js +2 -2
  27. package/src/project-graph/plugins/{internal-api.d.ts → loaded-nx-plugin.d.ts} +4 -10
  28. package/src/project-graph/plugins/loaded-nx-plugin.js +57 -0
  29. package/src/project-graph/plugins/resolve-plugin.d.ts +15 -0
  30. package/src/project-graph/plugins/{loader.js → resolve-plugin.js} +60 -149
  31. package/src/project-graph/plugins/transpiler.d.ts +8 -0
  32. package/src/project-graph/plugins/transpiler.js +47 -0
  33. package/src/project-graph/project-graph.js +0 -3
  34. package/src/project-graph/utils/project-configuration-utils.d.ts +1 -1
  35. package/src/project-graph/utils/project-configuration-utils.js +1 -17
  36. package/src/project-graph/utils/retrieve-workspace-files.d.ts +1 -1
  37. package/src/utils/delayed-spinner.js +1 -1
  38. package/src/utils/handle-errors.js +7 -11
  39. package/src/utils/package-json.d.ts +1 -0
  40. package/src/utils/plugins/plugin-capabilities.js +2 -2
  41. package/src/project-graph/plugins/internal-api.js +0 -135
  42. package/src/project-graph/plugins/loader.d.ts +0 -30
@@ -5,7 +5,6 @@ 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");
9
8
  if (process.env.NX_PERF_LOGGING === 'true') {
10
9
  require('../../../utils/perf-logging');
11
10
  }
@@ -38,7 +37,7 @@ const server = (0, net_1.createServer)((socket) => {
38
37
  // Register the ts-transpiler if we are pointing to a
39
38
  // plain ts file that's not part of a plugin project
40
39
  if (shouldRegisterTSTranspiler) {
41
- (0, loader_1.registerPluginTSTranspiler)();
40
+ require('../transpiler').registerPluginTSTranspiler();
42
41
  }
43
42
  plugin = await loadResolvedNxPluginAsync(pluginConfiguration, pluginPath, name);
44
43
  return {
@@ -1,3 +1,3 @@
1
1
  import type { PluginConfiguration } from '../../config/nx-json';
2
- import { LoadedNxPlugin } from './internal-api';
2
+ import { LoadedNxPlugin } from './loaded-nx-plugin';
3
3
  export declare function loadResolvedNxPluginAsync(pluginConfiguration: PluginConfiguration, pluginPath: string, name: string): Promise<LoadedNxPlugin>;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadResolvedNxPluginAsync = loadResolvedNxPluginAsync;
4
- const internal_api_1 = require("./internal-api");
4
+ const loaded_nx_plugin_1 = require("./loaded-nx-plugin");
5
5
  async function loadResolvedNxPluginAsync(pluginConfiguration, pluginPath, name) {
6
6
  const plugin = await importPluginModule(pluginPath);
7
7
  plugin.name ??= name;
8
- return new internal_api_1.LoadedNxPlugin(plugin, pluginConfiguration);
8
+ return new loaded_nx_plugin_1.LoadedNxPlugin(plugin, pluginConfiguration);
9
9
  }
10
10
  async function importPluginModule(pluginPath) {
11
11
  const m = await Promise.resolve(`${pluginPath}`).then(s => require(s));
@@ -1,7 +1,7 @@
1
- import { PluginConfiguration } from '../../config/nx-json';
2
- import { CreateDependenciesContext, CreateMetadataContext, CreateNodesContextV2, CreateNodesResult, NxPluginV2, ProjectsMetadata } from './public-api';
3
- import { ProjectGraph } from '../../config/project-graph';
4
- import { RawProjectGraphDependency } from '../project-graph-builder';
1
+ import type { ProjectGraph } from '../../config/project-graph';
2
+ import type { PluginConfiguration } from '../../config/nx-json';
3
+ import type { RawProjectGraphDependency } from '../project-graph-builder';
4
+ import type { CreateDependenciesContext, CreateMetadataContext, CreateNodesContextV2, CreateNodesResult, NxPluginV2, ProjectsMetadata } from './public-api';
5
5
  export declare class LoadedNxPlugin {
6
6
  readonly name: string;
7
7
  readonly createNodes?: [
@@ -19,9 +19,3 @@ export type CreateNodesResultWithContext = CreateNodesResult & {
19
19
  file: string;
20
20
  pluginName: string;
21
21
  };
22
- /**
23
- * Use `getPlugins` instead.
24
- * @deprecated Do not use this. Use `getPlugins` instead.
25
- */
26
- export declare function loadNxPlugins(plugins: PluginConfiguration[], root?: string): Promise<readonly [LoadedNxPlugin[], () => void]>;
27
- export declare function getDefaultPlugins(root: string): Promise<string[]>;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoadedNxPlugin = void 0;
4
+ const error_types_1 = require("../error-types");
5
+ const utils_1 = require("./utils");
6
+ class LoadedNxPlugin {
7
+ constructor(plugin, pluginDefinition) {
8
+ this.name = plugin.name;
9
+ if (typeof pluginDefinition !== 'string') {
10
+ this.options = pluginDefinition.options;
11
+ this.include = pluginDefinition.include;
12
+ this.exclude = pluginDefinition.exclude;
13
+ }
14
+ if (plugin.createNodes && !plugin.createNodesV2) {
15
+ this.createNodes = [
16
+ plugin.createNodes[0],
17
+ (configFiles, context) => (0, utils_1.createNodesFromFiles)(plugin.createNodes[1], configFiles, this.options, context).then((results) => results.map((r) => [this.name, r[0], r[1]])),
18
+ ];
19
+ }
20
+ if (plugin.createNodesV2) {
21
+ this.createNodes = [
22
+ plugin.createNodesV2[0],
23
+ async (configFiles, context) => {
24
+ const result = await plugin.createNodesV2[1](configFiles, this.options, context);
25
+ return result.map((r) => [this.name, r[0], r[1]]);
26
+ },
27
+ ];
28
+ }
29
+ if (this.createNodes) {
30
+ const inner = this.createNodes[1];
31
+ this.createNodes[1] = async (...args) => {
32
+ performance.mark(`${plugin.name}:createNodes - start`);
33
+ try {
34
+ return await inner(...args);
35
+ }
36
+ catch (e) {
37
+ if ((0, error_types_1.isAggregateCreateNodesError)(e)) {
38
+ throw e;
39
+ }
40
+ // The underlying plugin errored out. We can't know any partial results.
41
+ throw new error_types_1.AggregateCreateNodesError([[null, e]], []);
42
+ }
43
+ finally {
44
+ performance.mark(`${plugin.name}:createNodes - end`);
45
+ performance.measure(`${plugin.name}:createNodes`, `${plugin.name}:createNodes - start`, `${plugin.name}:createNodes - end`);
46
+ }
47
+ };
48
+ }
49
+ if (plugin.createDependencies) {
50
+ this.createDependencies = async (context) => plugin.createDependencies(this.options, context);
51
+ }
52
+ if (plugin.createMetadata) {
53
+ this.createMetadata = async (graph, context) => plugin.createMetadata(graph, this.options, context);
54
+ }
55
+ }
56
+ }
57
+ exports.LoadedNxPlugin = LoadedNxPlugin;
@@ -0,0 +1,15 @@
1
+ import type { ProjectConfiguration } from '../../config/workspace-json-project-json';
2
+ export declare function resolveNxPlugin(moduleName: string, root: string, paths: string[]): Promise<{
3
+ pluginPath: string;
4
+ name: any;
5
+ shouldRegisterTSTranspiler: boolean;
6
+ }>;
7
+ export declare function resolveLocalNxPlugin(importPath: string, projects: Record<string, ProjectConfiguration>, root?: string): {
8
+ path: string;
9
+ projectConfig: ProjectConfiguration;
10
+ } | null;
11
+ export declare function getPluginPathAndName(moduleName: string, paths: string[], projects: Record<string, ProjectConfiguration>, root: string): {
12
+ pluginPath: string;
13
+ name: any;
14
+ shouldRegisterTSTranspiler: boolean;
15
+ };
@@ -1,135 +1,29 @@
1
1
  "use strict";
2
- // This file contains methods and utilities that should **only** be used by the plugin worker.
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.unregisterPluginTSTranspiler = void 0;
5
- exports.readPluginPackageJson = readPluginPackageJson;
3
+ exports.resolveNxPlugin = resolveNxPlugin;
6
4
  exports.resolveLocalNxPlugin = resolveLocalNxPlugin;
7
- exports.registerPluginTSTranspiler = registerPluginTSTranspiler;
8
5
  exports.getPluginPathAndName = getPluginPathAndName;
9
- exports.loadNxPlugin = loadNxPlugin;
10
- exports.resolveNxPlugin = resolveNxPlugin;
11
- exports.loadNxPluginAsync = loadNxPluginAsync;
12
- const posix_1 = require("node:path/posix");
13
- const installation_directory_1 = require("../../utils/installation-directory");
14
- const package_json_1 = require("../../utils/package-json");
6
+ const path = require("node:path");
7
+ const node_fs_1 = require("node:fs");
8
+ const packages_1 = require("../../plugins/js/utils/packages");
15
9
  const fileutils_1 = require("../../utils/fileutils");
10
+ const logger_1 = require("../../utils/logger");
11
+ const path_1 = require("../../utils/path");
16
12
  const workspace_root_1 = require("../../utils/workspace-root");
17
- const node_fs_1 = require("node:fs");
18
- const register_1 = require("../../plugins/js/utils/register");
19
13
  const find_project_for_path_1 = require("../utils/find-project-for-path");
20
- const path_1 = require("../../utils/path");
21
- const logger_1 = require("../../utils/logger");
22
- const node_path_1 = require("node:path");
23
14
  const retrieve_workspace_files_1 = require("../utils/retrieve-workspace-files");
24
- const error_types_1 = require("../error-types");
25
- const path = require("node:path/posix");
26
- const typescript_1 = require("../../plugins/js/utils/typescript");
27
- const load_resolved_plugin_1 = require("./load-resolved-plugin");
28
- const packages_1 = require("../../plugins/js/utils/packages");
29
- function readPluginPackageJson(pluginName, projects, paths = (0, installation_directory_1.getNxRequirePaths)()) {
15
+ let projectsWithoutInference;
16
+ async function resolveNxPlugin(moduleName, root, paths) {
30
17
  try {
31
- const result = (0, package_json_1.readModulePackageJsonWithoutFallbacks)(pluginName, paths);
32
- return {
33
- json: result.packageJson,
34
- path: result.path,
35
- };
36
- }
37
- catch (e) {
38
- if (e.code === 'MODULE_NOT_FOUND') {
39
- const localPluginPath = resolveLocalNxPlugin(pluginName, projects);
40
- if (localPluginPath) {
41
- const localPluginPackageJson = path.join(localPluginPath.path, 'package.json');
42
- if (!exports.unregisterPluginTSTranspiler) {
43
- registerPluginTSTranspiler();
44
- }
45
- return {
46
- path: localPluginPackageJson,
47
- json: (0, fileutils_1.readJsonFile)(localPluginPackageJson),
48
- };
49
- }
50
- }
51
- throw e;
52
- }
53
- }
54
- function resolveLocalNxPlugin(importPath, projects, root = workspace_root_1.workspaceRoot) {
55
- return lookupLocalPlugin(importPath, projects, root);
56
- }
57
- exports.unregisterPluginTSTranspiler = null;
58
- /**
59
- * Register swc-node or ts-node if they are not currently registered
60
- * with some default settings which work well for Nx plugins.
61
- */
62
- function registerPluginTSTranspiler() {
63
- // Get the first tsconfig that matches the allowed set
64
- const tsConfigName = [
65
- (0, posix_1.join)(workspace_root_1.workspaceRoot, 'tsconfig.base.json'),
66
- (0, posix_1.join)(workspace_root_1.workspaceRoot, 'tsconfig.json'),
67
- ].find((x) => (0, node_fs_1.existsSync)(x));
68
- if (!tsConfigName) {
69
- return;
70
- }
71
- const tsConfig = tsConfigName
72
- ? (0, typescript_1.readTsConfig)(tsConfigName)
73
- : {};
74
- const cleanupFns = [
75
- (0, register_1.registerTsConfigPaths)(tsConfigName),
76
- (0, register_1.registerTranspiler)({
77
- experimentalDecorators: true,
78
- emitDecoratorMetadata: true,
79
- ...tsConfig.options,
80
- }, tsConfig.raw),
81
- ];
82
- exports.unregisterPluginTSTranspiler = () => {
83
- cleanupFns.forEach((fn) => fn?.());
84
- };
85
- }
86
- function lookupLocalPlugin(importPath, projects, root = workspace_root_1.workspaceRoot) {
87
- const projectConfig = findNxProjectForImportPath(importPath, projects, root);
88
- if (!projectConfig) {
89
- return null;
90
- }
91
- return { path: path.join(root, projectConfig.root), projectConfig };
92
- }
93
- let packageEntryPointsToProjectMap;
94
- function findNxProjectForImportPath(importPath, projects, root = workspace_root_1.workspaceRoot) {
95
- const tsConfigPaths = readTsConfigPaths(root);
96
- const possibleTsPaths = tsConfigPaths[importPath]?.map((p) => (0, path_1.normalizePath)(path.relative(root, path.join(root, p)))) ?? [];
97
- const projectRootMappings = new Map();
98
- if (possibleTsPaths.length) {
99
- const projectNameMap = new Map();
100
- for (const projectRoot in projects) {
101
- const project = projects[projectRoot];
102
- projectRootMappings.set(project.root, project.name);
103
- projectNameMap.set(project.name, project);
104
- }
105
- for (const tsConfigPath of possibleTsPaths) {
106
- const nxProject = (0, find_project_for_path_1.findProjectForPath)(tsConfigPath, projectRootMappings);
107
- if (nxProject) {
108
- return projectNameMap.get(nxProject);
109
- }
110
- }
111
- }
112
- packageEntryPointsToProjectMap ??=
113
- (0, packages_1.getPackageEntryPointsToProjectMap)(projects);
114
- if (packageEntryPointsToProjectMap[importPath]) {
115
- return packageEntryPointsToProjectMap[importPath];
18
+ require.resolve(moduleName);
116
19
  }
117
- logger_1.logger.verbose('Unable to find local plugin', possibleTsPaths, projectRootMappings);
118
- throw new Error('Unable to resolve local plugin with import path ' + importPath);
119
- }
120
- let tsconfigPaths;
121
- function readTsConfigPaths(root = workspace_root_1.workspaceRoot) {
122
- if (!tsconfigPaths) {
123
- const tsconfigPath = ['tsconfig.base.json', 'tsconfig.json']
124
- .map((x) => path.join(root, x))
125
- .filter((x) => (0, node_fs_1.existsSync)(x))[0];
126
- if (!tsconfigPath) {
127
- throw new Error('unable to find tsconfig.base.json or tsconfig.json');
128
- }
129
- const { compilerOptions } = (0, fileutils_1.readJsonFile)(tsconfigPath);
130
- tsconfigPaths = compilerOptions?.paths;
20
+ catch {
21
+ // If a plugin cannot be resolved, we will need projects to resolve it
22
+ projectsWithoutInference ??=
23
+ await (0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
131
24
  }
132
- return tsconfigPaths ?? {};
25
+ const { pluginPath, name, shouldRegisterTSTranspiler } = getPluginPathAndName(moduleName, paths, projectsWithoutInference, root);
26
+ return { pluginPath, name, shouldRegisterTSTranspiler };
133
27
  }
134
28
  function readPluginMainFromProjectConfiguration(plugin) {
135
29
  const { main } = Object.values(plugin.targets).find((x) => [
@@ -144,6 +38,9 @@ function readPluginMainFromProjectConfiguration(plugin) {
144
38
  {};
145
39
  return main;
146
40
  }
41
+ function resolveLocalNxPlugin(importPath, projects, root = workspace_root_1.workspaceRoot) {
42
+ return lookupLocalPlugin(importPath, projects, root);
43
+ }
147
44
  function getPluginPathAndName(moduleName, paths, projects, root) {
148
45
  let pluginPath;
149
46
  let shouldRegisterTSTranspiler = false;
@@ -172,43 +69,57 @@ function getPluginPathAndName(moduleName, paths, projects, root) {
172
69
  }
173
70
  }
174
71
  const packageJsonPath = path.join(pluginPath, 'package.json');
175
- const { name } = !['.ts', '.js'].some((x) => (0, node_path_1.extname)(moduleName) === x) && // Not trying to point to a ts or js file
72
+ const { name } = !['.ts', '.js'].some((x) => path.extname(moduleName) === x) && // Not trying to point to a ts or js file
176
73
  (0, node_fs_1.existsSync)(packageJsonPath) // plugin has a package.json
177
74
  ? (0, fileutils_1.readJsonFile)(packageJsonPath) // read name from package.json
178
75
  : { name: moduleName };
179
76
  return { pluginPath, name, shouldRegisterTSTranspiler };
180
77
  }
181
- let projectsWithoutInference;
182
- function loadNxPlugin(plugin, root) {
183
- return [
184
- loadNxPluginAsync(plugin, (0, installation_directory_1.getNxRequirePaths)(root), root),
185
- () => { },
186
- ];
78
+ function lookupLocalPlugin(importPath, projects, root = workspace_root_1.workspaceRoot) {
79
+ const projectConfig = findNxProjectForImportPath(importPath, projects, root);
80
+ if (!projectConfig) {
81
+ return null;
82
+ }
83
+ return { path: path.join(root, projectConfig.root), projectConfig };
187
84
  }
188
- async function resolveNxPlugin(moduleName, root, paths) {
189
- try {
190
- require.resolve(moduleName);
85
+ let packageEntryPointsToProjectMap;
86
+ function findNxProjectForImportPath(importPath, projects, root = workspace_root_1.workspaceRoot) {
87
+ const tsConfigPaths = readTsConfigPaths(root);
88
+ const possibleTsPaths = tsConfigPaths[importPath]?.map((p) => (0, path_1.normalizePath)(path.relative(root, path.join(root, p)))) ?? [];
89
+ const projectRootMappings = new Map();
90
+ if (possibleTsPaths.length) {
91
+ const projectNameMap = new Map();
92
+ for (const projectRoot in projects) {
93
+ const project = projects[projectRoot];
94
+ projectRootMappings.set(project.root, project.name);
95
+ projectNameMap.set(project.name, project);
96
+ }
97
+ for (const tsConfigPath of possibleTsPaths) {
98
+ const nxProject = (0, find_project_for_path_1.findProjectForPath)(tsConfigPath, projectRootMappings);
99
+ if (nxProject) {
100
+ return projectNameMap.get(nxProject);
101
+ }
102
+ }
191
103
  }
192
- catch {
193
- // If a plugin cannot be resolved, we will need projects to resolve it
194
- projectsWithoutInference ??=
195
- await (0, retrieve_workspace_files_1.retrieveProjectConfigurationsWithoutPluginInference)(root);
104
+ packageEntryPointsToProjectMap ??=
105
+ (0, packages_1.getPackageEntryPointsToProjectMap)(projects);
106
+ if (packageEntryPointsToProjectMap[importPath]) {
107
+ return packageEntryPointsToProjectMap[importPath];
196
108
  }
197
- const { pluginPath, name, shouldRegisterTSTranspiler } = getPluginPathAndName(moduleName, paths, projectsWithoutInference, root);
198
- return { pluginPath, name, shouldRegisterTSTranspiler };
109
+ logger_1.logger.verbose('Unable to find local plugin', possibleTsPaths, projectRootMappings);
110
+ throw new Error('Unable to resolve local plugin with import path ' + importPath);
199
111
  }
200
- async function loadNxPluginAsync(pluginConfiguration, paths, root) {
201
- const moduleName = typeof pluginConfiguration === 'string'
202
- ? pluginConfiguration
203
- : pluginConfiguration.plugin;
204
- try {
205
- const { pluginPath, name, shouldRegisterTSTranspiler } = await resolveNxPlugin(moduleName, root, paths);
206
- if (shouldRegisterTSTranspiler) {
207
- registerPluginTSTranspiler();
112
+ let tsconfigPaths;
113
+ function readTsConfigPaths(root = workspace_root_1.workspaceRoot) {
114
+ if (!tsconfigPaths) {
115
+ const tsconfigPath = ['tsconfig.base.json', 'tsconfig.json']
116
+ .map((x) => path.join(root, x))
117
+ .filter((x) => (0, node_fs_1.existsSync)(x))[0];
118
+ if (!tsconfigPath) {
119
+ throw new Error('unable to find tsconfig.base.json or tsconfig.json');
208
120
  }
209
- return (0, load_resolved_plugin_1.loadResolvedNxPluginAsync)(pluginConfiguration, pluginPath, name);
210
- }
211
- catch (e) {
212
- throw new error_types_1.LoadPluginError(moduleName, e);
121
+ const { compilerOptions } = (0, fileutils_1.readJsonFile)(tsconfigPath);
122
+ tsconfigPaths = compilerOptions?.paths;
213
123
  }
124
+ return tsconfigPaths ?? {};
214
125
  }
@@ -0,0 +1,8 @@
1
+ export declare let unregisterPluginTSTranspiler: (() => void) | null;
2
+ /**
3
+ * Register swc-node or ts-node if they are not currently registered
4
+ * with some default settings which work well for Nx plugins.
5
+ */
6
+ export declare function registerPluginTSTranspiler(): void;
7
+ export declare function pluginTranspilerIsRegistered(): boolean;
8
+ export declare function cleanupPluginTSTranspiler(): void;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unregisterPluginTSTranspiler = void 0;
4
+ exports.registerPluginTSTranspiler = registerPluginTSTranspiler;
5
+ exports.pluginTranspilerIsRegistered = pluginTranspilerIsRegistered;
6
+ exports.cleanupPluginTSTranspiler = cleanupPluginTSTranspiler;
7
+ const node_fs_1 = require("node:fs");
8
+ const posix_1 = require("node:path/posix");
9
+ const workspace_root_1 = require("../../utils/workspace-root");
10
+ const register_1 = require("../../plugins/js/utils/register");
11
+ const typescript_1 = require("../../plugins/js/utils/typescript");
12
+ exports.unregisterPluginTSTranspiler = null;
13
+ /**
14
+ * Register swc-node or ts-node if they are not currently registered
15
+ * with some default settings which work well for Nx plugins.
16
+ */
17
+ function registerPluginTSTranspiler() {
18
+ // Get the first tsconfig that matches the allowed set
19
+ const tsConfigName = [
20
+ (0, posix_1.join)(workspace_root_1.workspaceRoot, 'tsconfig.base.json'),
21
+ (0, posix_1.join)(workspace_root_1.workspaceRoot, 'tsconfig.json'),
22
+ ].find((x) => (0, node_fs_1.existsSync)(x));
23
+ if (!tsConfigName) {
24
+ return;
25
+ }
26
+ const tsConfig = tsConfigName
27
+ ? (0, typescript_1.readTsConfig)(tsConfigName)
28
+ : {};
29
+ const cleanupFns = [
30
+ (0, register_1.registerTsConfigPaths)(tsConfigName),
31
+ (0, register_1.registerTranspiler)({
32
+ experimentalDecorators: true,
33
+ emitDecoratorMetadata: true,
34
+ ...tsConfig.options,
35
+ }, tsConfig.raw),
36
+ ];
37
+ exports.unregisterPluginTSTranspiler = () => {
38
+ cleanupFns.forEach((fn) => fn?.());
39
+ };
40
+ }
41
+ function pluginTranspilerIsRegistered() {
42
+ return exports.unregisterPluginTSTranspiler !== null;
43
+ }
44
+ function cleanupPluginTSTranspiler() {
45
+ (0, exports.unregisterPluginTSTranspiler)?.();
46
+ exports.unregisterPluginTSTranspiler = null;
47
+ }
@@ -135,9 +135,6 @@ function handleProjectGraphError(opts, e) {
135
135
  const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
136
136
  if (e instanceof error_types_1.ProjectGraphError) {
137
137
  let title = e.message;
138
- if (isVerbose) {
139
- title += ' See errors below.';
140
- }
141
138
  const bodyLines = isVerbose
142
139
  ? [e.stack]
143
140
  : ['Pass --verbose to see the stacktraces.'];
@@ -1,7 +1,7 @@
1
1
  import { NxJsonConfiguration, TargetDefaults } from '../../config/nx-json';
2
2
  import { ProjectGraphExternalNode } from '../../config/project-graph';
3
3
  import { ProjectConfiguration, ProjectMetadata, TargetConfiguration, TargetMetadata } from '../../config/workspace-json-project-json';
4
- import { LoadedNxPlugin } from '../plugins/internal-api';
4
+ import { LoadedNxPlugin } from '../plugins/loaded-nx-plugin';
5
5
  export type SourceInformation = [file: string | null, plugin: string];
6
6
  export type ConfigurationSourceMaps = Record<string, Record<string, SourceInformation>>;
7
7
  export declare function mergeProjectConfigurationIntoRootMap(projectRootMap: Record<string, ProjectConfiguration>, project: ProjectConfiguration, configurationSourceMaps?: ConfigurationSourceMaps, sourceInformation?: SourceInformation, skipTargetNormalization?: boolean): void;
@@ -260,28 +260,12 @@ plugins) {
260
260
  workspaceRoot: root,
261
261
  })
262
262
  .catch((e) => {
263
- const errorBodyLines = [
264
- `An error occurred while processing files for the ${pluginName} plugin.`,
265
- ];
266
263
  const error = (0, error_types_1.isAggregateCreateNodesError)(e)
267
264
  ? // This is an expected error if something goes wrong while processing files.
268
265
  e
269
266
  : // This represents a single plugin erroring out with a hard error.
270
267
  new error_types_1.AggregateCreateNodesError([[null, e]], []);
271
- const innerErrors = error.errors;
272
- for (const [file, e] of innerErrors) {
273
- if (file) {
274
- errorBodyLines.push(` - ${file}: ${e.message}`);
275
- }
276
- else {
277
- errorBodyLines.push(` - ${e.message}`);
278
- }
279
- if (e.stack) {
280
- const innerStackTrace = ' ' + e.stack.split('\n')?.join('\n ');
281
- errorBodyLines.push(innerStackTrace);
282
- }
283
- }
284
- error.stack = errorBodyLines.join('\n');
268
+ (0, error_types_1.formatAggregateCreateNodesError)(error, pluginName);
285
269
  // This represents a single plugin erroring out with a hard error.
286
270
  errors.push(error);
287
271
  // The plugin didn't return partial results, so we return an empty array.
@@ -1,7 +1,7 @@
1
1
  import { ProjectConfiguration } from '../../config/workspace-json-project-json';
2
2
  import { NxJsonConfiguration } from '../../config/nx-json';
3
3
  import { ConfigurationResult } from './project-configuration-utils';
4
- import { LoadedNxPlugin } from '../plugins/internal-api';
4
+ import { LoadedNxPlugin } from '../plugins/loaded-nx-plugin';
5
5
  /**
6
6
  * Walks the workspace directory to create the `projectFileMap`, `ProjectConfigurations` and `allWorkspaceFiles`
7
7
  * @throws
@@ -21,13 +21,13 @@ class DelayedSpinner {
21
21
  const delay = SHOULD_SHOW_SPINNERS ? opts.delay : opts.ciDelay;
22
22
  this.timeouts.push(setTimeout(() => {
23
23
  this.ready = true;
24
+ this.lastMessage = message;
24
25
  if (!SHOULD_SHOW_SPINNERS) {
25
26
  console.warn(this.lastMessage);
26
27
  }
27
28
  else {
28
29
  this.spinner = ora(this.lastMessage).start();
29
30
  }
30
- this.lastMessage = message;
31
31
  }, delay).unref());
32
32
  }
33
33
  /**
@@ -24,22 +24,18 @@ async function handleErrors(isVerbose, fn) {
24
24
  'message' in projectGraphError.cause) {
25
25
  title += ' ' + projectGraphError.cause.message + '.';
26
26
  }
27
- if (isVerbose) {
28
- title += ' See errors below.';
29
- }
30
- const bodyLines = isVerbose
31
- ? formatErrorStackAndCause(projectGraphError)
32
- : ['Pass --verbose to see the stacktraces.'];
33
27
  output_1.output.error({
34
28
  title,
35
- bodyLines: bodyLines,
29
+ bodyLines: isVerbose
30
+ ? formatErrorStackAndCause(projectGraphError, isVerbose)
31
+ : projectGraphError.getErrors().map((e) => e.message),
36
32
  });
37
33
  }
38
34
  else {
39
35
  const lines = (err.message ? err.message : err.toString()).split('\n');
40
36
  const bodyLines = lines.slice(1);
41
37
  if (isVerbose) {
42
- bodyLines.push(...formatErrorStackAndCause(err));
38
+ bodyLines.push(...formatErrorStackAndCause(err, isVerbose));
43
39
  }
44
40
  else if (err.stack) {
45
41
  bodyLines.push('Pass --verbose to see the stacktrace.');
@@ -56,13 +52,13 @@ async function handleErrors(isVerbose, fn) {
56
52
  return 1;
57
53
  }
58
54
  }
59
- function formatErrorStackAndCause(error) {
55
+ function formatErrorStackAndCause(error, verbose) {
60
56
  return [
61
- error.stack || error.message,
57
+ verbose ? error.stack || error.message : error.message,
62
58
  ...(error.cause && typeof error.cause === 'object'
63
59
  ? [
64
60
  'Caused by:',
65
- 'stack' in error.cause
61
+ verbose && 'stack' in error.cause
66
62
  ? error.cause.stack.toString()
67
63
  : error.cause.toString(),
68
64
  ]
@@ -36,6 +36,7 @@ export interface PackageJson {
36
36
  require?: string;
37
37
  import?: string;
38
38
  development?: string;
39
+ default?: string;
39
40
  }>;
40
41
  dependencies?: Record<string, string>;
41
42
  devDependencies?: Record<string, string>;
@@ -5,7 +5,7 @@ const path_1 = require("path");
5
5
  const fileutils_1 = require("../fileutils");
6
6
  const installation_directory_1 = require("../installation-directory");
7
7
  const plugins_1 = require("../../project-graph/plugins");
8
- const loader_1 = require("../../project-graph/plugins/loader");
8
+ const in_process_loader_1 = require("../../project-graph/plugins/in-process-loader");
9
9
  function tryGetCollection(packageJsonPath, collectionFile, propName) {
10
10
  if (!collectionFile) {
11
11
  return null;
@@ -61,7 +61,7 @@ async function tryGetModule(packageJson, workspaceRoot) {
61
61
  packageJson['nx-migrations'] ??
62
62
  packageJson['schematics'] ??
63
63
  packageJson['builders']) {
64
- const [pluginPromise] = (0, loader_1.loadNxPlugin)(packageJson.name, workspaceRoot);
64
+ const [pluginPromise] = (0, in_process_loader_1.loadNxPlugin)(packageJson.name, workspaceRoot);
65
65
  return await pluginPromise;
66
66
  }
67
67
  else {