@nx/js 23.0.0-beta.0 → 23.0.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 +7 -7
- package/src/executors/copy-workspace-modules/copy-workspace-modules.d.ts.map +1 -1
- package/src/executors/copy-workspace-modules/copy-workspace-modules.js +2 -0
- package/src/executors/node/node.impl.d.ts.map +1 -1
- package/src/executors/node/node.impl.js +5 -13
- package/src/executors/prune-lockfile/prune-lockfile.d.ts.map +1 -1
- package/src/executors/prune-lockfile/prune-lockfile.js +2 -0
- package/src/executors/tsc/lib/typescript-compilation.js +2 -2
- package/src/executors/tsc/tsc.impl.d.ts +1 -1
- package/src/executors/tsc/tsc.impl.d.ts.map +1 -1
- package/src/generators/init/init.d.ts.map +1 -1
- package/src/generators/init/init.js +7 -8
- package/src/generators/library/library.d.ts.map +1 -1
- package/src/generators/library/library.js +13 -11
- package/src/generators/library/schema.d.ts +1 -1
- package/src/generators/setup-build/generator.d.ts.map +1 -1
- package/src/generators/setup-build/generator.js +3 -3
- package/src/migrations/update-22-0-0/remove-external-options-from-js-executors.d.ts.map +1 -1
- package/src/migrations/update-22-0-0/remove-external-options-from-js-executors.js +2 -2
- package/src/plugins/typescript/plugin.d.ts.map +1 -1
- package/src/plugins/typescript/plugin.js +39 -10
- package/src/release/version-actions.d.ts.map +1 -1
- package/src/release/version-actions.js +3 -3
- package/src/utils/buildable-libs-utils.d.ts.map +1 -1
- package/src/utils/buildable-libs-utils.js +3 -2
- package/src/utils/generator-prompts.js +3 -3
- package/src/utils/package-json/update-package-json.d.ts.map +1 -1
- package/src/utils/package-json/update-package-json.js +2 -1
- package/src/utils/strip-glob-to-base-dir.d.ts +2 -0
- package/src/utils/strip-glob-to-base-dir.d.ts.map +1 -0
- package/src/utils/strip-glob-to-base-dir.js +16 -0
- package/src/utils/swc/compile-swc.js +2 -2
- package/src/utils/typescript/compilation.d.ts +23 -0
- package/src/utils/typescript/compilation.d.ts.map +1 -0
- package/src/utils/typescript/compilation.js +119 -0
- package/src/utils/typescript/compile-typescript-files.d.ts +1 -1
- package/src/utils/typescript/compile-typescript-files.d.ts.map +1 -1
- package/src/utils/typescript/compile-typescript-files.js +3 -3
- package/src/utils/typescript/ts-solution-setup.d.ts +2 -0
- package/src/utils/typescript/ts-solution-setup.d.ts.map +1 -1
- package/src/utils/typescript/ts-solution-setup.js +5 -0
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "23.0.0-beta.
|
|
3
|
+
"version": "23.0.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": {
|
|
@@ -40,18 +40,18 @@
|
|
|
40
40
|
"@babel/preset-env": "^7.23.2",
|
|
41
41
|
"@babel/preset-typescript": "^7.22.5",
|
|
42
42
|
"@babel/runtime": "^7.22.6",
|
|
43
|
-
"@nx/devkit": "23.0.0-beta.
|
|
44
|
-
"@nx/workspace": "23.0.0-beta.
|
|
43
|
+
"@nx/devkit": "23.0.0-beta.10",
|
|
44
|
+
"@nx/workspace": "23.0.0-beta.10",
|
|
45
45
|
"@zkochan/js-yaml": "0.0.7",
|
|
46
46
|
"babel-plugin-const-enum": "^1.0.1",
|
|
47
47
|
"babel-plugin-macros": "^3.1.0",
|
|
48
48
|
"babel-plugin-transform-typescript-metadata": "^0.3.1",
|
|
49
49
|
"chalk": "^4.1.0",
|
|
50
50
|
"columnify": "^1.6.0",
|
|
51
|
-
"detect-port": "^1.
|
|
52
|
-
"ignore": "^
|
|
51
|
+
"detect-port": "^2.1.0",
|
|
52
|
+
"ignore": "^7.0.5",
|
|
53
53
|
"js-tokens": "^4.0.0",
|
|
54
|
-
"jsonc-parser": "3.2.0",
|
|
54
|
+
"jsonc-parser": "^3.2.0",
|
|
55
55
|
"npm-run-path": "^4.0.1",
|
|
56
56
|
"picocolors": "^1.1.0",
|
|
57
57
|
"picomatch": "4.0.4",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"tslib": "^2.3.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"nx": "23.0.0-beta.
|
|
64
|
+
"nx": "23.0.0-beta.10"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"verdaccio": "^6.0.5"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copy-workspace-modules.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/copy-workspace-modules/copy-workspace-modules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAMrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"copy-workspace-modules.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/copy-workspace-modules/copy-workspace-modules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EAMrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAc5D,wBAA8B,oBAAoB,CAChD,MAAM,EAAE,2BAA2B,EACnC,OAAO,EAAE,eAAe;;GASzB"}
|
|
@@ -8,6 +8,7 @@ const path_1 = require("path");
|
|
|
8
8
|
const fs_1 = require("fs");
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
10
10
|
const get_workspace_packages_from_graph_1 = require("nx/src/plugins/js/utils/get-workspace-packages-from-graph");
|
|
11
|
+
const strip_glob_to_base_dir_1 = require("../../utils/strip-glob-to-base-dir");
|
|
11
12
|
async function copyWorkspaceModules(schema, context) {
|
|
12
13
|
devkit_1.logger.log('Copying Workspace Modules to Build Directory...');
|
|
13
14
|
const outputDirectory = getOutputDir(schema, context);
|
|
@@ -128,6 +129,7 @@ function getOutputDir(schema, context) {
|
|
|
128
129
|
return outputDir;
|
|
129
130
|
}
|
|
130
131
|
function normalizeOutputPath(outputPath) {
|
|
132
|
+
outputPath = (0, strip_glob_to_base_dir_1.stripGlobToBaseDir)(outputPath);
|
|
131
133
|
if (!outputPath.startsWith(devkit_1.workspaceRoot)) {
|
|
132
134
|
outputPath = (0, path_1.join)(devkit_1.workspaceRoot, outputPath);
|
|
133
135
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/node.impl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/node/node.impl.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,eAAe,EAQhB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAe,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAsB5D,wBAAuB,YAAY,CACjC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,eAAe;aAgEb,OAAO;cACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;cA6QhC;AAmID,eAAe,YAAY,CAAC"}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.nodeExecutor = nodeExecutor;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
6
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
6
7
|
const child_process_1 = require("child_process");
|
|
7
8
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
9
9
|
const client_1 = require("nx/src/daemon/client/client");
|
|
10
10
|
const crypto_1 = require("crypto");
|
|
11
11
|
const path = tslib_1.__importStar(require("path"));
|
|
@@ -18,6 +18,7 @@ const fileutils_1 = require("nx/src/utils/fileutils");
|
|
|
18
18
|
const utils_1 = require("nx/src/tasks-runner/utils");
|
|
19
19
|
const detect_module_format_1 = require("./lib/detect-module-format");
|
|
20
20
|
const output_file_1 = require("./lib/output-file");
|
|
21
|
+
const strip_glob_to_base_dir_1 = require("../../utils/strip-glob-to-base-dir");
|
|
21
22
|
const globalLineAwareWriter = new line_aware_writer_1.LineAwareWriter();
|
|
22
23
|
async function* nodeExecutor(options, context) {
|
|
23
24
|
process.env.NODE_ENV ??= context?.configurationName ?? 'development';
|
|
@@ -59,7 +60,7 @@ async function* nodeExecutor(options, context) {
|
|
|
59
60
|
let additionalExitHandler = null;
|
|
60
61
|
let currentTask = null;
|
|
61
62
|
const tasks = [];
|
|
62
|
-
yield* (0,
|
|
63
|
+
yield* (0, internal_1.createAsyncIterable)(async ({ done, next, error, registerCleanup }) => {
|
|
63
64
|
const processQueue = async () => {
|
|
64
65
|
if (tasks.length === 0)
|
|
65
66
|
return;
|
|
@@ -298,7 +299,7 @@ function calculateResolveMappings(context, options) {
|
|
|
298
299
|
// `outputs` are cache patterns and may contain globs (e.g. from the
|
|
299
300
|
// inferred `@nx/js/typescript` build target). Strip the glob portion
|
|
300
301
|
// so the runtime require overrides resolve to the actual output dir.
|
|
301
|
-
const outputDir = stripGlobToBaseDir(c.outputs[0]);
|
|
302
|
+
const outputDir = (0, strip_glob_to_base_dir_1.stripGlobToBaseDir)(c.outputs[0]);
|
|
302
303
|
m[c.name] = (0, devkit_1.joinPathFragments)(context.root, outputDir);
|
|
303
304
|
}
|
|
304
305
|
return m;
|
|
@@ -338,7 +339,7 @@ function getFileToRun(context, project, buildOptions, buildTargetExecutor) {
|
|
|
338
339
|
// `{projectRoot}/dist/**/*.{js,...}` to avoid caching non-tsc files).
|
|
339
340
|
// Strip the glob portion back to the last path separator before it to
|
|
340
341
|
// recover the base output directory.
|
|
341
|
-
const outputDir = stripGlobToBaseDir(outputFilePath);
|
|
342
|
+
const outputDir = (0, strip_glob_to_base_dir_1.stripGlobToBaseDir)(outputFilePath);
|
|
342
343
|
return path.join(outputDir, 'main.js');
|
|
343
344
|
}
|
|
344
345
|
const fallbackFile = path.join('dist', project.data.root, 'main.js');
|
|
@@ -356,15 +357,6 @@ function getFileToRun(context, project, buildOptions, buildTargetExecutor) {
|
|
|
356
357
|
}
|
|
357
358
|
return (0, path_1.join)(context.root, buildOptions.outputPath, outputFileName);
|
|
358
359
|
}
|
|
359
|
-
function stripGlobToBaseDir(pathWithGlob) {
|
|
360
|
-
const globIdx = pathWithGlob.search(/[*?[{(]/);
|
|
361
|
-
if (globIdx === -1) {
|
|
362
|
-
return pathWithGlob.replace(/[\\/]+$/, '');
|
|
363
|
-
}
|
|
364
|
-
const prefix = pathWithGlob.slice(0, globIdx);
|
|
365
|
-
const lastSep = Math.max(prefix.lastIndexOf('/'), prefix.lastIndexOf('\\'));
|
|
366
|
-
return lastSep === -1 ? '' : prefix.slice(0, lastSep);
|
|
367
|
-
}
|
|
368
360
|
function fileToRunCorrectPath(fileToRun) {
|
|
369
361
|
if ((0, fileutils_1.fileExists)(fileToRun))
|
|
370
362
|
return fileToRun;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prune-lockfile.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/prune-lockfile/prune-lockfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAMrB,MAAM,YAAY,CAAC;AAYpB,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"prune-lockfile.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/prune-lockfile/prune-lockfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,eAAe,EAMrB,MAAM,YAAY,CAAC;AAYpB,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAGrD,wBAA8B,qBAAqB,CACjD,MAAM,EAAE,oBAAoB,EAC5B,OAAO,EAAE,eAAe;;GAgCzB"}
|
|
@@ -9,6 +9,7 @@ const utils_1 = require("nx/src/tasks-runner/utils");
|
|
|
9
9
|
const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
11
11
|
const get_workspace_packages_from_graph_1 = require("nx/src/plugins/js/utils/get-workspace-packages-from-graph");
|
|
12
|
+
const strip_glob_to_base_dir_1 = require("../../utils/strip-glob-to-base-dir");
|
|
12
13
|
async function pruneLockfileExecutor(schema, context) {
|
|
13
14
|
devkit_1.logger.log('Pruning lockfile...');
|
|
14
15
|
const outputDirectory = getOutputDir(schema, context);
|
|
@@ -89,6 +90,7 @@ function getOutputDir(schema, context) {
|
|
|
89
90
|
return outputDir;
|
|
90
91
|
}
|
|
91
92
|
function normalizeOutputPath(outputPath) {
|
|
93
|
+
outputPath = (0, strip_glob_to_base_dir_1.stripGlobToBaseDir)(outputPath);
|
|
92
94
|
if (!outputPath.startsWith(devkit_1.workspaceRoot)) {
|
|
93
95
|
outputPath = (0, path_1.join)(devkit_1.workspaceRoot, outputPath);
|
|
94
96
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compileTypescriptSolution = compileTypescriptSolution;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
const ts = tslib_1.__importStar(require("typescript"));
|
|
7
7
|
const get_custom_transformers_factory_1 = require("./get-custom-transformers-factory");
|
|
8
8
|
const typescript_diagnostic_reporters_1 = require("./typescript-diagnostic-reporters");
|
|
@@ -16,7 +16,7 @@ function compileTypescriptSolution(context, watch, logger, hooks, reporters) {
|
|
|
16
16
|
if (watch) {
|
|
17
17
|
// create an AsyncIterable that doesn't complete, watch mode is only
|
|
18
18
|
// stopped by killing the process
|
|
19
|
-
return (0,
|
|
19
|
+
return (0, internal_1.createAsyncIterable)(async ({ next }) => {
|
|
20
20
|
hooks ??= {};
|
|
21
21
|
const callerAfterProjectCompilationCallback = hooks.afterProjectCompilationCallback;
|
|
22
22
|
hooks.afterProjectCompilationCallback = (tsConfig, success) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ExecutorContext } from '@nx/devkit';
|
|
2
|
-
import type { TypeScriptCompilationOptions } from '
|
|
2
|
+
import type { TypeScriptCompilationOptions } from '../../utils/typescript/compilation';
|
|
3
3
|
import { ExecutorOptions, NormalizedExecutorOptions } from '../../utils/schema';
|
|
4
4
|
export declare function determineModuleFormatFromTsConfig(absolutePathToTsConfig: string, projectRoot?: string, workspaceRoot?: string): 'cjs' | 'esm';
|
|
5
5
|
export declare function createTypeScriptCompilationOptions(normalizedOptions: NormalizedExecutorOptions, context: ExecutorContext): TypeScriptCompilationOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tsc.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/tsc/tsc.impl.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAKhB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"tsc.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/tsc/tsc.impl.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAKhB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAQvF,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAOhF,wBAAgB,iCAAiC,CAC/C,sBAAsB,EAAE,MAAM,EAC9B,WAAW,CAAC,EAAE,MAAM,EACpB,aAAa,CAAC,EAAE,MAAM,GACrB,KAAK,GAAG,KAAK,CAkCf;AAED,wBAAgB,kCAAkC,CAChD,iBAAiB,EAAE,yBAAyB,EAC5C,OAAO,EAAE,eAAe,GACvB,4BAA4B,CAa9B;AAED,wBAAuB,WAAW,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,eAAe,mHAqHzB;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/init/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/init/init.ts"],"names":[],"mappings":"AACA,OAAO,EAML,iBAAiB,EAKjB,IAAI,EACL,MAAM,YAAY,CAAC;AAqBpB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAwCtC,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,iBAAiB,CAAC,CAS5B;AAED,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,iBAAiB,CAAC,CAgI5B;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initGenerator = initGenerator;
|
|
4
4
|
exports.initGeneratorInternal = initGeneratorInternal;
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const add_plugin_1 = require("@nx/devkit/src/utils/add-plugin");
|
|
7
|
-
const semver_1 = require("@nx/devkit/src/utils/semver");
|
|
8
7
|
const package_json_1 = require("nx/src/utils/package-json");
|
|
9
8
|
const path_1 = require("path");
|
|
10
|
-
const
|
|
9
|
+
const semver_1 = require("semver");
|
|
11
10
|
const plugin_1 = require("../../plugins/typescript/plugin");
|
|
12
11
|
const prettier_1 = require("../../utils/prettier");
|
|
13
12
|
const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
@@ -18,7 +17,7 @@ async function getInstalledTypescriptVersion(tree) {
|
|
|
18
17
|
if (!tsVersionInRootPackageJson) {
|
|
19
18
|
return null;
|
|
20
19
|
}
|
|
21
|
-
if ((0,
|
|
20
|
+
if ((0, semver_1.valid)(tsVersionInRootPackageJson)) {
|
|
22
21
|
// it's a pinned version, return it
|
|
23
22
|
return tsVersionInRootPackageJson;
|
|
24
23
|
}
|
|
@@ -29,12 +28,12 @@ async function getInstalledTypescriptVersion(tree) {
|
|
|
29
28
|
tsPackageJson.dependencies?.['typescript'];
|
|
30
29
|
// the installed version matches the package.json version range
|
|
31
30
|
if (installedTsVersion &&
|
|
32
|
-
(0,
|
|
31
|
+
(0, semver_1.satisfies)(installedTsVersion, tsVersionInRootPackageJson)) {
|
|
33
32
|
return installedTsVersion;
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
finally {
|
|
37
|
-
return (0,
|
|
36
|
+
return (0, internal_1.checkAndCleanWithSemver)(tree, 'typescript', tsVersionInRootPackageJson);
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
async function initGenerator(tree, schema) {
|
|
@@ -54,7 +53,7 @@ async function initGeneratorInternal(tree, schema) {
|
|
|
54
53
|
nxJson.useInferencePlugins !== false;
|
|
55
54
|
schema.addTsPlugin ??= schema.addPlugin;
|
|
56
55
|
if (schema.addTsPlugin) {
|
|
57
|
-
await (0,
|
|
56
|
+
await (0, internal_1.addPlugin)(tree, await (0, devkit_1.createProjectGraphAsync)(), '@nx/js/typescript', plugin_1.createNodesV2, {
|
|
58
57
|
typecheck: [
|
|
59
58
|
{ targetName: 'typecheck' },
|
|
60
59
|
{ targetName: 'tsc:typecheck' },
|
|
@@ -109,7 +108,7 @@ async function initGeneratorInternal(tree, schema) {
|
|
|
109
108
|
if (!schema.js && !schema.keepExistingVersions) {
|
|
110
109
|
const installedTsVersion = await getInstalledTypescriptVersion(tree);
|
|
111
110
|
if (!installedTsVersion ||
|
|
112
|
-
!(0,
|
|
111
|
+
!(0, semver_1.satisfies)(installedTsVersion, versions_1.supportedTypescriptVersions, {
|
|
113
112
|
includePrerelease: true,
|
|
114
113
|
})) {
|
|
115
114
|
devDependencies['typescript'] = versions_1.typescriptVersion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/library/library.ts"],"names":[],"mappings":"AAOA,OAAO,EAML,iBAAiB,EAWjB,IAAI,EAKL,MAAM,YAAY,CAAC;AAkCpB,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,8BAqK/B;AA2HD,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,GACX,yBAAyB,CAC5B,CAAC;AAEF,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,iBAAiB,CAAC,CAmH5B;AA+uBD,eAAe,gBAAgB,CAAC"}
|
|
@@ -4,11 +4,8 @@ exports.libraryGenerator = libraryGenerator;
|
|
|
4
4
|
exports.libraryGeneratorInternal = libraryGeneratorInternal;
|
|
5
5
|
exports.addLint = addLint;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
7
8
|
const devkit_1 = require("@nx/devkit");
|
|
8
|
-
const project_name_and_root_utils_1 = require("@nx/devkit/src/generators/project-name-and-root-utils");
|
|
9
|
-
const prompt_1 = require("@nx/devkit/src/generators/prompt");
|
|
10
|
-
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
11
|
-
const log_show_project_command_1 = require("@nx/devkit/src/utils/log-show-project-command");
|
|
12
9
|
const path_1 = require("path");
|
|
13
10
|
const generator_prompts_1 = require("../../utils/generator-prompts");
|
|
14
11
|
const sort_fields_1 = require("../../utils/package-json/sort-fields");
|
|
@@ -153,7 +150,7 @@ async function libraryGeneratorInternal(tree, schema) {
|
|
|
153
150
|
tasks.push(() => (0, devkit_1.installPackagesTask)(tree, true));
|
|
154
151
|
}
|
|
155
152
|
tasks.push(() => {
|
|
156
|
-
(0,
|
|
153
|
+
(0, internal_1.logShowProjectCommand)(options.name);
|
|
157
154
|
});
|
|
158
155
|
return (0, devkit_1.runTasksInSerial)(...tasks);
|
|
159
156
|
}
|
|
@@ -177,7 +174,7 @@ async function configureProject(tree, options) {
|
|
|
177
174
|
options.bundler === 'tsc'))) {
|
|
178
175
|
const outputPath = getOutputPath(options);
|
|
179
176
|
const executor = getBuildExecutor(options.bundler);
|
|
180
|
-
(0,
|
|
177
|
+
(0, internal_1.addBuildTargetDefaults)(tree, executor);
|
|
181
178
|
projectConfiguration.targets.build = {
|
|
182
179
|
executor,
|
|
183
180
|
outputs: ['{options.outputPath}'],
|
|
@@ -318,7 +315,12 @@ async function addLint(tree, options) {
|
|
|
318
315
|
ignoredFiles.add('{projectRoot}/esbuild.config.{js,ts,mjs,mts}');
|
|
319
316
|
}
|
|
320
317
|
if (options.unitTestRunner === 'vitest') {
|
|
321
|
-
|
|
318
|
+
// When bundler is 'vite', vite.config holds both build and test config
|
|
319
|
+
// (added above). Otherwise, @nx/vitest:configuration generates a
|
|
320
|
+
// dedicated vitest.config file for non-framework JS libraries.
|
|
321
|
+
ignoredFiles.add(options.bundler === 'vite'
|
|
322
|
+
? '{projectRoot}/vite.config.{js,ts,mjs,mts}'
|
|
323
|
+
: '{projectRoot}/vitest.config.{js,ts,mjs,mts}');
|
|
322
324
|
}
|
|
323
325
|
if (ignoredFiles.size) {
|
|
324
326
|
ruleOptions.ignoredFiles = Array.from(ignoredFiles);
|
|
@@ -535,7 +537,7 @@ function replaceJestConfig(tree, options) {
|
|
|
535
537
|
});
|
|
536
538
|
}
|
|
537
539
|
async function normalizeOptions(tree, options) {
|
|
538
|
-
await (0,
|
|
540
|
+
await (0, internal_1.ensureRootProjectName)(options, 'library');
|
|
539
541
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
540
542
|
options.addPlugin ??=
|
|
541
543
|
process.env.NX_ADD_PLUGINS !== 'false' &&
|
|
@@ -544,7 +546,7 @@ async function normalizeOptions(tree, options) {
|
|
|
544
546
|
const hasPlugin = (0, ts_solution_setup_1.isUsingTypeScriptPlugin)(tree);
|
|
545
547
|
const isUsingTsSolutionConfig = (0, ts_solution_setup_1.isUsingTsSolutionSetup)(tree);
|
|
546
548
|
if (isUsingTsSolutionConfig) {
|
|
547
|
-
options.unitTestRunner ??= await (0,
|
|
549
|
+
options.unitTestRunner ??= await (0, internal_1.promptWhenInteractive)({
|
|
548
550
|
type: 'autocomplete',
|
|
549
551
|
name: 'unitTestRunner',
|
|
550
552
|
message: `Which unit test runner would you like to use?`,
|
|
@@ -553,7 +555,7 @@ async function normalizeOptions(tree, options) {
|
|
|
553
555
|
}, { unitTestRunner: 'none' }).then(({ unitTestRunner }) => unitTestRunner);
|
|
554
556
|
}
|
|
555
557
|
else {
|
|
556
|
-
options.unitTestRunner ??= await (0,
|
|
558
|
+
options.unitTestRunner ??= await (0, internal_1.promptWhenInteractive)({
|
|
557
559
|
type: 'autocomplete',
|
|
558
560
|
name: 'unitTestRunner',
|
|
559
561
|
message: `Which unit test runner would you like to use?`,
|
|
@@ -614,7 +616,7 @@ async function normalizeOptions(tree, options) {
|
|
|
614
616
|
(options.skipTypeCheck == null || !isUsingTsSolutionConfig)) {
|
|
615
617
|
options.skipTypeCheck = false;
|
|
616
618
|
}
|
|
617
|
-
const { projectName, names: projectNames, projectRoot, importPath, } = await (0,
|
|
619
|
+
const { projectName, names: projectNames, projectRoot, importPath, } = await (0, internal_1.determineProjectNameAndRootOptions)(tree, {
|
|
618
620
|
name: options.name,
|
|
619
621
|
projectType: 'library',
|
|
620
622
|
directory: options.directory,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProjectNameAndRootOptions } from '@nx/devkit/
|
|
1
|
+
import type { ProjectNameAndRootOptions } from '@nx/devkit/internal';
|
|
2
2
|
// nx-ignore-next-line
|
|
3
3
|
const { Linter, LinterType } = require('@nx/eslint'); // use require to import to avoid circular dependency
|
|
4
4
|
import type { ProjectPackageManagerWorkspaceState } from '../../utils/package-manager-workspaces';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/setup-build/generator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/generators/setup-build/generator.ts"],"names":[],"mappings":"AACA,OAAO,EAWL,KAAK,iBAAiB,EAEtB,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAoBpB,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAIrD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,iBAAiB,CAAC,CAkL5B;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setupBuildGenerator = setupBuildGenerator;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const target_defaults_utils_1 = require("@nx/devkit/src/generators/target-defaults-utils");
|
|
6
6
|
const posix_1 = require("node:path/posix");
|
|
7
7
|
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
8
8
|
const get_import_path_1 = require("../../utils/get-import-path");
|
|
@@ -127,7 +127,7 @@ async function setupBuildGenerator(tree, options) {
|
|
|
127
127
|
updatePackageJsonForTsc(tree, options, project);
|
|
128
128
|
}
|
|
129
129
|
else {
|
|
130
|
-
(0,
|
|
130
|
+
(0, internal_1.addBuildTargetDefaults)(tree, '@nx/js:tsc');
|
|
131
131
|
const outputPath = (0, devkit_1.joinPathFragments)('dist', project.root);
|
|
132
132
|
project.targets[options.buildTarget] = {
|
|
133
133
|
executor: `@nx/js:tsc`,
|
|
@@ -144,7 +144,7 @@ async function setupBuildGenerator(tree, options) {
|
|
|
144
144
|
break;
|
|
145
145
|
}
|
|
146
146
|
case 'swc': {
|
|
147
|
-
(0,
|
|
147
|
+
(0, internal_1.addBuildTargetDefaults)(tree, '@nx/js:swc');
|
|
148
148
|
const outputPath = isTsSolutionSetup
|
|
149
149
|
? (0, devkit_1.joinPathFragments)(project.root, 'dist')
|
|
150
150
|
: (0, devkit_1.joinPathFragments)('dist', project.root);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-external-options-from-js-executors.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/migrations/update-22-0-0/remove-external-options-from-js-executors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remove-external-options-from-js-executors.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/migrations/update-22-0-0/remove-external-options-from-js-executors.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,IAAI,EACV,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,SAAS,UAA+B,CAAC;AAEtD,yBAA+B,IAAI,EAAE,IAAI,iBA+ExC"}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.executors = void 0;
|
|
4
4
|
exports.default = default_1;
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
-
const executor_options_utils_1 = require("@nx/devkit/src/generators/executor-options-utils");
|
|
7
7
|
exports.executors = ['@nx/js:swc', '@nx/js:tsc'];
|
|
8
8
|
async function default_1(tree) {
|
|
9
9
|
// update options from project configs
|
|
10
10
|
exports.executors.forEach((executor) => {
|
|
11
|
-
(0,
|
|
11
|
+
(0, internal_1.forEachExecutorOptions)(tree, executor, (options, project, target, configuration) => {
|
|
12
12
|
if (options.external === undefined &&
|
|
13
13
|
options.externalBuildTargets === undefined) {
|
|
14
14
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/plugins/typescript/plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/plugins/typescript/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,KAAK,kBAAkB,EAEvB,KAAK,aAAa,EAInB,MAAM,YAAY,CAAC;AA6BpB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAC1B,SAAS,CAAC,EACN,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;IACN,KAAK,CAAC,EACF,OAAO,GACP;QACE,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;IACN,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AA0KD;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,kBAEhC,CAAC;AAEF,eAAO,MAAM,WAAW,sBAAsB,CAAC;AAI/C,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,gBAAgB,CA+FzD,CAAC;AAEF,eAAO,MAAM,WAAW,iCAAgB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createNodes = exports.createNodesV2 = exports.PLUGIN_NAME = exports.createDependencies = void 0;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const get_named_inputs_1 = require("@nx/devkit/src/utils/get-named-inputs");
|
|
6
6
|
const node_fs_1 = require("node:fs");
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
8
|
const file_hasher_1 = require("nx/src/hasher/file-hasher");
|
|
@@ -122,8 +122,10 @@ exports.createNodesV2 = [
|
|
|
122
122
|
const cache = cacheStore.get(cacheKey);
|
|
123
123
|
initializeTsConfigCache(configFilePaths, context.workspaceRoot, cache);
|
|
124
124
|
const normalizedOptions = normalizePluginOptions(options);
|
|
125
|
-
const
|
|
126
|
-
const
|
|
125
|
+
const packageManager = (0, devkit_1.detectPackageManager)(context.workspaceRoot);
|
|
126
|
+
const pmc = (0, devkit_1.getPackageManagerCommand)(packageManager);
|
|
127
|
+
const lockFileName = (0, lock_file_1.getLockFileName)(packageManager);
|
|
128
|
+
const { configFilePaths: validConfigFilePaths, hashes, projectRoots, } = await resolveValidConfigFilesAndHashes(configFilePaths, normalizedOptions, optionsHash, context, cache, lockFileName);
|
|
127
129
|
try {
|
|
128
130
|
return await (0, devkit_1.createNodesFromFiles)((configFilePath, options, context, idx) => {
|
|
129
131
|
const projectRoot = projectRoots[idx];
|
|
@@ -156,8 +158,8 @@ exports.createNodesV2 = [
|
|
|
156
158
|
},
|
|
157
159
|
];
|
|
158
160
|
exports.createNodes = exports.createNodesV2;
|
|
159
|
-
async function resolveValidConfigFilesAndHashes(configFilePaths, options, optionsHash, context, cache) {
|
|
160
|
-
const lockFileHash = (0, file_hasher_1.hashFile)((0, node_path_1.join)(context.workspaceRoot,
|
|
161
|
+
async function resolveValidConfigFilesAndHashes(configFilePaths, options, optionsHash, context, cache, lockFileName) {
|
|
162
|
+
const lockFileHash = (0, file_hasher_1.hashFile)((0, node_path_1.join)(context.workspaceRoot, lockFileName)) ?? '';
|
|
161
163
|
const validConfigFilePaths = [];
|
|
162
164
|
const hashes = [];
|
|
163
165
|
const projectRoots = [];
|
|
@@ -246,7 +248,7 @@ function checkIfConfigFileShouldBeProject(config, cache) {
|
|
|
246
248
|
}
|
|
247
249
|
function buildTscTargets(config, options, context, configFiles, cache, pmc) {
|
|
248
250
|
const targets = {};
|
|
249
|
-
const namedInputs = (0,
|
|
251
|
+
const namedInputs = (0, internal_1.getNamedInputs)(config.project.root, context);
|
|
250
252
|
const tsConfig = retrieveTsConfigFromCache(config.absolutePath, context.workspaceRoot, cache);
|
|
251
253
|
let internalProjectReferences;
|
|
252
254
|
if (options.typecheck &&
|
|
@@ -626,9 +628,9 @@ function resolveShallowExternalProjectReferences(tsConfig, workspaceRoot, projec
|
|
|
626
628
|
}
|
|
627
629
|
/**
|
|
628
630
|
* Collects unique tsconfig paths (relative to their project root) from the
|
|
629
|
-
* project reference chain
|
|
630
|
-
* patterns. We only need to
|
|
631
|
-
*
|
|
631
|
+
* project reference chain — including any `extends` chains within those refs —
|
|
632
|
+
* and returns them as `^{projectRoot}/...` input patterns. We only need to
|
|
633
|
+
* discover the full set of distinct relative paths.
|
|
632
634
|
*/
|
|
633
635
|
function getExternalProjectReferenceTsconfigPatterns(tsConfig, internalProjectReferences, workspaceRoot, project, cache) {
|
|
634
636
|
const externalRefs = {};
|
|
@@ -659,7 +661,34 @@ function getExternalProjectReferenceTsconfigPatterns(tsConfig, internalProjectRe
|
|
|
659
661
|
visited.add(configPath);
|
|
660
662
|
const wsRelPath = posixRelative(workspaceRoot, configPath);
|
|
661
663
|
const tsConfigData = tsConfigCacheData[wsRelPath]?.data;
|
|
662
|
-
if (!tsConfigData
|
|
664
|
+
if (!tsConfigData) {
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
// Walk `extends` chains for the visited tsconfig. tsc reads extended
|
|
668
|
+
// configs while resolving project references, so the rel paths must be
|
|
669
|
+
// emitted as inputs. Workspace-root files (no owning project) are skipped
|
|
670
|
+
// — those are covered by the local project's own extends walk.
|
|
671
|
+
if (tsConfigData.extendedConfigFiles?.length) {
|
|
672
|
+
for (const extended of tsConfigData.extendedConfigFiles) {
|
|
673
|
+
if (!extended.filePath || visited.has(extended.filePath)) {
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
const extendedWsRelPath = posixRelative(workspaceRoot, extended.filePath);
|
|
677
|
+
if (!tsConfigCacheData[extendedWsRelPath]) {
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
const extendedContext = getConfigContext(extended.filePath, workspaceRoot, cache);
|
|
681
|
+
if (extendedContext.project.root &&
|
|
682
|
+
extendedContext.project.root !== '.') {
|
|
683
|
+
uniqueRelPaths.add(posixRelative(extendedContext.project.absolute, extended.filePath));
|
|
684
|
+
worklist.push({
|
|
685
|
+
configPath: extended.filePath,
|
|
686
|
+
ownerProject: extendedContext.project,
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
if (!tsConfigData.projectReferences?.length) {
|
|
663
692
|
continue;
|
|
664
693
|
}
|
|
665
694
|
for (const ref of tsConfigData.projectReferences) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version-actions.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/release/version-actions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"version-actions.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/release/version-actions.ts"],"names":[],"mappings":"AACA,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;AAM3E,eAAO,MAAM,yBAAyB,EAAE,yBAkBvC,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;IA4CI,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;IAwHpB,OAAO,CAAC,yBAAyB;CAyClC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.afterAllProjectsVersioned = void 0;
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
4
5
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const catalog_1 = require("@nx/devkit/src/utils/catalog");
|
|
6
6
|
const node_child_process_1 = require("node:child_process");
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
8
|
const release_1 = require("nx/release");
|
|
@@ -109,7 +109,7 @@ class JsVersionActions extends release_1.VersionActions {
|
|
|
109
109
|
}
|
|
110
110
|
// Resolve catalog references if needed
|
|
111
111
|
if (currentVersion) {
|
|
112
|
-
const catalogManager = (0,
|
|
112
|
+
const catalogManager = (0, internal_1.getCatalogManager)(tree.root);
|
|
113
113
|
if (catalogManager?.isCatalogReference(currentVersion)) {
|
|
114
114
|
currentVersion = catalogManager.resolveCatalogReference(tree, dependencyPackageName, currentVersion);
|
|
115
115
|
}
|
|
@@ -137,7 +137,7 @@ class JsVersionActions extends release_1.VersionActions {
|
|
|
137
137
|
}
|
|
138
138
|
const logMessages = [];
|
|
139
139
|
const catalogUpdates = [];
|
|
140
|
-
const catalogManager = (0,
|
|
140
|
+
const catalogManager = (0, internal_1.getCatalogManager)(tree.root);
|
|
141
141
|
for (const manifestToUpdate of this.manifestsToUpdate) {
|
|
142
142
|
(0, devkit_1.updateJson)(tree, manifestToUpdate.manifestPath, (json) => {
|
|
143
143
|
const dependencyTypes = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildable-libs-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/utils/buildable-libs-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACxB,uBAAuB,EACvB,SAAS,EACV,MAAM,YAAY,CAAC;AAYpB,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"buildable-libs-utils.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/utils/buildable-libs-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,wBAAwB,EACxB,uBAAuB,EACvB,SAAS,EACV,MAAM,YAAY,CAAC;AAYpB,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAiBtC,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,uBAAuB,GAAG,wBAAwB,CAAC;CAC1D,CAAC;AAEF,wBAAgB,qCAAqC,CACnD,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,SAAS,EAAE,YAAY,EACvB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,OAAO,GAChB;IACD,MAAM,EAAE,uBAAuB,CAAC;IAChC,YAAY,EAAE,6BAA6B,EAAE,CAAC;IAC9C,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,oBAAoB,EAAE,6BAA6B,EAAE,CAAC;CACvD,CAqBA;AAED,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,YAAY,EACvB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,OAAO,GAChB;IACD,MAAM,EAAE,uBAAuB,CAAC;IAChC,YAAY,EAAE,6BAA6B,EAAE,CAAC;IAC9C,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,oBAAoB,EAAE,6BAA6B,EAAE,CAAC;CACvD,CA+EA;AA0ED,wBAAgB,kCAAkC,CAChD,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM,EACzB,OAAO,CAAC,EAAE,OAAO,GAChB;IACD,MAAM,EAAE,uBAAuB,CAAC;IAChC,YAAY,EAAE,6BAA6B,EAAE,CAAC;IAC9C,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,oBAAoB,EAAE,6BAA6B,EAAE,CAAC;CACvD,CA8EA;AAkGD;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,GAAG,EAAE,CAAC,iBAAiB,EACvC,YAAY,EAAE,6BAA6B,EAAE,wBAK9C;AAED,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,6BAA6B,EAAE,EAC7C,qBAAqB,GAAE,OAAe,UAsBvC;AAUD,wBAAgB,WAAW,CACzB,YAAY,EAAE,6BAA6B,EAAE,EAC7C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,QA6DhC;AAED;;;GAGG;AACH,wBAAgB,6CAA6C,CAC3D,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,MAAM,EACzB,IAAI,EAAE,uBAAuB,EAC7B,YAAY,EAAE,6BAA6B,EAAE,EAC7C,gBAAgB,GAAE,cAAc,GAAG,kBAAmC,QAsFvE"}
|
|
@@ -14,6 +14,7 @@ const fileutils_1 = require("nx/src/utils/fileutils");
|
|
|
14
14
|
const output_1 = require("nx/src/utils/output");
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const ts_config_1 = require("./typescript/ts-config");
|
|
17
|
+
const strip_glob_to_base_dir_1 = require("./strip-glob-to-base-dir");
|
|
17
18
|
const crypto_1 = require("crypto");
|
|
18
19
|
const project_graph_1 = require("nx/src/config/project-graph");
|
|
19
20
|
function isBuildable(target, node) {
|
|
@@ -311,7 +312,7 @@ function updateBuildableProjectPackageJsonDependencies(root, projectName, target
|
|
|
311
312
|
target: targetName,
|
|
312
313
|
configuration: configurationName,
|
|
313
314
|
}, {}, node);
|
|
314
|
-
const packageJsonPath = `${outputs[0]}/package.json`;
|
|
315
|
+
const packageJsonPath = `${(0, strip_glob_to_base_dir_1.stripGlobToBaseDir)(outputs[0])}/package.json`;
|
|
315
316
|
let packageJson;
|
|
316
317
|
let workspacePackageJson;
|
|
317
318
|
try {
|
|
@@ -341,7 +342,7 @@ function updateBuildableProjectPackageJsonDependencies(root, projectName, target
|
|
|
341
342
|
target: targetName,
|
|
342
343
|
configuration: configurationName,
|
|
343
344
|
}, {}, entry.node);
|
|
344
|
-
const depPackageJsonPath = (0, path_1.join)(root, outputs[0], 'package.json');
|
|
345
|
+
const depPackageJsonPath = (0, path_1.join)(root, (0, strip_glob_to_base_dir_1.stripGlobToBaseDir)(outputs[0]), 'package.json');
|
|
345
346
|
depVersion = (0, devkit_1.readJsonFile)(depPackageJsonPath).version;
|
|
346
347
|
packageJson[typeOfDependency][packageName] = depVersion;
|
|
347
348
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.normalizeLinterOption = normalizeLinterOption;
|
|
4
4
|
exports.normalizeUnitTestRunnerOption = normalizeUnitTestRunnerOption;
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
const ts_solution_setup_1 = require("./typescript/ts-solution-setup");
|
|
7
7
|
async function normalizeLinterOption(tree, linter) {
|
|
8
8
|
if (linter) {
|
|
@@ -13,7 +13,7 @@ async function normalizeLinterOption(tree, linter) {
|
|
|
13
13
|
? [{ name: 'none' }, { name: 'eslint' }]
|
|
14
14
|
: [{ name: 'eslint' }, { name: 'none' }];
|
|
15
15
|
const defaultValue = isTsSolutionSetup ? 'none' : 'eslint';
|
|
16
|
-
return await (0,
|
|
16
|
+
return await (0, internal_1.promptWhenInteractive)({
|
|
17
17
|
type: 'autocomplete',
|
|
18
18
|
name: 'linter',
|
|
19
19
|
message: `Which linter would you like to use?`,
|
|
@@ -30,7 +30,7 @@ async function normalizeUnitTestRunnerOption(tree, unitTestRunner, testRunners =
|
|
|
30
30
|
? [{ name: 'none' }, ...testRunners.map((runner) => ({ name: runner }))]
|
|
31
31
|
: [...testRunners.map((runner) => ({ name: runner })), { name: 'none' }];
|
|
32
32
|
const defaultValue = (isTsSolutionSetup ? 'none' : testRunners[0]);
|
|
33
|
-
return await (0,
|
|
33
|
+
return await (0, internal_1.promptWhenInteractive)({
|
|
34
34
|
type: 'autocomplete',
|
|
35
35
|
name: 'unitTestRunner',
|
|
36
36
|
message: `Which unit test runner would you like to use?`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-package-json.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/package-json/update-package-json.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,eAAe,EAIf,cAAc,EAGd,uBAAuB,EAIxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAIxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"update-package-json.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/package-json/update-package-json.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,eAAe,EAIf,cAAc,EAGd,uBAAuB,EAIxB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAIxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAM7D,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,KAAK,CAAC;AAE5C,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;IACjC,MAAM,CAAC,EAAE,eAAe,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yBAAyB,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IACzC,yBAAyB,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IACzC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,uCAAuC,CAAC,EAAE,OAAO,CAAC;IAClD,qCAAqC,CAAC,EAAE,cAAc,GAAG,kBAAkB,CAAC;IAC5E,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C;AAED,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,uBAAuB,EAC/B,YAAY,EAAE,6BAA6B,EAAE,EAC7C,OAAO,GAAE,cAAqB,GAC7B,IAAI,CAmFN;AAqFD,UAAU,OAAO;IACf,GAAG,EAAE,MAAM,CAAC;IAEZ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,IAAI,CACX,uBAAuB,EACrB,MAAM,GACN,SAAS,GACT,aAAa,GACb,gBAAgB,GAChB,uBAAuB,GACvB,YAAY,GACZ,iBAAiB,CACpB,GAAG;IACF,OAAO,EAAE,MAAM,CAAC;CACjB,GACA,OAAO,CAgCT;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,uBAAuB,GAC/B,WAAW,CAuGb;AA2CD,wBAAgB,YAAY,CAC1B,OAAO,EAAE,IAAI,CACX,uBAAuB,EACrB,MAAM,GACN,SAAS,GACT,aAAa,GACb,gBAAgB,GAChB,YAAY,GACZ,iBAAiB,CACpB,GACA,MAAM,CAWR"}
|
|
@@ -14,6 +14,7 @@ const path_1 = require("path");
|
|
|
14
14
|
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
15
15
|
const nx_deps_cache_1 = require("nx/src/project-graph/nx-deps-cache");
|
|
16
16
|
const get_main_file_dir_1 = require("../get-main-file-dir");
|
|
17
|
+
const strip_glob_to_base_dir_1 = require("../strip-glob-to-base-dir");
|
|
17
18
|
function updatePackageJson(options, context, target, dependencies, fileMap = null) {
|
|
18
19
|
let packageJson;
|
|
19
20
|
if (fileMap == null) {
|
|
@@ -101,7 +102,7 @@ function addMissingDependencies(packageJson, { projectName, targetName, configur
|
|
|
101
102
|
target: targetName,
|
|
102
103
|
configuration: configurationName,
|
|
103
104
|
}, {}, entry.node);
|
|
104
|
-
const depPackageJsonPath = (0, path_1.join)(root, outputs[0], 'package.json');
|
|
105
|
+
const depPackageJsonPath = (0, path_1.join)(root, (0, strip_glob_to_base_dir_1.stripGlobToBaseDir)(outputs[0]), 'package.json');
|
|
105
106
|
if ((0, node_fs_1.existsSync)(depPackageJsonPath)) {
|
|
106
107
|
const version = (0, devkit_1.readJsonFile)(depPackageJsonPath).version;
|
|
107
108
|
packageJson[propType] ??= {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-glob-to-base-dir.d.ts","sourceRoot":"","sources":["../../../../../packages/js/src/utils/strip-glob-to-base-dir.ts"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAQ/D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stripGlobToBaseDir = stripGlobToBaseDir;
|
|
4
|
+
// `outputs` entries on inferred targets (e.g. from `@nx/js/typescript`) are
|
|
5
|
+
// cache-match patterns and may contain globs. Strip the glob portion back to
|
|
6
|
+
// the last path separator to recover the base output directory. Returns the
|
|
7
|
+
// input with trailing separators stripped when there is no glob.
|
|
8
|
+
function stripGlobToBaseDir(pathWithGlob) {
|
|
9
|
+
const globIdx = pathWithGlob.search(/[*?[{(]/);
|
|
10
|
+
if (globIdx === -1) {
|
|
11
|
+
return pathWithGlob.replace(/[\\/]+$/, '');
|
|
12
|
+
}
|
|
13
|
+
const prefix = pathWithGlob.slice(0, globIdx);
|
|
14
|
+
const lastSep = Math.max(prefix.lastIndexOf('/'), prefix.lastIndexOf('\\'));
|
|
15
|
+
return lastSep === -1 ? '' : prefix.slice(0, lastSep);
|
|
16
|
+
}
|
|
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.compileSwc = compileSwc;
|
|
4
4
|
exports.compileSwcWatch = compileSwcWatch;
|
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
7
|
const node_child_process_1 = require("node:child_process");
|
|
7
8
|
const node_fs_1 = require("node:fs");
|
|
8
9
|
const node_path_1 = require("node:path");
|
|
9
|
-
const async_iterable_1 = require("@nx/devkit/src/utils/async-iterable");
|
|
10
10
|
const print_diagnostics_1 = require("../typescript/print-diagnostics");
|
|
11
11
|
const run_type_check_1 = require("../typescript/run-type-check");
|
|
12
12
|
const path_1 = require("path");
|
|
@@ -101,7 +101,7 @@ async function* compileSwcWatch(context, normalizedOptions, postCompilationCallb
|
|
|
101
101
|
if (normalizedOptions.clean) {
|
|
102
102
|
(0, node_fs_1.rmSync)(normalizedOptions.outputPath, { recursive: true, force: true });
|
|
103
103
|
}
|
|
104
|
-
return yield* (0,
|
|
104
|
+
return yield* (0, internal_1.createAsyncIterable)(async ({ next, done }) => {
|
|
105
105
|
let processOnExit;
|
|
106
106
|
let handleCallback;
|
|
107
107
|
let stdoutOnData;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type * as ts from 'typescript';
|
|
2
|
+
import type { CustomTransformers, Diagnostic, Program } from 'typescript';
|
|
3
|
+
export interface TypeScriptCompilationOptions {
|
|
4
|
+
outputPath: string;
|
|
5
|
+
projectName: string;
|
|
6
|
+
projectRoot: string;
|
|
7
|
+
tsConfig: string;
|
|
8
|
+
deleteOutputPath?: boolean;
|
|
9
|
+
rootDir?: string;
|
|
10
|
+
watch?: boolean;
|
|
11
|
+
getCustomTransformers?(program: Program): CustomTransformers;
|
|
12
|
+
}
|
|
13
|
+
export interface TypescriptWatchChangeEvent {
|
|
14
|
+
diagnostic: ts.Diagnostic;
|
|
15
|
+
newLine: string;
|
|
16
|
+
options: ts.CompilerOptions;
|
|
17
|
+
errorCount: number;
|
|
18
|
+
}
|
|
19
|
+
export declare function compileTypeScript(options: TypeScriptCompilationOptions): {
|
|
20
|
+
success: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare function compileTypeScriptWatcher(options: TypeScriptCompilationOptions, callback: (diagnostic: Diagnostic, newLine: string, options: ts.CompilerOptions, errorCount: number) => void | Promise<void>): ts.WatchOfFilesAndCompilerOptions<ts.BuilderProgram>;
|
|
23
|
+
//# sourceMappingURL=compilation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compilation.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/compilation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAM1E,MAAM,WAAW,4BAA4B;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qBAAqB,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,kBAAkB,CAAC;CAC9D;AAED,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,EAAE,CAAC,eAAe,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,4BAA4B,GAAG;IACxE,OAAO,EAAE,OAAO,CAAC;CAClB,CASA;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,4BAA4B,EACrC,QAAQ,EAAE,CACR,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,EAAE,CAAC,eAAe,EAC3B,UAAU,EAAE,MAAM,KACf,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,wDAwD1B"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compileTypeScript = compileTypeScript;
|
|
4
|
+
exports.compileTypeScriptWatcher = compileTypeScriptWatcher;
|
|
5
|
+
const devkit_1 = require("@nx/devkit");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const ts_config_1 = require("./ts-config");
|
|
8
|
+
const ensure_typescript_1 = require("./ensure-typescript");
|
|
9
|
+
let tsModule;
|
|
10
|
+
function compileTypeScript(options) {
|
|
11
|
+
const normalizedOptions = normalizeOptions(options);
|
|
12
|
+
const tsConfig = getNormalizedTsConfig(normalizedOptions);
|
|
13
|
+
if (normalizedOptions.deleteOutputPath) {
|
|
14
|
+
(0, fs_1.rmSync)(normalizedOptions.outputPath, { recursive: true, force: true });
|
|
15
|
+
}
|
|
16
|
+
return createProgram(tsConfig, normalizedOptions);
|
|
17
|
+
}
|
|
18
|
+
function compileTypeScriptWatcher(options, callback) {
|
|
19
|
+
if (!tsModule) {
|
|
20
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
21
|
+
}
|
|
22
|
+
const normalizedOptions = normalizeOptions(options);
|
|
23
|
+
const tsConfig = getNormalizedTsConfig(normalizedOptions);
|
|
24
|
+
if (normalizedOptions.deleteOutputPath) {
|
|
25
|
+
(0, fs_1.rmSync)(normalizedOptions.outputPath, { recursive: true, force: true });
|
|
26
|
+
}
|
|
27
|
+
const host = tsModule.createWatchCompilerHost(tsConfig.fileNames, tsConfig.options, tsModule.sys);
|
|
28
|
+
const originalAfterProgramCreate = host.afterProgramCreate;
|
|
29
|
+
host.afterProgramCreate = (builderProgram) => {
|
|
30
|
+
const originalProgramEmit = builderProgram.emit;
|
|
31
|
+
builderProgram.emit = (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) => {
|
|
32
|
+
const consumerCustomTransformers = options.getCustomTransformers?.(builderProgram.getProgram());
|
|
33
|
+
const mergedCustomTransformers = mergeCustomTransformers(customTransformers, consumerCustomTransformers);
|
|
34
|
+
return originalProgramEmit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, mergedCustomTransformers);
|
|
35
|
+
};
|
|
36
|
+
if (originalAfterProgramCreate)
|
|
37
|
+
originalAfterProgramCreate(builderProgram);
|
|
38
|
+
};
|
|
39
|
+
const originalOnWatchStatusChange = host.onWatchStatusChange;
|
|
40
|
+
host.onWatchStatusChange = async (a, b, c, d) => {
|
|
41
|
+
originalOnWatchStatusChange?.(a, b, c, d);
|
|
42
|
+
await callback?.(a, b, c, d);
|
|
43
|
+
};
|
|
44
|
+
return tsModule.createWatchProgram(host);
|
|
45
|
+
}
|
|
46
|
+
function mergeCustomTransformers(originalCustomTransformers, consumerCustomTransformers) {
|
|
47
|
+
if (!consumerCustomTransformers)
|
|
48
|
+
return originalCustomTransformers;
|
|
49
|
+
const mergedCustomTransformers = {};
|
|
50
|
+
if (consumerCustomTransformers.before) {
|
|
51
|
+
mergedCustomTransformers.before = originalCustomTransformers?.before
|
|
52
|
+
? [
|
|
53
|
+
...originalCustomTransformers.before,
|
|
54
|
+
...consumerCustomTransformers.before,
|
|
55
|
+
]
|
|
56
|
+
: consumerCustomTransformers.before;
|
|
57
|
+
}
|
|
58
|
+
if (consumerCustomTransformers.after) {
|
|
59
|
+
mergedCustomTransformers.after = originalCustomTransformers?.after
|
|
60
|
+
? [
|
|
61
|
+
...originalCustomTransformers.after,
|
|
62
|
+
...consumerCustomTransformers.after,
|
|
63
|
+
]
|
|
64
|
+
: consumerCustomTransformers.after;
|
|
65
|
+
}
|
|
66
|
+
if (consumerCustomTransformers.afterDeclarations) {
|
|
67
|
+
mergedCustomTransformers.afterDeclarations =
|
|
68
|
+
originalCustomTransformers?.afterDeclarations
|
|
69
|
+
? [
|
|
70
|
+
...originalCustomTransformers.afterDeclarations,
|
|
71
|
+
...consumerCustomTransformers.afterDeclarations,
|
|
72
|
+
]
|
|
73
|
+
: consumerCustomTransformers.afterDeclarations;
|
|
74
|
+
}
|
|
75
|
+
return mergedCustomTransformers;
|
|
76
|
+
}
|
|
77
|
+
function getNormalizedTsConfig(options) {
|
|
78
|
+
const tsConfig = (0, ts_config_1.readTsConfig)(options.tsConfig);
|
|
79
|
+
tsConfig.options.outDir = options.outputPath;
|
|
80
|
+
tsConfig.options.noEmitOnError = true;
|
|
81
|
+
tsConfig.options.rootDir = options.rootDir;
|
|
82
|
+
if (tsConfig.options.incremental && !tsConfig.options.tsBuildInfoFile) {
|
|
83
|
+
tsConfig.options.tsBuildInfoFile = (0, devkit_1.joinPathFragments)(options.outputPath, 'tsconfig.tsbuildinfo');
|
|
84
|
+
}
|
|
85
|
+
return tsConfig;
|
|
86
|
+
}
|
|
87
|
+
function createProgram(tsconfig, { projectName, getCustomTransformers }) {
|
|
88
|
+
if (!tsModule) {
|
|
89
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
90
|
+
}
|
|
91
|
+
const host = tsModule.createCompilerHost(tsconfig.options);
|
|
92
|
+
const program = tsModule.createProgram({
|
|
93
|
+
rootNames: tsconfig.fileNames,
|
|
94
|
+
options: tsconfig.options,
|
|
95
|
+
host,
|
|
96
|
+
});
|
|
97
|
+
devkit_1.logger.info(`Compiling TypeScript files for project "${projectName}"...`);
|
|
98
|
+
const results = program.emit(undefined, undefined, undefined, undefined, getCustomTransformers?.(program));
|
|
99
|
+
if (results.emitSkipped) {
|
|
100
|
+
const diagnostics = tsModule.formatDiagnosticsWithColorAndContext(results.diagnostics, {
|
|
101
|
+
getCurrentDirectory: () => tsModule.sys.getCurrentDirectory(),
|
|
102
|
+
getNewLine: () => tsModule.sys.newLine,
|
|
103
|
+
getCanonicalFileName: (name) => name,
|
|
104
|
+
});
|
|
105
|
+
devkit_1.logger.error(diagnostics);
|
|
106
|
+
return { success: false };
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
devkit_1.logger.info(`Done compiling TypeScript files for project "${projectName}".`);
|
|
110
|
+
return { success: true };
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function normalizeOptions(options) {
|
|
114
|
+
return {
|
|
115
|
+
...options,
|
|
116
|
+
deleteOutputPath: options.deleteOutputPath ?? true,
|
|
117
|
+
rootDir: options.rootDir ?? options.projectRoot,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TypeScriptCompilationOptions } from '
|
|
1
|
+
import { TypeScriptCompilationOptions } from './compilation';
|
|
2
2
|
import { NormalizedExecutorOptions } from '../schema';
|
|
3
3
|
export interface TypescriptCompilationResult {
|
|
4
4
|
success: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-typescript-files.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/compile-typescript-files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile-typescript-files.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/compile-typescript-files.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,4BAA4B,EAC7B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAWtD,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,sBAAsB,CACpC,iBAAiB,EAAE,yBAAyB,EAC5C,UAAU,EAAE,4BAA4B,EACxC,uBAAuB,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAClD;IACD,QAAQ,EAAE,aAAa,CAAC,2BAA2B,CAAC,CAAC;IACrD,KAAK,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC,CA0CA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compileTypeScriptFiles = compileTypeScriptFiles;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
5
|
+
const compilation_1 = require("./compilation");
|
|
6
6
|
const TYPESCRIPT_FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES = 6194;
|
|
7
7
|
// Typescript diagnostic message for 6194: Found {0} errors. Watching for file changes.
|
|
8
8
|
// https://github.com/microsoft/TypeScript/blob/d45012c5e2ab122919ee4777a7887307c5f4a1e0/src/compiler/diagnosticMessages.json#L4763-L4766
|
|
@@ -17,7 +17,7 @@ function compileTypeScriptFiles(normalizedOptions, tscOptions, postCompilationCa
|
|
|
17
17
|
});
|
|
18
18
|
let tearDown;
|
|
19
19
|
return {
|
|
20
|
-
iterator: (0,
|
|
20
|
+
iterator: (0, internal_1.createAsyncIterable)(async ({ next, done }) => {
|
|
21
21
|
if (normalizedOptions.watch) {
|
|
22
22
|
const host = (0, compilation_1.compileTypeScriptWatcher)(tscOptions, async (d) => {
|
|
23
23
|
if (d.code === TYPESCRIPT_FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES) {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type ProjectConfiguration, type Tree } from '@nx/devkit';
|
|
2
|
+
import type { JsonInput } from 'nx/src/native';
|
|
3
|
+
export declare const TS_SOLUTION_SETUP_TSCONFIG_INPUT: JsonInput;
|
|
2
4
|
export declare function isUsingTypeScriptPlugin(tree: Tree): boolean;
|
|
3
5
|
export declare function shouldConfigureTsSolutionSetup(tree: Tree, addPlugins: boolean, addTsPlugin?: boolean): boolean;
|
|
4
6
|
export declare function isUsingTsSolutionSetup(tree?: Tree): boolean;
|
|
@@ -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;
|
|
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;AAUpB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,eAAO,MAAM,gCAAgC,EAAE,SAG9C,CAAC;AAEF,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;AAKD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,IAAI,EACV,OAAO,GAAE;IAAE,uBAAuB,CAAC,EAAE,OAAO,CAAA;CAAO,GAClD,MAAM,CAqCR;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,CAqCvE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TS_SOLUTION_SETUP_TSCONFIG_INPUT = void 0;
|
|
3
4
|
exports.isUsingTypeScriptPlugin = isUsingTypeScriptPlugin;
|
|
4
5
|
exports.shouldConfigureTsSolutionSetup = shouldConfigureTsSolutionSetup;
|
|
5
6
|
exports.isUsingTsSolutionSetup = isUsingTsSolutionSetup;
|
|
@@ -17,6 +18,10 @@ const posix_1 = require("node:path/posix");
|
|
|
17
18
|
const tree_1 = require("nx/src/generators/tree");
|
|
18
19
|
const package_manager_workspaces_1 = require("../package-manager-workspaces");
|
|
19
20
|
const configuration_1 = require("./configuration");
|
|
21
|
+
exports.TS_SOLUTION_SETUP_TSCONFIG_INPUT = {
|
|
22
|
+
json: '{workspaceRoot}/tsconfig.json',
|
|
23
|
+
fields: ['extends', 'files', 'include'],
|
|
24
|
+
};
|
|
20
25
|
function isUsingTypeScriptPlugin(tree) {
|
|
21
26
|
const nxJson = (0, devkit_1.readNxJson)(tree);
|
|
22
27
|
return (nxJson?.plugins?.some((p) => typeof p === 'string'
|
package/src/utils/versions.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const swcCoreVersion = "~1.15.5";
|
|
|
6
6
|
export declare const swcHelpersVersion = "~0.5.18";
|
|
7
7
|
export declare const swcNodeVersion = "~1.11.1";
|
|
8
8
|
export declare const tsLibVersion = "^2.3.0";
|
|
9
|
-
export declare const typesNodeVersion = "
|
|
9
|
+
export declare const typesNodeVersion = "^22.0.0";
|
|
10
10
|
export declare const verdaccioVersion = "^6.3.2";
|
|
11
11
|
export declare const typescriptVersion = "~5.9.2";
|
|
12
12
|
/**
|
package/src/utils/versions.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.swcCoreVersion = '~1.15.5';
|
|
|
9
9
|
exports.swcHelpersVersion = '~0.5.18';
|
|
10
10
|
exports.swcNodeVersion = '~1.11.1';
|
|
11
11
|
exports.tsLibVersion = '^2.3.0';
|
|
12
|
-
exports.typesNodeVersion = '
|
|
12
|
+
exports.typesNodeVersion = '^22.0.0';
|
|
13
13
|
exports.verdaccioVersion = '^6.3.2';
|
|
14
14
|
// Typescript
|
|
15
15
|
exports.typescriptVersion = '~5.9.2';
|