nx 21.2.0-canary.20250605-5ffd82e → 21.2.0-canary.20250606-c43d2f2
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/plugins/js/utils/register.d.ts +3 -2
- package/src/plugins/js/utils/register.js +36 -22
- package/src/plugins/js/utils/typescript.d.ts +2 -1
- package/src/plugins/js/utils/typescript.js +12 -7
- package/src/project-graph/plugins/transpiler.js +5 -5
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nx",
|
3
|
-
"version": "21.2.0-canary.
|
3
|
+
"version": "21.2.0-canary.20250606-c43d2f2",
|
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": {
|
@@ -83,16 +83,16 @@
|
|
83
83
|
}
|
84
84
|
},
|
85
85
|
"optionalDependencies": {
|
86
|
-
"@nx/nx-darwin-arm64": "21.2.0-canary.
|
87
|
-
"@nx/nx-darwin-x64": "21.2.0-canary.
|
88
|
-
"@nx/nx-freebsd-x64": "21.2.0-canary.
|
89
|
-
"@nx/nx-linux-arm-gnueabihf": "21.2.0-canary.
|
90
|
-
"@nx/nx-linux-arm64-gnu": "21.2.0-canary.
|
91
|
-
"@nx/nx-linux-arm64-musl": "21.2.0-canary.
|
92
|
-
"@nx/nx-linux-x64-gnu": "21.2.0-canary.
|
93
|
-
"@nx/nx-linux-x64-musl": "21.2.0-canary.
|
94
|
-
"@nx/nx-win32-arm64-msvc": "21.2.0-canary.
|
95
|
-
"@nx/nx-win32-x64-msvc": "21.2.0-canary.
|
86
|
+
"@nx/nx-darwin-arm64": "21.2.0-canary.20250606-c43d2f2",
|
87
|
+
"@nx/nx-darwin-x64": "21.2.0-canary.20250606-c43d2f2",
|
88
|
+
"@nx/nx-freebsd-x64": "21.2.0-canary.20250606-c43d2f2",
|
89
|
+
"@nx/nx-linux-arm-gnueabihf": "21.2.0-canary.20250606-c43d2f2",
|
90
|
+
"@nx/nx-linux-arm64-gnu": "21.2.0-canary.20250606-c43d2f2",
|
91
|
+
"@nx/nx-linux-arm64-musl": "21.2.0-canary.20250606-c43d2f2",
|
92
|
+
"@nx/nx-linux-x64-gnu": "21.2.0-canary.20250606-c43d2f2",
|
93
|
+
"@nx/nx-linux-x64-musl": "21.2.0-canary.20250606-c43d2f2",
|
94
|
+
"@nx/nx-win32-arm64-msvc": "21.2.0-canary.20250606-c43d2f2",
|
95
|
+
"@nx/nx-win32-x64-msvc": "21.2.0-canary.20250606-c43d2f2"
|
96
96
|
},
|
97
97
|
"nx-migrations": {
|
98
98
|
"migrations": "./migrations.json",
|
Binary file
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { TsConfigOptions } from 'ts-node';
|
1
2
|
import type { CompilerOptions } from 'typescript';
|
2
3
|
/**
|
3
4
|
* Optionally, if swc-node and tsconfig-paths are available in the current workspace, apply the require
|
@@ -23,7 +24,7 @@ export declare function registerTsProject(tsConfigPath: string): () => void;
|
|
23
24
|
*/
|
24
25
|
export declare function registerTsProject(path: string, configFilename: string): any;
|
25
26
|
export declare function getSwcTranspiler(compilerOptions: CompilerOptions): (...args: unknown[]) => unknown;
|
26
|
-
export declare function getTsNodeTranspiler(compilerOptions: CompilerOptions): (...args: unknown[]) => unknown;
|
27
|
+
export declare function getTsNodeTranspiler(compilerOptions: CompilerOptions, tsNodeOptions?: TsConfigOptions): (...args: unknown[]) => unknown;
|
27
28
|
export declare function getTranspiler(compilerOptions: CompilerOptions, tsConfigRaw?: unknown): () => (...args: unknown[]) => unknown;
|
28
29
|
/**
|
29
30
|
* Register ts-node or swc-node given a set of compiler options.
|
@@ -33,7 +34,7 @@ export declare function getTranspiler(compilerOptions: CompilerOptions, tsConfig
|
|
33
34
|
*
|
34
35
|
* @returns cleanup method
|
35
36
|
*/
|
36
|
-
export declare function registerTranspiler(compilerOptions: CompilerOptions): () => void;
|
37
|
+
export declare function registerTranspiler(compilerOptions: CompilerOptions, tsConfigRaw?: unknown): () => void;
|
37
38
|
/**
|
38
39
|
* @param tsConfigPath Adds the paths from a tsconfig file into node resolutions
|
39
40
|
* @returns cleanup function
|
@@ -9,6 +9,7 @@ exports.registerTsConfigPaths = registerTsConfigPaths;
|
|
9
9
|
exports.getTsNodeCompilerOptions = getTsNodeCompilerOptions;
|
10
10
|
const path_1 = require("path");
|
11
11
|
const logger_1 = require("../../../utils/logger");
|
12
|
+
const typescript_1 = require("./typescript");
|
12
13
|
const swcNodeInstalled = packageIsInstalled('@swc-node/register');
|
13
14
|
const tsNodeInstalled = packageIsInstalled('ts-node/register');
|
14
15
|
let ts;
|
@@ -53,10 +54,10 @@ function registerTsProject(path, configFilename) {
|
|
53
54
|
return () => { };
|
54
55
|
}
|
55
56
|
const tsConfigPath = configFilename ? (0, path_1.join)(path, configFilename) : path;
|
56
|
-
const compilerOptions = readCompilerOptions(tsConfigPath);
|
57
|
+
const { compilerOptions, tsConfigRaw } = readCompilerOptions(tsConfigPath);
|
57
58
|
const cleanupFunctions = [
|
58
59
|
registerTsConfigPaths(tsConfigPath),
|
59
|
-
registerTranspiler(compilerOptions),
|
60
|
+
registerTranspiler(compilerOptions, tsConfigRaw),
|
60
61
|
];
|
61
62
|
// Add ESM support for `.ts` files.
|
62
63
|
// NOTE: There is no cleanup function for this, as it's not possible to unregister the loader.
|
@@ -90,12 +91,16 @@ function getSwcTranspiler(compilerOptions) {
|
|
90
91
|
const cleanupFn = register(compilerOptions);
|
91
92
|
return typeof cleanupFn === 'function' ? cleanupFn : () => { };
|
92
93
|
}
|
93
|
-
function getTsNodeTranspiler(compilerOptions) {
|
94
|
+
function getTsNodeTranspiler(compilerOptions, tsNodeOptions) {
|
94
95
|
const { register } = require('ts-node');
|
95
96
|
// ts-node doesn't provide a cleanup method
|
96
97
|
const service = register({
|
98
|
+
...tsNodeOptions,
|
97
99
|
transpileOnly: true,
|
98
|
-
compilerOptions: getTsNodeCompilerOptions(
|
100
|
+
compilerOptions: getTsNodeCompilerOptions({
|
101
|
+
...tsNodeOptions?.compilerOptions,
|
102
|
+
...compilerOptions,
|
103
|
+
}),
|
99
104
|
// we already read and provide the compiler options, so prevent ts-node from reading them again
|
100
105
|
skipProject: true,
|
101
106
|
});
|
@@ -165,21 +170,30 @@ function getTranspiler(compilerOptions, tsConfigRaw) {
|
|
165
170
|
compilerOptions.target = ts.ScriptTarget.ES2021;
|
166
171
|
compilerOptions.inlineSourceMap = true;
|
167
172
|
compilerOptions.skipLibCheck = true;
|
173
|
+
let _getTranspiler;
|
174
|
+
let registrationKey = JSON.stringify(compilerOptions);
|
175
|
+
let tsNodeOptions;
|
176
|
+
if (swcNodeInstalled && !preferTsNode) {
|
177
|
+
_getTranspiler = getSwcTranspiler;
|
178
|
+
}
|
179
|
+
else if (tsNodeInstalled) {
|
180
|
+
// We can fall back on ts-node if it's available
|
181
|
+
_getTranspiler = getTsNodeTranspiler;
|
182
|
+
tsNodeOptions = filterRecognizedTsConfigTsNodeOptions(tsConfigRaw?.['ts-node']).recognized;
|
183
|
+
// include ts-node options in the registration key
|
184
|
+
registrationKey += JSON.stringify(tsNodeOptions);
|
185
|
+
}
|
186
|
+
else {
|
187
|
+
_getTranspiler = undefined;
|
188
|
+
}
|
168
189
|
// Just return if transpiler was already registered before.
|
169
|
-
const registrationKey = JSON.stringify(compilerOptions);
|
170
190
|
const registrationEntry = registered.get(registrationKey);
|
171
191
|
if (registered.has(registrationKey)) {
|
172
192
|
registrationEntry.refCount++;
|
173
193
|
return registrationEntry.cleanup;
|
174
194
|
}
|
175
|
-
const _getTranspiler = swcNodeInstalled && !preferTsNode
|
176
|
-
? getSwcTranspiler
|
177
|
-
: tsNodeInstalled
|
178
|
-
? // We can fall back on ts-node if it's available
|
179
|
-
getTsNodeTranspiler
|
180
|
-
: undefined;
|
181
195
|
if (_getTranspiler) {
|
182
|
-
const transpilerCleanup = _getTranspiler(compilerOptions);
|
196
|
+
const transpilerCleanup = _getTranspiler(compilerOptions, tsNodeOptions);
|
183
197
|
const currRegistrationEntry = {
|
184
198
|
refCount: 1,
|
185
199
|
cleanup: () => {
|
@@ -204,9 +218,9 @@ function getTranspiler(compilerOptions, tsConfigRaw) {
|
|
204
218
|
*
|
205
219
|
* @returns cleanup method
|
206
220
|
*/
|
207
|
-
function registerTranspiler(compilerOptions) {
|
221
|
+
function registerTranspiler(compilerOptions, tsConfigRaw) {
|
208
222
|
// Function to register transpiler that returns cleanup function
|
209
|
-
const transpiler = getTranspiler(compilerOptions);
|
223
|
+
const transpiler = getTranspiler(compilerOptions, tsConfigRaw);
|
210
224
|
if (!transpiler) {
|
211
225
|
warnNoTranspiler();
|
212
226
|
return () => { };
|
@@ -245,7 +259,9 @@ function registerTsConfigPaths(tsConfigPath) {
|
|
245
259
|
function readCompilerOptions(tsConfigPath) {
|
246
260
|
const preferTsNode = process.env.NX_PREFER_TS_NODE === 'true';
|
247
261
|
if (swcNodeInstalled && !preferTsNode) {
|
248
|
-
return
|
262
|
+
return {
|
263
|
+
compilerOptions: readCompilerOptionsWithSwc(tsConfigPath),
|
264
|
+
};
|
249
265
|
}
|
250
266
|
else {
|
251
267
|
return readCompilerOptionsWithTypescript(tsConfigPath);
|
@@ -261,16 +277,14 @@ function readCompilerOptionsWithSwc(tsConfigPath) {
|
|
261
277
|
return compilerOptions;
|
262
278
|
}
|
263
279
|
function readCompilerOptionsWithTypescript(tsConfigPath) {
|
264
|
-
|
265
|
-
ts = require('typescript');
|
266
|
-
}
|
267
|
-
const { readConfigFile, parseJsonConfigFileContent, sys } = ts;
|
268
|
-
const jsonContent = readConfigFile(tsConfigPath, sys.readFile);
|
269
|
-
const { options } = parseJsonConfigFileContent(jsonContent.config, sys, (0, path_1.dirname)(tsConfigPath));
|
280
|
+
const { options, raw } = (0, typescript_1.readTsConfigWithoutFiles)(tsConfigPath);
|
270
281
|
// This property is returned in compiler options for some reason, but not part of the typings.
|
271
282
|
// ts-node fails on unknown props, so we have to remove it.
|
272
283
|
delete options.configFilePath;
|
273
|
-
return
|
284
|
+
return {
|
285
|
+
compilerOptions: options,
|
286
|
+
tsConfigRaw: raw,
|
287
|
+
};
|
274
288
|
}
|
275
289
|
function loadTsConfigPaths() {
|
276
290
|
try {
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import type * as ts from 'typescript';
|
2
2
|
import type { Node, SyntaxKind } from 'typescript';
|
3
|
-
export declare function readTsConfig(tsConfigPath: string): ts.ParsedCommandLine;
|
3
|
+
export declare function readTsConfig(tsConfigPath: string, sys?: ts.System): ts.ParsedCommandLine;
|
4
|
+
export declare function readTsConfigWithoutFiles(tsConfigPath: string): ts.ParsedCommandLine;
|
4
5
|
export declare function readTsConfigOptions(tsConfigPath: string): ts.CompilerOptions;
|
5
6
|
/**
|
6
7
|
* Find a module based on its import
|
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.readTsConfig = readTsConfig;
|
4
|
+
exports.readTsConfigWithoutFiles = readTsConfigWithoutFiles;
|
4
5
|
exports.readTsConfigOptions = readTsConfigOptions;
|
5
6
|
exports.resolveModuleByImport = resolveModuleByImport;
|
6
7
|
exports.getRootTsConfigFileName = getRootTsConfigFileName;
|
@@ -11,25 +12,29 @@ const fs_1 = require("fs");
|
|
11
12
|
const path_1 = require("path");
|
12
13
|
const normalizedAppRoot = workspace_root_1.workspaceRoot.replace(/\\/g, '/');
|
13
14
|
let tsModule;
|
14
|
-
function readTsConfig(tsConfigPath) {
|
15
|
+
function readTsConfig(tsConfigPath, sys) {
|
15
16
|
if (!tsModule) {
|
16
17
|
tsModule = require('typescript');
|
17
18
|
}
|
18
|
-
|
19
|
-
|
19
|
+
sys ??= tsModule.sys;
|
20
|
+
const readResult = tsModule.readConfigFile(tsConfigPath, sys.readFile);
|
21
|
+
return tsModule.parseJsonConfigFileContent(readResult.config, sys, (0, path_1.dirname)(tsConfigPath));
|
20
22
|
}
|
21
|
-
function
|
23
|
+
function readTsConfigWithoutFiles(tsConfigPath) {
|
22
24
|
if (!tsModule) {
|
23
25
|
tsModule = require('typescript');
|
24
26
|
}
|
25
|
-
const readResult = tsModule.readConfigFile(tsConfigPath, tsModule.sys.readFile);
|
26
27
|
// We only care about options, so we don't need to scan source files, and thus
|
27
28
|
// `readDirectory` is stubbed for performance.
|
28
|
-
const
|
29
|
+
const sys = {
|
29
30
|
...tsModule.sys,
|
30
31
|
readDirectory: () => [],
|
31
32
|
};
|
32
|
-
return
|
33
|
+
return readTsConfig(tsConfigPath, sys);
|
34
|
+
}
|
35
|
+
function readTsConfigOptions(tsConfigPath) {
|
36
|
+
const { options } = readTsConfigWithoutFiles(tsConfigPath);
|
37
|
+
return options;
|
33
38
|
}
|
34
39
|
let compilerHost;
|
35
40
|
/**
|
@@ -6,9 +6,9 @@ exports.pluginTranspilerIsRegistered = pluginTranspilerIsRegistered;
|
|
6
6
|
exports.cleanupPluginTSTranspiler = cleanupPluginTSTranspiler;
|
7
7
|
const node_fs_1 = require("node:fs");
|
8
8
|
const posix_1 = require("node:path/posix");
|
9
|
-
const workspace_root_1 = require("../../utils/workspace-root");
|
10
9
|
const register_1 = require("../../plugins/js/utils/register");
|
11
10
|
const typescript_1 = require("../../plugins/js/utils/typescript");
|
11
|
+
const workspace_root_1 = require("../../utils/workspace-root");
|
12
12
|
exports.unregisterPluginTSTranspiler = null;
|
13
13
|
/**
|
14
14
|
* Register swc-node or ts-node if they are not currently registered
|
@@ -23,16 +23,16 @@ function registerPluginTSTranspiler() {
|
|
23
23
|
if (!tsConfigName) {
|
24
24
|
return;
|
25
25
|
}
|
26
|
-
const
|
27
|
-
? (0, typescript_1.
|
26
|
+
const tsConfig = tsConfigName
|
27
|
+
? (0, typescript_1.readTsConfigWithoutFiles)(tsConfigName)
|
28
28
|
: {};
|
29
29
|
const cleanupFns = [
|
30
30
|
(0, register_1.registerTsConfigPaths)(tsConfigName),
|
31
31
|
(0, register_1.registerTranspiler)({
|
32
32
|
experimentalDecorators: true,
|
33
33
|
emitDecoratorMetadata: true,
|
34
|
-
...
|
35
|
-
}),
|
34
|
+
...tsConfig.options,
|
35
|
+
}, tsConfig.raw),
|
36
36
|
];
|
37
37
|
exports.unregisterPluginTSTranspiler = () => {
|
38
38
|
cleanupFns.forEach((fn) => fn?.());
|