@nx/js 21.4.0-beta.0 → 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/generators/typescript-sync/typescript-sync.d.ts.map +1 -1
- package/src/generators/typescript-sync/typescript-sync.js +44 -33
- 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/assets/copy-assets-handler.d.ts.map +1 -1
- package/src/utils/assets/copy-assets-handler.js +9 -2
- 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 +50 -14
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":"typescript-sync.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/typescript-sync/typescript-sync.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"typescript-sync.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/typescript-sync/typescript-sync.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAIpB,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,8BAA8B,CAAC;AAuCtC,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAgO5E;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -22,7 +22,6 @@ async function syncGenerator(tree) {
|
|
|
22
22
|
composite: new Map(),
|
|
23
23
|
content: new Map(),
|
|
24
24
|
exists: new Map(),
|
|
25
|
-
isFile: new Map(),
|
|
26
25
|
};
|
|
27
26
|
// Root tsconfig containing project references for the whole workspace
|
|
28
27
|
const rootTsconfigPath = 'tsconfig.json';
|
|
@@ -63,18 +62,18 @@ async function syncGenerator(tree) {
|
|
|
63
62
|
// made by this generator to know if the TS config is out of sync with the
|
|
64
63
|
// project graph. Therefore, we don't format the files if there were no changes
|
|
65
64
|
// to avoid potential format-only changes that can lead to false positives.
|
|
66
|
-
|
|
65
|
+
const changedFiles = new Map();
|
|
67
66
|
if (tsconfigProjectNodeValues.length > 0) {
|
|
68
67
|
const referencesSet = new Set();
|
|
69
68
|
for (const ref of rootTsconfig.references ?? []) {
|
|
70
69
|
// reference path is relative to the tsconfig file
|
|
71
|
-
const resolvedRefPath = getTsConfigPathFromReferencePath(
|
|
70
|
+
const resolvedRefPath = getTsConfigPathFromReferencePath(rootTsconfigPath, ref.path);
|
|
72
71
|
if (tsconfigExists(tree, tsconfigInfoCaches, resolvedRefPath)) {
|
|
73
72
|
// we only keep the references that still exist
|
|
74
73
|
referencesSet.add(normalizeReferencePath(ref.path));
|
|
75
74
|
}
|
|
76
75
|
else {
|
|
77
|
-
|
|
76
|
+
addChangedFile(changedFiles, rootTsconfigPath, resolvedRefPath, 'stale');
|
|
78
77
|
}
|
|
79
78
|
}
|
|
80
79
|
for (const node of tsconfigProjectNodeValues) {
|
|
@@ -82,10 +81,10 @@ async function syncGenerator(tree) {
|
|
|
82
81
|
// Skip the root tsconfig itself
|
|
83
82
|
if (node.data.root !== '.' && !referencesSet.has(normalizedPath)) {
|
|
84
83
|
referencesSet.add(normalizedPath);
|
|
85
|
-
|
|
84
|
+
addChangedFile(changedFiles, rootTsconfigPath, toFullProjectReferencePath(node.data.root), 'missing');
|
|
86
85
|
}
|
|
87
86
|
}
|
|
88
|
-
if (
|
|
87
|
+
if (changedFiles.size > 0) {
|
|
89
88
|
const updatedReferences = Array.from(referencesSet)
|
|
90
89
|
// Check composite is true in the internal reference before proceeding
|
|
91
90
|
.filter((ref) => hasCompositeEnabled(tsSysFromTree, tsconfigInfoCaches, (0, devkit_1.joinPathFragments)(ref, 'tsconfig.json')))
|
|
@@ -101,7 +100,7 @@ async function syncGenerator(tree) {
|
|
|
101
100
|
COMMON_RUNTIME_TS_CONFIG_FILE_NAMES,
|
|
102
101
|
};
|
|
103
102
|
const collectedDependencies = new Map();
|
|
104
|
-
for (const
|
|
103
|
+
for (const projectName of Object.keys(projectGraph.dependencies)) {
|
|
105
104
|
if (!projectGraph.nodes[projectName] ||
|
|
106
105
|
projectGraph.nodes[projectName].data.root === '.') {
|
|
107
106
|
continue;
|
|
@@ -124,17 +123,26 @@ async function syncGenerator(tree) {
|
|
|
124
123
|
continue;
|
|
125
124
|
}
|
|
126
125
|
// Update project references for the runtime tsconfig
|
|
127
|
-
|
|
128
|
-
updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, runtimeTsConfigPath, dependencies, sourceProjectNode.data.root, projectRoots, runtimeTsConfigFileName, runtimeTsConfigFileNames) || hasChanges;
|
|
126
|
+
updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, runtimeTsConfigPath, dependencies, sourceProjectNode.data.root, projectRoots, changedFiles, runtimeTsConfigFileName, runtimeTsConfigFileNames);
|
|
129
127
|
}
|
|
130
128
|
// Update project references for the tsconfig.json file
|
|
131
|
-
|
|
132
|
-
updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, sourceProjectTsconfigPath, dependencies, sourceProjectNode.data.root, projectRoots) || hasChanges;
|
|
129
|
+
updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, sourceProjectTsconfigPath, dependencies, sourceProjectNode.data.root, projectRoots, changedFiles);
|
|
133
130
|
}
|
|
134
|
-
if (
|
|
131
|
+
if (changedFiles.size > 0) {
|
|
135
132
|
await (0, devkit_1.formatFiles)(tree);
|
|
133
|
+
const outOfSyncDetails = [];
|
|
134
|
+
for (const [filePath, details] of changedFiles) {
|
|
135
|
+
outOfSyncDetails.push(`${filePath}:`);
|
|
136
|
+
if (details.missing.size > 0) {
|
|
137
|
+
outOfSyncDetails.push(` - Missing references: ${Array.from(details.missing).join(', ')}`);
|
|
138
|
+
}
|
|
139
|
+
if (details.stale.size > 0) {
|
|
140
|
+
outOfSyncDetails.push(` - Stale references: ${Array.from(details.stale).join(', ')}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
136
143
|
return {
|
|
137
|
-
outOfSyncMessage: 'Some TypeScript configuration files are missing project references to the projects they depend on or contain
|
|
144
|
+
outOfSyncMessage: 'Some TypeScript configuration files are missing project references to the projects they depend on or contain stale project references.',
|
|
145
|
+
outOfSyncDetails,
|
|
138
146
|
};
|
|
139
147
|
}
|
|
140
148
|
}
|
|
@@ -159,7 +167,7 @@ function tsconfigExists(tree, tsconfigInfoCaches, tsconfigPath) {
|
|
|
159
167
|
}
|
|
160
168
|
return tsconfigInfoCaches.exists.get(tsconfigPath);
|
|
161
169
|
}
|
|
162
|
-
function updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, tsConfigPath, dependencies, projectRoot, projectRoots, runtimeTsConfigFileName, possibleRuntimeTsConfigFileNames) {
|
|
170
|
+
function updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, tsConfigPath, dependencies, projectRoot, projectRoots, changedFiles, runtimeTsConfigFileName, possibleRuntimeTsConfigFileNames) {
|
|
163
171
|
const stringifiedJsonContents = readRawTsconfigContents(tree, tsconfigInfoCaches, tsConfigPath);
|
|
164
172
|
const tsConfig = (0, devkit_1.parseJson)(stringifiedJsonContents);
|
|
165
173
|
const ignoredReferences = new Set(tsConfig.nx?.sync?.ignoredReferences ?? []);
|
|
@@ -177,13 +185,16 @@ function updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, tsCon
|
|
|
177
185
|
continue;
|
|
178
186
|
}
|
|
179
187
|
// reference path is relative to the tsconfig file
|
|
180
|
-
const resolvedRefPath = getTsConfigPathFromReferencePath(
|
|
181
|
-
if (isProjectReferenceWithinNxProject(
|
|
188
|
+
const resolvedRefPath = getTsConfigPathFromReferencePath(tsConfigPath, ref.path);
|
|
189
|
+
if (isProjectReferenceWithinNxProject(resolvedRefPath, projectRoot, projectRoots) ||
|
|
182
190
|
isProjectReferenceIgnored(tree, resolvedRefPath)) {
|
|
183
191
|
// we keep all references within the current Nx project or that are ignored
|
|
184
192
|
references.push(ref);
|
|
185
193
|
newReferencesSet.add(normalizedPath);
|
|
186
194
|
}
|
|
195
|
+
if (!newReferencesSet.has(normalizedPath)) {
|
|
196
|
+
addChangedFile(changedFiles, tsConfigPath, resolvedRefPath, 'stale');
|
|
197
|
+
}
|
|
187
198
|
}
|
|
188
199
|
let hasChanges = false;
|
|
189
200
|
for (const dep of dependencies) {
|
|
@@ -238,13 +249,13 @@ function updateTsConfigReferences(tree, tsSysFromTree, tsconfigInfoCaches, tsCon
|
|
|
238
249
|
}
|
|
239
250
|
if (!originalReferencesSet.has(relativePathToTargetRoot)) {
|
|
240
251
|
hasChanges = true;
|
|
252
|
+
addChangedFile(changedFiles, tsConfigPath, toFullProjectReferencePath(referencePath), 'missing');
|
|
241
253
|
}
|
|
242
254
|
}
|
|
243
255
|
hasChanges ||= newReferencesSet.size !== originalReferencesSet.size;
|
|
244
256
|
if (hasChanges) {
|
|
245
257
|
patchTsconfigJsonReferences(tree, tsconfigInfoCaches, tsConfigPath, references);
|
|
246
258
|
}
|
|
247
|
-
return hasChanges;
|
|
248
259
|
}
|
|
249
260
|
// TODO(leo): follow up with the TypeScript team to confirm if we really need
|
|
250
261
|
// to reference transitive dependencies.
|
|
@@ -288,8 +299,14 @@ function normalizeReferencePath(path) {
|
|
|
288
299
|
.replace(/\/tsconfig.json$/, '')
|
|
289
300
|
.replace(/^\.\//, '');
|
|
290
301
|
}
|
|
291
|
-
function
|
|
292
|
-
|
|
302
|
+
function toFullProjectReferencePath(path) {
|
|
303
|
+
const normalizedPath = normalizeReferencePath(path);
|
|
304
|
+
return normalizedPath.endsWith('.json')
|
|
305
|
+
? normalizedPath
|
|
306
|
+
: (0, devkit_1.joinPathFragments)(normalizedPath, 'tsconfig.json');
|
|
307
|
+
}
|
|
308
|
+
function isProjectReferenceWithinNxProject(refTsConfigPath, projectRoot, projectRoots) {
|
|
309
|
+
let currentPath = getTsConfigDirName(refTsConfigPath);
|
|
293
310
|
if ((0, posix_1.relative)(projectRoot, currentPath).startsWith('..')) {
|
|
294
311
|
// it's outside of the project root, so it's an external project reference
|
|
295
312
|
return false;
|
|
@@ -315,14 +332,14 @@ function isProjectReferenceIgnored(tree, refTsConfigPath) {
|
|
|
315
332
|
}
|
|
316
333
|
return ig.ignores(refTsConfigPath);
|
|
317
334
|
}
|
|
318
|
-
function getTsConfigDirName(
|
|
319
|
-
return
|
|
335
|
+
function getTsConfigDirName(tsConfigPath) {
|
|
336
|
+
return tsConfigPath.endsWith('.json')
|
|
320
337
|
? (0, posix_1.dirname)(tsConfigPath)
|
|
321
338
|
: (0, posix_1.normalize)(tsConfigPath);
|
|
322
339
|
}
|
|
323
|
-
function getTsConfigPathFromReferencePath(
|
|
340
|
+
function getTsConfigPathFromReferencePath(ownerTsConfigPath, referencePath) {
|
|
324
341
|
const resolvedRefPath = (0, devkit_1.joinPathFragments)((0, posix_1.dirname)(ownerTsConfigPath), referencePath);
|
|
325
|
-
return
|
|
342
|
+
return resolvedRefPath.endsWith('.json')
|
|
326
343
|
? resolvedRefPath
|
|
327
344
|
: (0, devkit_1.joinPathFragments)(resolvedRefPath, 'tsconfig.json');
|
|
328
345
|
}
|
|
@@ -344,15 +361,9 @@ function hasCompositeEnabled(tsSysFromTree, tsconfigInfoCaches, tsconfigPath) {
|
|
|
344
361
|
}
|
|
345
362
|
return tsconfigInfoCaches.composite.get(tsconfigPath);
|
|
346
363
|
}
|
|
347
|
-
function
|
|
348
|
-
if (
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
if (tsconfigInfoCaches.content.has(tsconfigPath)) {
|
|
352
|
-
// if it has content, it's a file
|
|
353
|
-
tsconfigInfoCaches.isFile.set(tsconfigPath, true);
|
|
354
|
-
return true;
|
|
364
|
+
function addChangedFile(changedFiles, filePath, referencePath, type) {
|
|
365
|
+
if (!changedFiles.has(filePath)) {
|
|
366
|
+
changedFiles.set(filePath, { missing: new Set(), stale: new Set() });
|
|
355
367
|
}
|
|
356
|
-
|
|
357
|
-
return tsconfigInfoCaches.isFile.get(tsconfigPath);
|
|
368
|
+
changedFiles.get(filePath)[type].add(referencePath);
|
|
358
369
|
}
|
|
@@ -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;I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B,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,OAA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,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-assets-handler.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/assets/copy-assets-handler.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,WAAW,EAAgB,MAAM,6BAA6B,CAAC;AAGxE,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAE3D,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,GAAG,EAAE,MAAM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AAC,EAAE,CAAC;IAC/B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;CAC1C;AAUD,eAAO,MAAM,uBAAuB,GAAI,QAAQ,SAAS,EAAE,SAiB1D,CAAC;AAEF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAe;IAC1C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4B;IACnD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgC;gBAE7C,IAAI,EAAE,uBAAuB;IAuDnC,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAmB3C,wBAAwB,IAAI,IAAI;IAgB1B,4BAA4B,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC;IAqBnD,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAgC9D,OAAO,CAAC,YAAY;IAkBpB,OAAO,CAAC,qBAAqB;CAG9B"}
|
|
@@ -41,10 +41,12 @@ class CopyAssetsHandler {
|
|
|
41
41
|
this.ignore = (0, ignore_1.default)();
|
|
42
42
|
const gitignore = pathPosix.join(opts.rootDir, '.gitignore');
|
|
43
43
|
const nxignore = pathPosix.join(opts.rootDir, '.nxignore');
|
|
44
|
-
if ((0, node_fs_1.existsSync)(gitignore))
|
|
44
|
+
if ((0, node_fs_1.existsSync)(gitignore)) {
|
|
45
45
|
this.ignore.add((0, node_fs_1.readFileSync)(gitignore).toString());
|
|
46
|
-
|
|
46
|
+
}
|
|
47
|
+
if ((0, node_fs_1.existsSync)(nxignore)) {
|
|
47
48
|
this.ignore.add((0, node_fs_1.readFileSync)(nxignore).toString());
|
|
49
|
+
}
|
|
48
50
|
this.assetGlobs = opts.assets.map((f) => {
|
|
49
51
|
let isGlob = false;
|
|
50
52
|
let pattern;
|
|
@@ -85,6 +87,8 @@ class CopyAssetsHandler {
|
|
|
85
87
|
cwd: this.rootDir,
|
|
86
88
|
dot: true, // enable hidden files
|
|
87
89
|
expandDirectories: false,
|
|
90
|
+
// Ignore common directories that should not be copied or processed
|
|
91
|
+
ignore: ['**/node_modules/**', '**/.git/**'],
|
|
88
92
|
});
|
|
89
93
|
this.callback(this.filesToEvent(files, ag));
|
|
90
94
|
}));
|
|
@@ -97,6 +101,7 @@ class CopyAssetsHandler {
|
|
|
97
101
|
cwd: this.rootDir,
|
|
98
102
|
dot: true, // enable hidden files
|
|
99
103
|
expandDirectories: false,
|
|
104
|
+
ignore: ['**/node_modules/**', '**/.git/**'],
|
|
100
105
|
});
|
|
101
106
|
this.callback(this.filesToEvent(files, ag));
|
|
102
107
|
});
|
|
@@ -120,6 +125,8 @@ class CopyAssetsHandler {
|
|
|
120
125
|
return () => unregisterFileWatcher();
|
|
121
126
|
}
|
|
122
127
|
async processWatchEvents(events) {
|
|
128
|
+
if (events.length === 0)
|
|
129
|
+
return;
|
|
123
130
|
const fileEvents = [];
|
|
124
131
|
for (const event of events) {
|
|
125
132
|
const pathFromRoot = event.path.startsWith(this.rootDir)
|
|
@@ -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) {
|
|
@@ -198,13 +230,17 @@ function getProjectType(tree, projectRoot, projectType) {
|
|
|
198
230
|
return 'library';
|
|
199
231
|
if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.app.json')))
|
|
200
232
|
return 'application';
|
|
201
|
-
// If
|
|
233
|
+
// If it doesn't have any common library entry points, assume it is an application
|
|
202
234
|
const packageJsonPath = (0, devkit_1.joinPathFragments)(projectRoot, 'package.json');
|
|
203
235
|
const packageJson = tree.exists(packageJsonPath)
|
|
204
236
|
? (0, devkit_1.readJson)(tree, (0, devkit_1.joinPathFragments)(projectRoot, 'package.json'))
|
|
205
237
|
: null;
|
|
206
|
-
if (!packageJson?.exports
|
|
238
|
+
if (!packageJson?.exports &&
|
|
239
|
+
!packageJson?.main &&
|
|
240
|
+
!packageJson?.module &&
|
|
241
|
+
!packageJson?.bin) {
|
|
207
242
|
return 'application';
|
|
243
|
+
}
|
|
208
244
|
return 'library';
|
|
209
245
|
}
|
|
210
246
|
function getProjectSourceRoot(project, tree) {
|