@nx/js 23.1.0 → 23.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/babel.js +11 -0
- package/dist/internal.d.ts +4 -3
- package/dist/internal.js +16 -17
- package/dist/src/executors/copy-workspace-modules/copy-workspace-modules.js +4 -6
- package/dist/src/executors/node/lib/output-file.js +4 -4
- package/dist/src/executors/node/node.impl.js +9 -10
- package/dist/src/executors/prune-lockfile/prune-lockfile.d.ts +1 -1
- package/dist/src/executors/prune-lockfile/prune-lockfile.js +4 -9
- package/dist/src/executors/release-publish/extract-npm-publish-json-data.js +92 -52
- package/dist/src/executors/release-publish/log-tar.js +6 -2
- package/dist/src/executors/release-publish/release-publish.impl.js +15 -0
- package/dist/src/executors/tsc/lib/batch/watch.js +3 -3
- package/dist/src/executors/tsc/tsc.batch-impl.d.ts +1 -1
- package/dist/src/executors/tsc/tsc.batch-impl.js +2 -2
- package/dist/src/executors/verdaccio/verdaccio.impl.js +8 -1
- package/dist/src/generators/library/library.d.ts +1 -1
- package/dist/src/generators/library/library.js +4 -4
- package/dist/src/generators/library/schema.d.ts +4 -0
- package/dist/src/generators/library/schema.json +8 -2
- package/dist/src/generators/library/utils/add-release-config.js +2 -2
- package/dist/src/generators/setup-build/generator.js +2 -7
- package/dist/src/generators/typescript-sync/typescript-sync.d.ts +1 -1
- package/dist/src/generators/typescript-sync/typescript-sync.js +2 -2
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.js +5 -7
- package/dist/src/migrations/update-23-1-0/add-ignore-deprecations-for-ts6.d.ts +3 -2
- package/dist/src/migrations/update-23-1-0/add-ignore-deprecations-for-ts6.js +17 -11
- package/dist/src/plugins/jest/start-local-registry.js +6 -1
- package/dist/src/plugins/typescript/plugin.js +9 -14
- package/dist/src/plugins/typescript/util.d.ts +1 -1
- package/dist/src/release/utils/update-lock-file.js +5 -7
- package/dist/src/release/version-actions.d.ts +12 -3
- package/dist/src/release/version-actions.js +232 -74
- package/dist/src/utils/assets/copy-assets-handler.d.ts +1 -1
- package/dist/src/utils/assets/copy-assets-handler.js +2 -2
- package/dist/src/utils/buildable-libs-utils.js +10 -13
- package/dist/src/utils/find-npm-dependencies.js +7 -10
- package/dist/src/utils/generate-globs.js +11 -14
- package/dist/src/utils/get-main-file-dir.js +2 -2
- package/dist/src/utils/npm-config.d.ts +1 -1
- package/dist/src/utils/package-json/update-package-json.d.ts +1 -1
- package/dist/src/utils/package-json/update-package-json.js +6 -11
- package/dist/src/utils/package-manager-workspaces.js +2 -2
- package/dist/src/utils/swc/add-swc-dependencies.js +6 -0
- package/dist/src/utils/typescript/configuration.js +3 -5
- package/dist/src/utils/typescript/create-ts-config.d.ts +1 -1
- package/dist/src/utils/typescript/create-ts-config.js +5 -5
- package/dist/src/utils/typescript/plugin.js +2 -2
- package/dist/src/utils/typescript/run-type-check.js +2 -2
- package/dist/src/utils/typescript/ts-config.d.ts +51 -1
- package/dist/src/utils/typescript/ts-config.js +114 -0
- package/dist/src/utils/typescript/ts-solution-setup.d.ts +1 -1
- package/dist/src/utils/typescript/ts-solution-setup.js +3 -3
- package/dist/src/utils/watch-for-single-file-changes.js +2 -2
- package/migrations.json +1 -1
- package/package.json +8 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExecutorContext, ProjectFileMap, ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
2
|
import { DependentBuildableProjectNode } from '../buildable-libs-utils';
|
|
3
|
-
import type { PackageJson } from 'nx/
|
|
3
|
+
import type { PackageJson } from '@nx/devkit/internal';
|
|
4
4
|
export type SupportedFormat = 'cjs' | 'esm';
|
|
5
5
|
export interface UpdatePackageJsonOption {
|
|
6
6
|
rootDir?: string;
|
|
@@ -4,24 +4,19 @@ exports.updatePackageJson = updatePackageJson;
|
|
|
4
4
|
exports.getExports = getExports;
|
|
5
5
|
exports.getUpdatedPackageJsonContent = getUpdatedPackageJsonContent;
|
|
6
6
|
exports.getOutputDir = getOutputDir;
|
|
7
|
-
|
|
8
|
-
const lock_file_1 = require("nx/src/plugins/js/lock-file/lock-file");
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
|
|
10
|
-
const create_package_json_1 = require("nx/src/plugins/js/package-json/create-package-json");
|
|
7
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
11
8
|
const devkit_1 = require("@nx/devkit");
|
|
12
9
|
const node_fs_1 = require("node:fs");
|
|
13
10
|
const path_1 = require("path");
|
|
14
|
-
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
15
|
-
const nx_deps_cache_1 = require("nx/src/project-graph/nx-deps-cache");
|
|
16
11
|
const get_main_file_dir_1 = require("../get-main-file-dir");
|
|
17
12
|
const strip_glob_to_base_dir_1 = require("../strip-glob-to-base-dir");
|
|
18
13
|
function updatePackageJson(options, context, target, dependencies, fileMap = null) {
|
|
19
14
|
let packageJson;
|
|
20
15
|
if (fileMap == null) {
|
|
21
|
-
fileMap = (0,
|
|
16
|
+
fileMap = (0, internal_1.readFileMapCache)()?.fileMap?.projectFileMap || {};
|
|
22
17
|
}
|
|
23
18
|
if (options.updateBuildableProjectDepsInPackageJson) {
|
|
24
|
-
packageJson = (0,
|
|
19
|
+
packageJson = (0, internal_1.createPackageJson)(context.projectName, context.projectGraph, {
|
|
25
20
|
target: context.targetName,
|
|
26
21
|
root: context.root,
|
|
27
22
|
// By default we remove devDependencies since this is a production build.
|
|
@@ -34,7 +29,7 @@ function updatePackageJson(options, context, target, dependencies, fileMap = nul
|
|
|
34
29
|
}
|
|
35
30
|
else {
|
|
36
31
|
const pathToPackageJson = (0, path_1.join)(context.root, options.projectRoot, 'package.json');
|
|
37
|
-
packageJson = (0,
|
|
32
|
+
packageJson = (0, internal_1.fileExists)(pathToPackageJson)
|
|
38
33
|
? (0, devkit_1.readJsonFile)(pathToPackageJson)
|
|
39
34
|
: { name: context.projectName, version: '0.0.1' };
|
|
40
35
|
}
|
|
@@ -60,8 +55,8 @@ function updatePackageJson(options, context, target, dependencies, fileMap = nul
|
|
|
60
55
|
devkit_1.logger.warn(`Bun lockfile generation is unsupported. Remove "generateLockfile" option or set it to false.`);
|
|
61
56
|
}
|
|
62
57
|
else {
|
|
63
|
-
const lockFile = (0,
|
|
64
|
-
(0, node_fs_1.writeFileSync)(`${options.outputPath}/${(0,
|
|
58
|
+
const lockFile = (0, internal_1.createLockFile)(packageJson, context.projectGraph, packageManager);
|
|
59
|
+
(0, node_fs_1.writeFileSync)(`${options.outputPath}/${(0, internal_1.getLockFileName)(packageManager)}`, lockFile, {
|
|
65
60
|
encoding: 'utf-8',
|
|
66
61
|
});
|
|
67
62
|
}
|
|
@@ -8,8 +8,8 @@ exports.getProjectPackageManagerWorkspaceStateWarningTask = getProjectPackageMan
|
|
|
8
8
|
const devkit_1 = require("@nx/devkit");
|
|
9
9
|
const picomatch = require("picomatch");
|
|
10
10
|
const posix_1 = require("node:path/posix");
|
|
11
|
-
const package_json_1 = require("nx/src/plugins/package-json");
|
|
12
11
|
const semver_1 = require("semver");
|
|
12
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
13
13
|
function getProjectPackageManagerWorkspaceState(tree, projectRoot) {
|
|
14
14
|
if (!isUsingPackageManagerWorkspaces(tree)) {
|
|
15
15
|
return 'no-workspaces';
|
|
@@ -19,7 +19,7 @@ function getProjectPackageManagerWorkspaceState(tree, projectRoot) {
|
|
|
19
19
|
return isIncluded ? 'included' : 'excluded';
|
|
20
20
|
}
|
|
21
21
|
function getPackageManagerWorkspacesPatterns(tree) {
|
|
22
|
-
return (0,
|
|
22
|
+
return (0, internal_1.getGlobPatternsFromPackageManagerWorkspaces)(tree.root, (path) => (0, devkit_1.readJson)(tree, path, { expectComments: true }), (path) => {
|
|
23
23
|
const content = tree.read(path, 'utf-8');
|
|
24
24
|
const { load } = require('@zkochan/js-yaml');
|
|
25
25
|
return load(content, { filename: path });
|
|
@@ -4,7 +4,11 @@ exports.getSwcDependencies = getSwcDependencies;
|
|
|
4
4
|
exports.addSwcDependencies = addSwcDependencies;
|
|
5
5
|
exports.addSwcRegisterDependencies = addSwcRegisterDependencies;
|
|
6
6
|
const devkit_1 = require("@nx/devkit");
|
|
7
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
7
8
|
const versions_1 = require("../versions");
|
|
9
|
+
// @swc/core's postinstall only installs a wasm fallback for platforms not
|
|
10
|
+
// covered by its prebuilt optional dependencies, so skip it.
|
|
11
|
+
const swcAllowBuilds = { '@swc/core': false };
|
|
8
12
|
function getSwcDependencies() {
|
|
9
13
|
const dependencies = {
|
|
10
14
|
'@swc/helpers': versions_1.swcHelpersVersion,
|
|
@@ -17,8 +21,10 @@ function getSwcDependencies() {
|
|
|
17
21
|
}
|
|
18
22
|
function addSwcDependencies(tree) {
|
|
19
23
|
const { dependencies, devDependencies } = getSwcDependencies();
|
|
24
|
+
(0, internal_1.acknowledgeBuildScripts)(tree, (0, devkit_1.detectPackageManager)(tree.root), swcAllowBuilds);
|
|
20
25
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, dependencies, devDependencies, undefined, true);
|
|
21
26
|
}
|
|
22
27
|
function addSwcRegisterDependencies(tree) {
|
|
28
|
+
(0, internal_1.acknowledgeBuildScripts)(tree, (0, devkit_1.detectPackageManager)(tree.root), swcAllowBuilds);
|
|
23
29
|
return (0, devkit_1.addDependenciesToPackageJson)(tree, {}, { '@swc-node/register': versions_1.swcNodeVersion, '@swc/core': versions_1.swcCoreVersion }, undefined, true);
|
|
24
30
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getNeededCompilerOptionOverrides = getNeededCompilerOptionOverrides;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const ensure_typescript_1 = require("./ensure-typescript");
|
|
6
|
+
const ts_config_1 = require("./ts-config");
|
|
6
7
|
const optionEnumTypeMap = {
|
|
7
8
|
importsNotUsedAsValues: 'ImportsNotUsedAsValues',
|
|
8
9
|
jsx: 'JsxEmit',
|
|
@@ -21,11 +22,8 @@ function getNeededCompilerOptionOverrides(tree, compilerOptions, tsConfigPath) {
|
|
|
21
22
|
if (!ts) {
|
|
22
23
|
ts = (0, ensure_typescript_1.ensureTypescript)();
|
|
23
24
|
}
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
readFile: (path) => tree.read(path, 'utf-8'),
|
|
27
|
-
};
|
|
28
|
-
const parsed = ts.parseJsonConfigFileContent(ts.readConfigFile(tsConfigPath, tsSysFromTree.readFile).config, tsSysFromTree, (0, path_1.dirname)(tsConfigPath));
|
|
25
|
+
const host = (0, ts_config_1.createTreeParseConfigHost)(tree);
|
|
26
|
+
const parsed = ts.parseJsonConfigFileContent(ts.readConfigFile(tsConfigPath, host.readFile).config, host, (0, path_1.dirname)(tsConfigPath));
|
|
29
27
|
// ModuleKind: { CommonJS: 'commonjs', ... } => ModuleKind: { commonjs: 'CommonJS', ... }
|
|
30
28
|
const reversedCompilerOptionsEnumValues = {
|
|
31
29
|
JsxEmit: reverseEnum(ts.server.protocol.JsxEmit),
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.tsConfigBaseOptions = void 0;
|
|
4
4
|
exports.getTsConfigBaseOptions = getTsConfigBaseOptions;
|
|
5
5
|
exports.extractTsConfigBase = extractTsConfigBase;
|
|
6
|
-
const json_1 = require("nx/src/generators/utils/json");
|
|
7
6
|
const is_typescript_version_at_least_1 = require("../is-typescript-version-at-least");
|
|
7
|
+
const devkit_1 = require("@nx/devkit");
|
|
8
8
|
exports.tsConfigBaseOptions = {
|
|
9
9
|
rootDir: '.',
|
|
10
10
|
sourceMap: true,
|
|
@@ -32,7 +32,7 @@ function getTsConfigBaseOptions(tree) {
|
|
|
32
32
|
function extractTsConfigBase(host) {
|
|
33
33
|
if (host.exists('tsconfig.base.json'))
|
|
34
34
|
return;
|
|
35
|
-
const tsconfig = (0,
|
|
35
|
+
const tsconfig = (0, devkit_1.readJson)(host, 'tsconfig.json');
|
|
36
36
|
const baseCompilerOptions = {};
|
|
37
37
|
if (tsconfig.compilerOptions) {
|
|
38
38
|
for (let compilerOption of Object.keys(exports.tsConfigBaseOptions)) {
|
|
@@ -41,7 +41,7 @@ function extractTsConfigBase(host) {
|
|
|
41
41
|
delete tsconfig.compilerOptions[compilerOption];
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
(0,
|
|
44
|
+
(0, devkit_1.writeJson)(host, 'tsconfig.base.json', {
|
|
45
45
|
compileOnSave: false,
|
|
46
46
|
compilerOptions: baseCompilerOptions,
|
|
47
47
|
exclude: tsconfig.exclude,
|
|
@@ -49,10 +49,10 @@ function extractTsConfigBase(host) {
|
|
|
49
49
|
tsconfig.extends = './tsconfig.base.json';
|
|
50
50
|
delete tsconfig.compileOnSave;
|
|
51
51
|
delete tsconfig.exclude;
|
|
52
|
-
(0,
|
|
52
|
+
(0, devkit_1.writeJson)(host, 'tsconfig.json', tsconfig);
|
|
53
53
|
// special case for updating e2e tests.
|
|
54
54
|
if (host.exists('e2e/tsconfig.json')) {
|
|
55
|
-
(0,
|
|
55
|
+
(0, devkit_1.updateJson)(host, 'e2e/tsconfig.json', (json) => {
|
|
56
56
|
json.extends = '../tsconfig.base.json';
|
|
57
57
|
return json;
|
|
58
58
|
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ensureProjectIsIncludedInPluginRegistrations = ensureProjectIsIncludedInPluginRegistrations;
|
|
4
|
-
const devkit_internals_1 = require("nx/src/devkit-internals");
|
|
5
4
|
const picomatch = require("picomatch");
|
|
5
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
6
6
|
function ensureProjectIsIncludedInPluginRegistrations(nxJson, projectRoot, buildTargetName) {
|
|
7
7
|
nxJson.plugins ??= [];
|
|
8
8
|
let isIncluded = false;
|
|
@@ -32,7 +32,7 @@ function ensureProjectIsIncludedInPluginRegistrations(nxJson, projectRoot, build
|
|
|
32
32
|
// before the registration's include/exclude filters are applied.
|
|
33
33
|
const tsconfigPath = `${projectRoot}/tsconfig.json`;
|
|
34
34
|
const matchingConfigFiles = picomatch('**/tsconfig.json', { dot: true })(tsconfigPath)
|
|
35
|
-
? (0,
|
|
35
|
+
? (0, internal_1.findMatchingConfigFiles)([tsconfigPath], registration.include, registration.exclude)
|
|
36
36
|
: [];
|
|
37
37
|
if (matchingConfigFiles.length) {
|
|
38
38
|
// it's included by the plugin registration, check if the user-specified options would result
|
|
@@ -6,9 +6,9 @@ exports.getFormattedDiagnostic = getFormattedDiagnostic;
|
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
8
8
|
const path = tslib_1.__importStar(require("path"));
|
|
9
|
-
const code_frames_1 = require("nx/src/utils/code-frames");
|
|
10
9
|
const highlight_1 = require("../code-frames/highlight");
|
|
11
10
|
const ts_config_1 = require("../../utils/typescript/ts-config");
|
|
11
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
12
12
|
async function runTypeCheckWatch(options, callback) {
|
|
13
13
|
const { ts, workspaceRoot, config, compilerOptions } = await setupTypeScript(options);
|
|
14
14
|
const host = ts.createWatchCompilerHost(config.fileNames, compilerOptions, ts.sys, ts.createEmitAndSemanticDiagnosticsBuilderProgram);
|
|
@@ -133,7 +133,7 @@ function getFormattedDiagnostic(ts, workspaceRoot, diagnostic) {
|
|
|
133
133
|
const code = diagnostic.file.getFullText(diagnostic.file.getSourceFile());
|
|
134
134
|
message +=
|
|
135
135
|
'\n' +
|
|
136
|
-
(0,
|
|
136
|
+
(0, internal_1.codeFrameColumns)(code, {
|
|
137
137
|
start: { line: line, column },
|
|
138
138
|
}, { highlight: highlight_1.highlight });
|
|
139
139
|
}
|
|
@@ -1,7 +1,57 @@
|
|
|
1
1
|
import { Tree } from '@nx/devkit';
|
|
2
2
|
import type * as ts from 'typescript';
|
|
3
|
-
export declare function readTsConfig(tsConfigPath: string, sys?: ts.
|
|
3
|
+
export declare function readTsConfig(tsConfigPath: string, sys?: ts.ParseConfigHost): ts.ParsedCommandLine;
|
|
4
4
|
export declare function readTsConfigFromTree(tree: Tree, tsConfigPath: string): ts.ParsedCommandLine;
|
|
5
|
+
/**
|
|
6
|
+
* The members `createTreeParseConfigHost` overrides: the file system ones are
|
|
7
|
+
* backed by the `Tree`, `realpath`/`getCurrentDirectory` are anchored to
|
|
8
|
+
* `tree.root`, and `useCaseSensitiveFileNames` is platform-derived from
|
|
9
|
+
* `ts.sys`. The returned object still spreads `ts.sys` (TypeScript duck-types
|
|
10
|
+
* the host and reads members this type does not name), so the narrow type is a
|
|
11
|
+
* compile-time guard on Nx callers: everything outside it is disk-backed and
|
|
12
|
+
* escapes the tree.
|
|
13
|
+
*/
|
|
14
|
+
export type TreeParseConfigHost = Required<Pick<ts.ParseConfigHost, 'useCaseSensitiveFileNames' | 'readDirectory' | 'readFile' | 'fileExists' | 'directoryExists' | 'realpath' | 'getCurrentDirectory'>>;
|
|
15
|
+
/**
|
|
16
|
+
* A TypeScript host, backed by the devkit `Tree`, that resolves `extends` the
|
|
17
|
+
* way real `tsc` does. The naive `{ ...ts.sys, readFile: (p) => tree.read(p) }`
|
|
18
|
+
* host resolves less than `tsc`:
|
|
19
|
+
* - A package-form `extends` (e.g. `@tsconfig/node14/tsconfig.json`) is
|
|
20
|
+
* realpath-absolutized by TypeScript; `Tree.read`/`Tree.exists` re-root an
|
|
21
|
+
* absolute path under the workspace, so the base reads as nothing and its
|
|
22
|
+
* options silently vanish from the merged result (the failure surfaces only
|
|
23
|
+
* as a TS5083/TS6053 in `errors`, which callers discard).
|
|
24
|
+
* - An extension-less `extends` resolves against `process.cwd()` when
|
|
25
|
+
* existence comes from `ts.sys`; Nx never chdirs to the workspace root, so it
|
|
26
|
+
* resolves only when the command runs from the root.
|
|
27
|
+
*
|
|
28
|
+
* This host maps absolute paths under `tree.root` back to tree-relative for the
|
|
29
|
+
* tree lookups and falls through to `fs` for paths that resolve outside the
|
|
30
|
+
* workspace (a pnpm store or a `link:`/`file:` target). Resolution is anchored
|
|
31
|
+
* to `tree.root` rather than the working directory: TypeScript resolves a
|
|
32
|
+
* package-form base as a relative path and hands it to `realpath`, and
|
|
33
|
+
* `ts.sys.realpath` would resolve it against `process.cwd()`, so a workspace
|
|
34
|
+
* whose root is not an ancestor of the working directory would read a
|
|
35
|
+
* same-named package from the wrong tree.
|
|
36
|
+
*
|
|
37
|
+
* `readDirectory` is a no-op: the source-file scan is skipped because callers
|
|
38
|
+
* read only the merged `options`, never the file list. A config that resolves
|
|
39
|
+
* its inputs through `include` (or the default glob) then reports a TS18003
|
|
40
|
+
* unless it also carries `files` or `references`, so `errors.length > 0` is not
|
|
41
|
+
* a usable signal; match specific codes (TS5083/TS6053) instead.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createTreeParseConfigHost(tree: Tree): TreeParseConfigHost;
|
|
44
|
+
/**
|
|
45
|
+
* Whether a `ParsedCommandLine` produced with `createTreeParseConfigHost` failed
|
|
46
|
+
* to resolve an `extends` target: TS5083 (the base resolved but could not be
|
|
47
|
+
* read) or TS6053 (the base could not be resolved at all). Because the host
|
|
48
|
+
* resolves what real `tsc` resolves, this only fires for a config whose extends
|
|
49
|
+
* chain `tsc` cannot read either. The no-op `readDirectory` also adds a TS18003
|
|
50
|
+
* whenever the config resolves inputs through `include` and carries neither
|
|
51
|
+
* `files` nor `references`, so `errors.length > 0` is not a usable signal; match
|
|
52
|
+
* these two codes.
|
|
53
|
+
*/
|
|
54
|
+
export declare function extendsResolutionFailed(errors: readonly ts.Diagnostic[]): boolean;
|
|
5
55
|
export declare function getRootTsConfigPathInTree(tree: Tree): string | null;
|
|
6
56
|
export declare function getRelativePathToRootTsConfig(tree: Tree, targetPath: string): string;
|
|
7
57
|
export declare function getRootTsConfigPath(): string | null;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.readTsConfig = readTsConfig;
|
|
4
4
|
exports.readTsConfigFromTree = readTsConfigFromTree;
|
|
5
|
+
exports.createTreeParseConfigHost = createTreeParseConfigHost;
|
|
6
|
+
exports.extendsResolutionFailed = extendsResolutionFailed;
|
|
5
7
|
exports.getRootTsConfigPathInTree = getRootTsConfigPathInTree;
|
|
6
8
|
exports.getRelativePathToRootTsConfig = getRelativePathToRootTsConfig;
|
|
7
9
|
exports.getRootTsConfigPath = getRootTsConfigPath;
|
|
@@ -32,6 +34,118 @@ function readTsConfigFromTree(tree, tsConfigPath) {
|
|
|
32
34
|
};
|
|
33
35
|
return readTsConfig(tsConfigPath, tsSysFromTree);
|
|
34
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* A TypeScript host, backed by the devkit `Tree`, that resolves `extends` the
|
|
39
|
+
* way real `tsc` does. The naive `{ ...ts.sys, readFile: (p) => tree.read(p) }`
|
|
40
|
+
* host resolves less than `tsc`:
|
|
41
|
+
* - A package-form `extends` (e.g. `@tsconfig/node14/tsconfig.json`) is
|
|
42
|
+
* realpath-absolutized by TypeScript; `Tree.read`/`Tree.exists` re-root an
|
|
43
|
+
* absolute path under the workspace, so the base reads as nothing and its
|
|
44
|
+
* options silently vanish from the merged result (the failure surfaces only
|
|
45
|
+
* as a TS5083/TS6053 in `errors`, which callers discard).
|
|
46
|
+
* - An extension-less `extends` resolves against `process.cwd()` when
|
|
47
|
+
* existence comes from `ts.sys`; Nx never chdirs to the workspace root, so it
|
|
48
|
+
* resolves only when the command runs from the root.
|
|
49
|
+
*
|
|
50
|
+
* This host maps absolute paths under `tree.root` back to tree-relative for the
|
|
51
|
+
* tree lookups and falls through to `fs` for paths that resolve outside the
|
|
52
|
+
* workspace (a pnpm store or a `link:`/`file:` target). Resolution is anchored
|
|
53
|
+
* to `tree.root` rather than the working directory: TypeScript resolves a
|
|
54
|
+
* package-form base as a relative path and hands it to `realpath`, and
|
|
55
|
+
* `ts.sys.realpath` would resolve it against `process.cwd()`, so a workspace
|
|
56
|
+
* whose root is not an ancestor of the working directory would read a
|
|
57
|
+
* same-named package from the wrong tree.
|
|
58
|
+
*
|
|
59
|
+
* `readDirectory` is a no-op: the source-file scan is skipped because callers
|
|
60
|
+
* read only the merged `options`, never the file list. A config that resolves
|
|
61
|
+
* its inputs through `include` (or the default glob) then reports a TS18003
|
|
62
|
+
* unless it also carries `files` or `references`, so `errors.length > 0` is not
|
|
63
|
+
* a usable signal; match specific codes (TS5083/TS6053) instead.
|
|
64
|
+
*/
|
|
65
|
+
function createTreeParseConfigHost(tree) {
|
|
66
|
+
if (!tsModule) {
|
|
67
|
+
tsModule = (0, ensure_typescript_1.ensureTypescript)();
|
|
68
|
+
}
|
|
69
|
+
// Classify with `relative` rather than a string prefix: it normalizes
|
|
70
|
+
// separators, so an absolute path TypeScript hands over with forward slashes
|
|
71
|
+
// still matches a `tree.root` carrying platform separators, and it respects
|
|
72
|
+
// the segment boundary, so a sibling of the root (`/repo/core-utils` for
|
|
73
|
+
// `/repo/core`) is not taken for a path inside it.
|
|
74
|
+
const isOutsideRoot = (path) => {
|
|
75
|
+
if (!(0, path_1.isAbsolute)(path)) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const rel = (0, path_1.relative)(tree.root, path);
|
|
79
|
+
return rel === '..' || rel.startsWith(`..${path_1.sep}`) || (0, path_1.isAbsolute)(rel);
|
|
80
|
+
};
|
|
81
|
+
const toTreePath = (path) => (0, path_1.isAbsolute)(path) ? (0, path_1.relative)(tree.root, path) || '.' : path;
|
|
82
|
+
// `ts.sys` gates `readFile`/`fileExists` on `isFile`, so a directory is never
|
|
83
|
+
// read as a config file. Both branches mirror that, which lets an
|
|
84
|
+
// extension-less `extends` ("./config") that collides with a same-named
|
|
85
|
+
// directory fall through to its `.json` sibling. Out-of-root, a bare
|
|
86
|
+
// `existsSync` answers true for a directory and `readFileSync` on it throws
|
|
87
|
+
// EISDIR (TS5012, which the extends-failure guard does not catch); in-root,
|
|
88
|
+
// `tree.exists` also answers true for a directory, so `fileExists` gates on
|
|
89
|
+
// `tree.isFile`.
|
|
90
|
+
const isFileOnDisk = (path) => {
|
|
91
|
+
try {
|
|
92
|
+
return (0, fs_1.statSync)(path).isFile();
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const isDirectoryOnDisk = (path) => {
|
|
99
|
+
try {
|
|
100
|
+
return (0, fs_1.statSync)(path).isDirectory();
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
...tsModule.sys,
|
|
108
|
+
readDirectory: () => [],
|
|
109
|
+
getCurrentDirectory: () => tree.root,
|
|
110
|
+
// A relative path anchored to the workspace instead of `process.cwd()`; an
|
|
111
|
+
// absolute one still goes through `ts.sys` so a symlinked in-root
|
|
112
|
+
// `node_modules` entry resolves to its real (out-of-root) target.
|
|
113
|
+
realpath: (path) => tsModule.sys.realpath((0, path_1.isAbsolute)(path) ? path : (0, path_1.join)(tree.root, path)),
|
|
114
|
+
readFile: (path) => isOutsideRoot(path)
|
|
115
|
+
? isFileOnDisk(path)
|
|
116
|
+
? (0, fs_1.readFileSync)(path, 'utf-8')
|
|
117
|
+
: undefined
|
|
118
|
+
: (tree.read(toTreePath(path), 'utf-8') ?? undefined),
|
|
119
|
+
fileExists: (path) => {
|
|
120
|
+
if (isOutsideRoot(path)) {
|
|
121
|
+
return isFileOnDisk(path);
|
|
122
|
+
}
|
|
123
|
+
const treePath = toTreePath(path);
|
|
124
|
+
return tree.exists(treePath) && tree.isFile(treePath);
|
|
125
|
+
},
|
|
126
|
+
directoryExists: (path) => {
|
|
127
|
+
if (isOutsideRoot(path)) {
|
|
128
|
+
return isDirectoryOnDisk(path);
|
|
129
|
+
}
|
|
130
|
+
const treePath = toTreePath(path);
|
|
131
|
+
return tree.exists(treePath) && !tree.isFile(treePath);
|
|
132
|
+
},
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Whether a `ParsedCommandLine` produced with `createTreeParseConfigHost` failed
|
|
137
|
+
* to resolve an `extends` target: TS5083 (the base resolved but could not be
|
|
138
|
+
* read) or TS6053 (the base could not be resolved at all). Because the host
|
|
139
|
+
* resolves what real `tsc` resolves, this only fires for a config whose extends
|
|
140
|
+
* chain `tsc` cannot read either. The no-op `readDirectory` also adds a TS18003
|
|
141
|
+
* whenever the config resolves inputs through `include` and carries neither
|
|
142
|
+
* `files` nor `references`, so `errors.length > 0` is not a usable signal; match
|
|
143
|
+
* these two codes.
|
|
144
|
+
*/
|
|
145
|
+
function extendsResolutionFailed(errors) {
|
|
146
|
+
// 5083: Cannot read file '{0}'. 6053: File '{0}' not found.
|
|
147
|
+
return errors.some((error) => error.code === 5083 || error.code === 6053);
|
|
148
|
+
}
|
|
35
149
|
function getRootTsConfigPathInTree(tree) {
|
|
36
150
|
for (const path of ['tsconfig.base.json', 'tsconfig.json']) {
|
|
37
151
|
if (tree.exists(path)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ProjectConfiguration, type Tree } from '@nx/devkit';
|
|
2
|
-
import type { JsonInput } from 'nx/
|
|
2
|
+
import type { JsonInput } from '@nx/devkit/internal';
|
|
3
3
|
export declare const TS_SOLUTION_SETUP_TSCONFIG_INPUT: JsonInput;
|
|
4
4
|
export declare function isUsingTypeScriptPlugin(tree: Tree): boolean;
|
|
5
5
|
export declare function shouldConfigureTsSolutionSetup(tree: Tree, addPlugins: boolean, addTsPlugin?: boolean): boolean;
|
|
@@ -15,7 +15,7 @@ exports.getDefinedCustomConditionName = getDefinedCustomConditionName;
|
|
|
15
15
|
const devkit_1 = require("@nx/devkit");
|
|
16
16
|
const node_fs_1 = require("node:fs");
|
|
17
17
|
const posix_1 = require("node:path/posix");
|
|
18
|
-
const
|
|
18
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
19
19
|
const package_manager_workspaces_1 = require("../package-manager-workspaces");
|
|
20
20
|
const configuration_1 = require("./configuration");
|
|
21
21
|
exports.TS_SOLUTION_SETUP_TSCONFIG_INPUT = {
|
|
@@ -48,7 +48,7 @@ function shouldConfigureTsSolutionSetup(tree, addPlugins, addTsPlugin) {
|
|
|
48
48
|
return !tree.exists('tsconfig.base.json') && !tree.exists('tsconfig.json');
|
|
49
49
|
}
|
|
50
50
|
function isUsingTsSolutionSetup(tree) {
|
|
51
|
-
tree ??= new
|
|
51
|
+
tree ??= new internal_1.FsTree(devkit_1.workspaceRoot, false);
|
|
52
52
|
return ((0, package_manager_workspaces_1.isUsingPackageManagerWorkspaces)(tree) &&
|
|
53
53
|
isWorkspaceSetupWithTsSolution(tree));
|
|
54
54
|
}
|
|
@@ -113,7 +113,7 @@ function assertNotUsingTsSolutionSetup(tree, pluginName, generatorName) {
|
|
|
113
113
|
throw new Error(`The ${artifactString} doesn't yet support the existing TypeScript setup. See the error above.`);
|
|
114
114
|
}
|
|
115
115
|
function findRuntimeTsConfigName(projectRoot, tree) {
|
|
116
|
-
tree ??= new
|
|
116
|
+
tree ??= new internal_1.FsTree(devkit_1.workspaceRoot, false);
|
|
117
117
|
if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.app.json')))
|
|
118
118
|
return 'tsconfig.app.json';
|
|
119
119
|
if (tree.exists((0, devkit_1.joinPathFragments)(projectRoot, 'tsconfig.lib.json')))
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.watchForSingleFileChanges = watchForSingleFileChanges;
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
|
-
const client_1 = require("nx/src/daemon/client/client");
|
|
6
5
|
const path_1 = require("path");
|
|
6
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
7
7
|
async function watchForSingleFileChanges(projectName, projectRoot, relativeFilePath, callback) {
|
|
8
|
-
const unregisterFileWatcher = await
|
|
8
|
+
const unregisterFileWatcher = await internal_1.daemonClient.registerFileWatcher({ watchProjects: [projectName] }, (err, data) => {
|
|
9
9
|
if (err === 'reconnecting') {
|
|
10
10
|
// Silent - daemon restarts automatically on lockfile changes
|
|
11
11
|
return;
|
package/migrations.json
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"23-1-0-add-ignore-deprecations-for-ts6": {
|
|
33
33
|
"version": "23.1.0-beta.8",
|
|
34
|
-
"description": "Adds `\"ignoreDeprecations\": \"6.0\"` to tsconfig files whose compilerOptions (or ts-node.compilerOptions) carry a TypeScript 6 deprecated option value, set directly or inherited through `extends` including from a base this migration does not edit (e.g. moduleResolution node/node10/classic, baseUrl, target es5, esModuleInterop false, outFile, module amd/umd/system/none, alwaysStrict false, allowSyntheticDefaultImports false, downlevelIteration set). Also pins `\"strict\": false`, `\"noUncheckedSideEffectImports\": false`, `\"types\": [\"*\"]`, and `\"esModuleInterop\": false` in chain-root tsconfigs (no \"extends\") that lack each key, preserving pre-TS6 behavior where these defaults changed; `esModuleInterop` false is itself deprecated (removed in TS7) so it also receives `ignoreDeprecations`, deferring the interop change to the TS7 migration. Also adds `ignoreDeprecations` to every `tsconfig.json` (the exact name jest/ts-node auto-resolve when compiling a config file; ts-node injects a deprecated default `target: es5` there, so the load
|
|
34
|
+
"description": "Adds `\"ignoreDeprecations\": \"6.0\"` to tsconfig files whose compilerOptions (or ts-node.compilerOptions) carry a TypeScript 6 deprecated option value, set directly or inherited through `extends` including from a base this migration does not edit (e.g. moduleResolution node/node10/classic, baseUrl, target es5, esModuleInterop false, outFile, module amd/umd/system/none, alwaysStrict false, allowSyntheticDefaultImports false, downlevelIteration set). Also pins `\"strict\": false`, `\"noUncheckedSideEffectImports\": false`, `\"types\": [\"*\"]`, and `\"esModuleInterop\": false` in chain-root tsconfigs (no \"extends\") that lack each key, preserving pre-TS6 behavior where these defaults changed; `esModuleInterop` false is itself deprecated (removed in TS7) so it also receives `ignoreDeprecations`, deferring the interop change to the TS7 migration. Also adds `ignoreDeprecations` to every `tsconfig.json` (the exact name jest/ts-node auto-resolve when compiling a config file; ts-node injects a deprecated default `target: es5` there, so the load can hit a TS6 error even on a clean config), even one with no deprecated value of its own; a stale local `ignoreDeprecations` (e.g. `5.0`) that would otherwise override the inherited flag is upgraded.",
|
|
35
35
|
"requires": {
|
|
36
36
|
"typescript": ">=6.0.0"
|
|
37
37
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/js",
|
|
3
|
-
"version": "23.1.
|
|
3
|
+
"version": "23.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -120,9 +120,12 @@
|
|
|
120
120
|
}
|
|
121
121
|
},
|
|
122
122
|
"dependencies": {
|
|
123
|
-
"@babel/core": "^7.
|
|
123
|
+
"@babel/core": "^7.29.6",
|
|
124
124
|
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
125
125
|
"@babel/plugin-transform-class-properties": "^7.22.5",
|
|
126
|
+
"@babel/plugin-transform-class-static-block": "^7.22.5",
|
|
127
|
+
"@babel/plugin-transform-private-methods": "^7.22.5",
|
|
128
|
+
"@babel/plugin-transform-private-property-in-object": "^7.22.5",
|
|
126
129
|
"@babel/plugin-transform-runtime": "^7.23.2",
|
|
127
130
|
"@babel/preset-env": "^7.23.2",
|
|
128
131
|
"@babel/preset-typescript": "^7.22.5",
|
|
@@ -144,11 +147,11 @@
|
|
|
144
147
|
"source-map-support": "0.5.19",
|
|
145
148
|
"tinyglobby": "^0.2.12",
|
|
146
149
|
"tslib": "^2.3.0",
|
|
147
|
-
"@nx/devkit": "23.1.
|
|
148
|
-
"@nx/workspace": "23.1.
|
|
150
|
+
"@nx/devkit": "23.1.2",
|
|
151
|
+
"@nx/workspace": "23.1.2"
|
|
149
152
|
},
|
|
150
153
|
"devDependencies": {
|
|
151
|
-
"nx": "23.1.
|
|
154
|
+
"nx": "23.1.2"
|
|
152
155
|
},
|
|
153
156
|
"peerDependencies": {
|
|
154
157
|
"@swc/cli": ">=0.6.0 <0.9.0",
|