@nx/js 21.4.0-beta.1 → 21.4.0-beta.10
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 +4 -4
- package/spec/src/executors/node/lib/detect-module-format.spec.d.ts +2 -0
- package/spec/src/executors/node/lib/detect-module-format.spec.d.ts.map +1 -0
- package/spec/src/executors/node/lib/esm-loader.spec.d.ts +2 -0
- package/spec/src/executors/node/lib/esm-loader.spec.d.ts.map +1 -0
- package/spec/src/executors/release-publish/release-publish.impl.spec.d.ts +2 -0
- package/spec/src/executors/release-publish/release-publish.impl.spec.d.ts.map +1 -0
- package/src/executors/node/lib/detect-module-format.d.ts +10 -0
- package/src/executors/node/lib/detect-module-format.d.ts.map +1 -0
- package/src/executors/node/lib/detect-module-format.js +64 -0
- package/src/executors/node/lib/esm-loader.d.ts +14 -0
- package/src/executors/node/lib/esm-loader.d.ts.map +1 -0
- package/src/executors/node/lib/esm-loader.js +51 -0
- package/src/executors/node/node-with-esm-loader.d.ts +6 -0
- package/src/executors/node/node-with-esm-loader.d.ts.map +1 -0
- package/src/executors/node/node-with-esm-loader.js +25 -0
- package/src/executors/node/node.impl.d.ts.map +1 -1
- package/src/executors/node/node.impl.js +14 -1
- package/src/executors/release-publish/release-publish.impl.js +2 -2
- package/src/generators/library/library.d.ts.map +1 -1
- package/src/generators/library/library.js +2 -0
- package/src/plugins/typescript/util.d.ts.map +1 -1
- package/src/plugins/typescript/util.js +4 -2
- package/src/release/version-actions.d.ts.map +1 -1
- package/src/release/version-actions.js +7 -1
- package/src/utils/typescript/ts-solution-setup.d.ts +1 -0
- package/src/utils/typescript/ts-solution-setup.d.ts.map +1 -1
- package/src/utils/typescript/ts-solution-setup.js +44 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "21.4.0-beta.
|
|
3
|
+
"version": "21.4.0-beta.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ",
|
|
6
6
|
"repository": {
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.23.2",
|
|
40
40
|
"@babel/preset-typescript": "^7.22.5",
|
|
41
41
|
"@babel/runtime": "^7.22.6",
|
|
42
|
-
"@nx/devkit": "21.4.0-beta.
|
|
43
|
-
"@nx/workspace": "21.4.0-beta.
|
|
42
|
+
"@nx/devkit": "21.4.0-beta.10",
|
|
43
|
+
"@nx/workspace": "21.4.0-beta.10",
|
|
44
44
|
"@zkochan/js-yaml": "0.0.7",
|
|
45
45
|
"babel-plugin-const-enum": "^1.0.1",
|
|
46
46
|
"babel-plugin-macros": "^3.1.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"tslib": "^2.3.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"nx": "21.4.0-beta.
|
|
66
|
+
"nx": "21.4.0-beta.10"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
69
|
"verdaccio": "^6.0.5"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-module-format.spec.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/js/src/executors/node/lib/detect-module-format.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esm-loader.spec.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/js/src/executors/node/lib/esm-loader.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release-publish.impl.spec.d.ts","sourceRoot":"","sources":["../../../../../../../packages/js/src/executors/release-publish/release-publish.impl.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ModuleFormat = 'cjs' | 'esm';
|
|
2
|
+
export interface ModuleFormatDetectionOptions {
|
|
3
|
+
projectRoot: string;
|
|
4
|
+
workspaceRoot: string;
|
|
5
|
+
tsConfig?: string;
|
|
6
|
+
main: string;
|
|
7
|
+
buildOptions?: any;
|
|
8
|
+
}
|
|
9
|
+
export declare function detectModuleFormat(options: ModuleFormatDetectionOptions): ModuleFormat;
|
|
10
|
+
//# sourceMappingURL=detect-module-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-module-format.d.ts","sourceRoot":"","sources":["../../../../../../../packages/js/src/executors/node/lib/detect-module-format.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,CAAC;AAEzC,MAAM,WAAW,4BAA4B;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,4BAA4B,GACpC,YAAY,CAiEd"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectModuleFormat = detectModuleFormat;
|
|
4
|
+
const devkit_1 = require("@nx/devkit");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const ts_config_1 = require("../../../utils/typescript/ts-config");
|
|
8
|
+
const ts = require("typescript");
|
|
9
|
+
function detectModuleFormat(options) {
|
|
10
|
+
if (options.buildOptions?.format) {
|
|
11
|
+
const formats = Array.isArray(options.buildOptions.format)
|
|
12
|
+
? options.buildOptions.format
|
|
13
|
+
: [options.buildOptions.format];
|
|
14
|
+
if (formats.includes('esm')) {
|
|
15
|
+
return 'esm';
|
|
16
|
+
}
|
|
17
|
+
if (formats.includes('cjs')) {
|
|
18
|
+
return 'cjs';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if (options.main.endsWith('.mjs')) {
|
|
22
|
+
return 'esm';
|
|
23
|
+
}
|
|
24
|
+
if (options.main.endsWith('.cjs')) {
|
|
25
|
+
return 'cjs';
|
|
26
|
+
}
|
|
27
|
+
const packageJsonPath = (0, path_1.join)(options.workspaceRoot, options.projectRoot, 'package.json');
|
|
28
|
+
if ((0, fs_1.existsSync)(packageJsonPath)) {
|
|
29
|
+
try {
|
|
30
|
+
const packageJson = (0, devkit_1.readJsonFile)(packageJsonPath);
|
|
31
|
+
if (packageJson.type === 'module') {
|
|
32
|
+
return 'esm';
|
|
33
|
+
}
|
|
34
|
+
if (packageJson.type === 'commonjs') {
|
|
35
|
+
return 'cjs';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
// Continue to next detection method
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (options.tsConfig && (0, fs_1.existsSync)(options.tsConfig)) {
|
|
43
|
+
try {
|
|
44
|
+
const tsConfig = (0, ts_config_1.readTsConfig)(options.tsConfig);
|
|
45
|
+
if (tsConfig.options.module === ts.ModuleKind.ES2015 ||
|
|
46
|
+
tsConfig.options.module === ts.ModuleKind.ES2020 ||
|
|
47
|
+
tsConfig.options.module === ts.ModuleKind.ES2022 ||
|
|
48
|
+
tsConfig.options.module === ts.ModuleKind.ESNext ||
|
|
49
|
+
tsConfig.options.module === ts.ModuleKind.NodeNext) {
|
|
50
|
+
// For NodeNext, we need to check moduleResolution
|
|
51
|
+
if (tsConfig.options.module === ts.ModuleKind.NodeNext) {
|
|
52
|
+
// NodeNext uses package.json type field, which we already checked
|
|
53
|
+
// Default to CJS if no type field
|
|
54
|
+
return 'cjs';
|
|
55
|
+
}
|
|
56
|
+
return 'esm';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Continue to default
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return 'cjs';
|
|
64
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom ESM resolver for Node.js that handles Nx workspace library mappings.
|
|
3
|
+
*
|
|
4
|
+
* This resolver is necessary because:
|
|
5
|
+
* 1. Node.js ESM resolution doesn't understand TypeScript path mappings (e.g., @myorg/mylib)
|
|
6
|
+
* 2. Nx workspace libraries need to be resolved to their actual built output locations
|
|
7
|
+
* 3. The built output might be in different formats (.js, .mjs) or locations (index.js)
|
|
8
|
+
*
|
|
9
|
+
* The resolver intercepts import requests for workspace libraries and maps them to their
|
|
10
|
+
* actual file system locations based on the NX_MAPPINGS environment variable set by
|
|
11
|
+
* the Node executor.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolve(specifier: string, context: any, nextResolve: any): Promise<any>;
|
|
14
|
+
//# sourceMappingURL=esm-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esm-loader.d.ts","sourceRoot":"","sources":["../../../../../../../packages/js/src/executors/node/lib/esm-loader.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AACH,wBAAsB,OAAO,CAC3B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,GAAG,EACZ,WAAW,EAAE,GAAG,gBA0CjB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolve = resolve;
|
|
4
|
+
const node_url_1 = require("node:url");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
/**
|
|
8
|
+
* Custom ESM resolver for Node.js that handles Nx workspace library mappings.
|
|
9
|
+
*
|
|
10
|
+
* This resolver is necessary because:
|
|
11
|
+
* 1. Node.js ESM resolution doesn't understand TypeScript path mappings (e.g., @myorg/mylib)
|
|
12
|
+
* 2. Nx workspace libraries need to be resolved to their actual built output locations
|
|
13
|
+
* 3. The built output might be in different formats (.js, .mjs) or locations (index.js)
|
|
14
|
+
*
|
|
15
|
+
* The resolver intercepts import requests for workspace libraries and maps them to their
|
|
16
|
+
* actual file system locations based on the NX_MAPPINGS environment variable set by
|
|
17
|
+
* the Node executor.
|
|
18
|
+
*/
|
|
19
|
+
async function resolve(specifier, context, nextResolve) {
|
|
20
|
+
// Parse mappings on each call to ensure we get the latest values
|
|
21
|
+
const mappings = JSON.parse(process.env.NX_MAPPINGS || '{}');
|
|
22
|
+
const mappingKeys = Object.keys(mappings);
|
|
23
|
+
// Check if this is a workspace library mapping
|
|
24
|
+
const matchingKey = mappingKeys.find((key) => specifier === key || specifier.startsWith(key + '/'));
|
|
25
|
+
if (matchingKey) {
|
|
26
|
+
const mappedPath = mappings[matchingKey];
|
|
27
|
+
const restOfPath = specifier.slice(matchingKey.length);
|
|
28
|
+
const fullPath = (0, node_path_1.join)(mappedPath, restOfPath);
|
|
29
|
+
// Try to resolve the mapped path as a file first
|
|
30
|
+
if ((0, node_fs_1.existsSync)(fullPath)) {
|
|
31
|
+
const stats = (0, node_fs_1.statSync)(fullPath);
|
|
32
|
+
if (stats.isFile()) {
|
|
33
|
+
return nextResolve((0, node_url_1.pathToFileURL)(fullPath).href, context);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Try with index.js
|
|
37
|
+
const indexPath = (0, node_path_1.join)(fullPath, 'index.js');
|
|
38
|
+
if ((0, node_fs_1.existsSync)(indexPath)) {
|
|
39
|
+
return nextResolve((0, node_url_1.pathToFileURL)(indexPath).href, context);
|
|
40
|
+
}
|
|
41
|
+
const jsPath = fullPath + '.js';
|
|
42
|
+
if ((0, node_fs_1.existsSync)(jsPath)) {
|
|
43
|
+
return nextResolve((0, node_url_1.pathToFileURL)(jsPath).href, context);
|
|
44
|
+
}
|
|
45
|
+
const mjsPath = fullPath + '.mjs';
|
|
46
|
+
if ((0, node_fs_1.existsSync)(mjsPath)) {
|
|
47
|
+
return nextResolve((0, node_url_1.pathToFileURL)(mjsPath).href, context);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return nextResolve(specifier, context);
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-with-esm-loader.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/node-with-esm-loader.ts"],"names":[],"mappings":"AAAA,QAAA,MAAQ,aAAa,KAAwB,CAAC;AAC9C,QAAA,MAAQ,QAAQ,KAA2B,CAAC;AAC5C,QAAA,MAAM,IAAI,KAAuB,CAAC;AAGlC,QAAA,MAAM,gBAAgB,UAAwD,CAAC;AAE/E,iBAAe,IAAI,kBAkBlB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const { pathToFileURL } = require('node:url');
|
|
2
|
+
const { register } = require('node:module');
|
|
3
|
+
const path = require('node:path');
|
|
4
|
+
// Dynamic import helper to prevent TypeScript from transforming it
|
|
5
|
+
const dynamicImportEsm = new Function('specifier', 'return import(specifier)');
|
|
6
|
+
async function main() {
|
|
7
|
+
try {
|
|
8
|
+
// Register ESM loader for workspace path mappings
|
|
9
|
+
register(path.join(__dirname, 'lib', 'esm-loader.js'), pathToFileURL(__filename));
|
|
10
|
+
// Import and run the file
|
|
11
|
+
const fileToRun = process.env.NX_FILE_TO_RUN;
|
|
12
|
+
if (!fileToRun) {
|
|
13
|
+
throw new Error('NX_FILE_TO_RUN environment variable not set');
|
|
14
|
+
}
|
|
15
|
+
await dynamicImportEsm(pathToFileURL(fileToRun).href);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
console.error('ESM loader error:', error);
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
main().catch((error) => {
|
|
23
|
+
console.error(error);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/node.impl.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAQhB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAe,mBAAmB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"node.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/node.impl.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAQhB,MAAM,YAAY,CAAC;AAOpB,OAAO,EAAe,mBAAmB,EAAE,MAAM,UAAU,CAAC;AA6C5D,wBAAuB,YAAY,CACjC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe;aAgEb,OAAO;cACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;cA4NhC;AA+HD,eAAe,YAAY,CAAC"}
|
|
@@ -14,6 +14,7 @@ const kill_tree_1 = require("./lib/kill-tree");
|
|
|
14
14
|
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
15
15
|
const get_main_file_dir_1 = require("../../utils/get-main-file-dir");
|
|
16
16
|
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
17
|
+
const detect_module_format_1 = require("./lib/detect-module-format");
|
|
17
18
|
function debounce(fn, wait) {
|
|
18
19
|
let timeoutId;
|
|
19
20
|
let pendingPromise = null;
|
|
@@ -67,6 +68,15 @@ async function* nodeExecutor(options, context) {
|
|
|
67
68
|
// Re-map buildable workspace projects to their output directory.
|
|
68
69
|
const mappings = calculateResolveMappings(context, options);
|
|
69
70
|
const fileToRun = getFileToRun(context, project, buildOptions, buildTargetExecutor);
|
|
71
|
+
// Detect module format for the project
|
|
72
|
+
const moduleFormat = (0, detect_module_format_1.detectModuleFormat)({
|
|
73
|
+
projectRoot: project.data.root,
|
|
74
|
+
workspaceRoot: context.root,
|
|
75
|
+
tsConfig: buildOptions.tsConfig ||
|
|
76
|
+
(0, path_1.join)(context.root, project.data.root, 'tsconfig.json'),
|
|
77
|
+
main: buildOptions.main || fileToRun,
|
|
78
|
+
buildOptions,
|
|
79
|
+
});
|
|
70
80
|
let additionalExitHandler = null;
|
|
71
81
|
let currentTask = null;
|
|
72
82
|
const tasks = [];
|
|
@@ -108,7 +118,10 @@ async function* nodeExecutor(options, context) {
|
|
|
108
118
|
return;
|
|
109
119
|
// Run the program
|
|
110
120
|
task.promise = new Promise((resolve, reject) => {
|
|
111
|
-
|
|
121
|
+
const loaderFile = moduleFormat === 'esm'
|
|
122
|
+
? 'node-with-esm-loader'
|
|
123
|
+
: 'node-with-require-overrides';
|
|
124
|
+
task.childProcess = (0, child_process_1.fork)((0, devkit_1.joinPathFragments)(__dirname, loaderFile), options.args ?? [], {
|
|
112
125
|
execArgv: getExecArgv(options),
|
|
113
126
|
stdio: [0, 1, 'pipe', 'ipc'],
|
|
114
127
|
env: {
|
|
@@ -155,10 +155,10 @@ Please update the local dependency on "${depName}" to be a valid semantic versio
|
|
|
155
155
|
!(err.stderr?.toString().includes('E404') &&
|
|
156
156
|
err.stderr?.toString().includes('no such package available'))) {
|
|
157
157
|
console.error('npm dist-tag add error:');
|
|
158
|
-
if (stdoutData.error
|
|
158
|
+
if (stdoutData.error?.summary) {
|
|
159
159
|
console.error(stdoutData.error.summary);
|
|
160
160
|
}
|
|
161
|
-
if (stdoutData.error
|
|
161
|
+
if (stdoutData.error?.detail) {
|
|
162
162
|
console.error(stdoutData.error.detail);
|
|
163
163
|
}
|
|
164
164
|
if (context.isVerbose) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAYjB,IAAI,EAKL,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,iBAAiB,EAYjB,IAAI,EAKL,MAAM,YAAY,CAAC;AAyCpB,OAAO,KAAK,EAEV,sBAAsB,EACtB,iCAAiC,EAClC,MAAM,UAAU,CAAC;AASlB,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAO/B;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,sBAAsB,8BAsL/B;AA4HD,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,iCAAiC,EAC/B,MAAM,GACN,QAAQ,GACR,aAAa,GACb,gBAAgB,GAChB,IAAI,GACJ,yBAAyB,GACzB,aAAa,GACb,SAAS,GACT,WAAW,CACd,CAAC;AAEF,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAqG5B;AA4vBD,eAAe,gBAAgB,CAAC"}
|
|
@@ -34,11 +34,13 @@ async function libraryGenerator(tree, schema) {
|
|
|
34
34
|
}
|
|
35
35
|
async function libraryGeneratorInternal(tree, schema) {
|
|
36
36
|
const tasks = [];
|
|
37
|
+
const addTsPlugin = (0, ts_solution_setup_1.shouldConfigureTsSolutionSetup)(tree, schema.addPlugin);
|
|
37
38
|
tasks.push(await (0, init_1.default)(tree, {
|
|
38
39
|
...schema,
|
|
39
40
|
skipFormat: true,
|
|
40
41
|
tsConfigName: schema.rootProject ? 'tsconfig.json' : 'tsconfig.base.json',
|
|
41
42
|
addTsConfigBase: true,
|
|
43
|
+
addTsPlugin,
|
|
42
44
|
// In the new setup, Prettier is prompted for and installed during `create-nx-workspace`.
|
|
43
45
|
formatter: (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree) ? 'none' : 'prettier',
|
|
44
46
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/plugins/typescript/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGpE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGpD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,iBAAiB,EACjB,SAAS,GAAG,mBAAmB,GAAG,KAAK,CACxC,GAAG;IACF,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC5C,OAAO,EAAE;IAAE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAAC,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAAE,EACvE,GAAG,EAAE,sBAAsB,GAC1B,IAAI,CA2BN;AAED,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,kBAAkB,EAC5B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/plugins/typescript/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGpE,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGpD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,iBAAiB,EACjB,SAAS,GAAG,mBAAmB,GAAG,KAAK,CACxC,GAAG;IACF,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC5C,OAAO,EAAE;IAAE,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAAC,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAAE,EACvE,GAAG,EAAE,sBAAsB,GAC1B,IAAI,CA2BN;AAED,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,kBAAkB,EAC5B,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAClB,OAAO,CAqLT"}
|
|
@@ -77,7 +77,7 @@ function isValidPackageJsonBuildConfig(tsConfig, workspaceRoot, projectRoot) {
|
|
|
77
77
|
}
|
|
78
78
|
else if (typeof dotExport === 'object') {
|
|
79
79
|
const hasMatch = Object.entries(dotExport).some(([key, value]) => {
|
|
80
|
-
if (key === 'types' || key === 'development')
|
|
80
|
+
if (key === 'types' || key === 'development' || key.startsWith('@'))
|
|
81
81
|
return false;
|
|
82
82
|
return typeof value === 'string' && isPathSourceFile(value);
|
|
83
83
|
});
|
|
@@ -146,7 +146,9 @@ function isValidPackageJsonBuildConfig(tsConfig, workspaceRoot, projectRoot) {
|
|
|
146
146
|
else if (typeof value === 'object') {
|
|
147
147
|
return Object.entries(value).some(([currentKey, subValue]) => {
|
|
148
148
|
// Skip types and development conditions
|
|
149
|
-
if (currentKey === 'types' ||
|
|
149
|
+
if (currentKey === 'types' ||
|
|
150
|
+
currentKey === 'development' ||
|
|
151
|
+
currentKey.startsWith('@')) {
|
|
150
152
|
return false;
|
|
151
153
|
}
|
|
152
154
|
if (typeof subValue === 'string') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-actions.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/release/version-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAEZ,IAAI,EAGL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAK3E,eAAO,MAAM,yBAAyB,EAAE,yBAmBvC,CAAC;AAKF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,sBAAsB,WAAoB;IAEpC,oCAAoC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;QAC9D,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IAkBI,8BAA8B,CAClC,IAAI,EAAE,IAAI,EACV,8BAA8B,EAAE,6BAA6B,CAAC,gCAAgC,CAAC,GAC9F,OAAO,CAAC;QACT,cAAc,EAAE,MAAM,CAAC;QACvB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;
|
|
1
|
+
{"version":3,"file":"version-actions.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/release/version-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAEZ,IAAI,EAGL,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAK3E,eAAO,MAAM,yBAAyB,EAAE,yBAmBvC,CAAC;AAKF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,cAAc;IAC1D,sBAAsB,WAAoB;IAEpC,oCAAoC,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;QAC9D,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IAkBI,8BAA8B,CAClC,IAAI,EAAE,IAAI,EACV,8BAA8B,EAAE,6BAA6B,CAAC,gCAAgC,CAAC,GAC9F,OAAO,CAAC;QACT,cAAc,EAAE,MAAM,CAAC;QACvB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IAkEI,8BAA8B,CAClC,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,qBAAqB,EAAE,MAAM,GAC5B,OAAO,CAAC;QACT,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;KACrC,CAAC;IA+BI,oBAAoB,CACxB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC;IAcd,yBAAyB,CAC7B,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,YAAY,EAC1B,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3C,OAAO,CAAC,MAAM,EAAE,CAAC;IA+DpB,OAAO,CAAC,yBAAyB;CAyClC"}
|
|
@@ -66,7 +66,13 @@ class JsVersionActions extends release_1.VersionActions {
|
|
|
66
66
|
if (error) {
|
|
67
67
|
return reject(error);
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
// Only reject on stderr if it contains actual errors, not just npm warnings
|
|
70
|
+
// npm 11+ writes "npm warn" messages to stderr even on successful commands
|
|
71
|
+
if (stderr &&
|
|
72
|
+
!stderr
|
|
73
|
+
.trim()
|
|
74
|
+
.split('\n')
|
|
75
|
+
.every((line) => line.startsWith('npm warn'))) {
|
|
70
76
|
return reject(stderr);
|
|
71
77
|
}
|
|
72
78
|
return resolve(stdout.trim());
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ProjectConfiguration, type Tree } from '@nx/devkit';
|
|
2
2
|
export declare function isUsingTypeScriptPlugin(tree: Tree): boolean;
|
|
3
|
+
export declare function shouldConfigureTsSolutionSetup(tree: Tree, addPlugins: boolean, addTsPlugin?: boolean): boolean;
|
|
3
4
|
export declare function isUsingTsSolutionSetup(tree?: Tree): boolean;
|
|
4
5
|
export declare function assertNotUsingTsSolutionSetup(tree: Tree, pluginName: string, generatorName: string): void;
|
|
5
6
|
export declare function findRuntimeTsConfigName(projectRoot: string, tree?: Tree): string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ts-solution-setup.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/ts-solution-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,oBAAoB,EAGzB,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAWpB,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAU3D;AAED,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAO3D;
|
|
1
|
+
{"version":3,"file":"ts-solution-setup.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/ts-solution-setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,oBAAoB,EAGzB,KAAK,IAAI,EAGV,MAAM,YAAY,CAAC;AAWpB,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAU3D;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,OAAO,EACnB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAsBT;AAED,wBAAgB,sBAAsB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAO3D;AAuDD,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,GACpB,IAAI,CAsBN;AAED,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE,IAAI,GACV,MAAM,GAAG,IAAI,CAOf;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,uBAAuB,EAAE,MAAM,EAC/B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC,EAC5D,OAAO,GAAE,MAAM,EAAO,EACtB,OAAO,SAAQ,QAoFhB;AAED,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,MAAM,iBAqDnB;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,IAAI,EACV,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,SAAS,GAAG,aAAa,GACtC,SAAS,GAAG,aAAa,CAoB3B;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,oBAAoB,EAC7B,IAAI,CAAC,EAAE,IAAI,GACV,MAAM,CAgBR"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isUsingTypeScriptPlugin = isUsingTypeScriptPlugin;
|
|
4
|
+
exports.shouldConfigureTsSolutionSetup = shouldConfigureTsSolutionSetup;
|
|
4
5
|
exports.isUsingTsSolutionSetup = isUsingTsSolutionSetup;
|
|
5
6
|
exports.assertNotUsingTsSolutionSetup = assertNotUsingTsSolutionSetup;
|
|
6
7
|
exports.findRuntimeTsConfigName = findRuntimeTsConfigName;
|
|
@@ -20,11 +21,39 @@ function isUsingTypeScriptPlugin(tree) {
|
|
|
20
21
|
? p === '@nx/js/typescript'
|
|
21
22
|
: p.plugin === '@nx/js/typescript') ?? false);
|
|
22
23
|
}
|
|
24
|
+
function shouldConfigureTsSolutionSetup(tree, addPlugins, addTsPlugin) {
|
|
25
|
+
if (addTsPlugin !== undefined) {
|
|
26
|
+
return addTsPlugin;
|
|
27
|
+
}
|
|
28
|
+
if (addPlugins === undefined) {
|
|
29
|
+
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
30
|
+
addPlugins =
|
|
31
|
+
process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
32
|
+
nxJson.useInferencePlugins !== false;
|
|
33
|
+
}
|
|
34
|
+
if (!addPlugins) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (!(0, package_manager_workspaces_1.isUsingPackageManagerWorkspaces)(tree)) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
// if there are no root tsconfig files, we should configure the TS solution setup
|
|
41
|
+
return !tree.exists('tsconfig.base.json') && !tree.exists('tsconfig.json');
|
|
42
|
+
}
|
|
23
43
|
function isUsingTsSolutionSetup(tree) {
|
|
24
44
|
tree ??= new tree_1.FsTree(devkit_1.workspaceRoot, false);
|
|
25
45
|
return ((0, package_manager_workspaces_1.isUsingPackageManagerWorkspaces)(tree) &&
|
|
26
46
|
isWorkspaceSetupWithTsSolution(tree));
|
|
27
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* The TS solution setup requires:
|
|
50
|
+
* - `tsconfig.base.json`: TS config with common compiler options needed by the
|
|
51
|
+
* majority of projects in the workspace. It's meant to be extended by other
|
|
52
|
+
* tsconfig files in the workspace to reuse them.
|
|
53
|
+
* - `tsconfig.json`: TS solution config file that references all other projects
|
|
54
|
+
* in the repo. It shouldn't include any file and it's not meant to be
|
|
55
|
+
* extended or define any common compiler options.
|
|
56
|
+
*/
|
|
28
57
|
function isWorkspaceSetupWithTsSolution(tree) {
|
|
29
58
|
if (!tree.exists('tsconfig.base.json') || !tree.exists('tsconfig.json')) {
|
|
30
59
|
return false;
|
|
@@ -34,27 +63,30 @@ function isWorkspaceSetupWithTsSolution(tree) {
|
|
|
34
63
|
return false;
|
|
35
64
|
}
|
|
36
65
|
/**
|
|
37
|
-
*
|
|
38
|
-
* - `files`
|
|
39
|
-
* -
|
|
40
|
-
*
|
|
66
|
+
* TS solution setup requires:
|
|
67
|
+
* - One of `files` or `include` defined
|
|
68
|
+
* - If set, they must be empty arrays
|
|
69
|
+
*
|
|
70
|
+
* Note: while the TS solution setup uses TS project references, in the initial
|
|
71
|
+
* state of the workspace, where there are no projects, `references` is not
|
|
72
|
+
* required to be defined.
|
|
41
73
|
*/
|
|
42
|
-
if (!tsconfigJson.files ||
|
|
43
|
-
tsconfigJson.files
|
|
44
|
-
|
|
45
|
-
!!tsconfigJson.include?.length) {
|
|
74
|
+
if ((!tsconfigJson.files && !tsconfigJson.include) ||
|
|
75
|
+
tsconfigJson.files?.length > 0 ||
|
|
76
|
+
tsconfigJson.include?.length > 0) {
|
|
46
77
|
return false;
|
|
47
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* TS solution setup requires:
|
|
81
|
+
* - `compilerOptions.composite`: true
|
|
82
|
+
* - `compilerOptions.declaration`: true or not set (default to true)
|
|
83
|
+
*/
|
|
48
84
|
const baseTsconfigJson = (0, devkit_1.readJson)(tree, 'tsconfig.base.json');
|
|
49
85
|
if (!baseTsconfigJson.compilerOptions ||
|
|
50
86
|
!baseTsconfigJson.compilerOptions.composite ||
|
|
51
87
|
baseTsconfigJson.compilerOptions.declaration === false) {
|
|
52
88
|
return false;
|
|
53
89
|
}
|
|
54
|
-
const { compilerOptions, ...rest } = baseTsconfigJson;
|
|
55
|
-
if (Object.keys(rest).length > 0) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
90
|
return true;
|
|
59
91
|
}
|
|
60
92
|
function assertNotUsingTsSolutionSetup(tree, pluginName, generatorName) {
|