@nx/js 23.1.0-beta.6 → 23.1.0-beta.7
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/src/executors/tsc/tsc.impl.js +6 -2
- package/dist/src/migrations/update-23-1-0/add-ignore-deprecations-for-ts6.d.ts +20 -9
- package/dist/src/migrations/update-23-1-0/add-ignore-deprecations-for-ts6.js +31 -13
- package/dist/src/migrations/update-23-1-0/add-ignore-deprecations-for-ts6.md +5 -4
- package/migrations.json +1 -1
- package/package.json +4 -4
|
@@ -55,8 +55,12 @@ function createTypeScriptCompilationOptions(normalizedOptions, context) {
|
|
|
55
55
|
outputPath: (0, devkit_1.joinPathFragments)(normalizedOptions.outputPath),
|
|
56
56
|
projectName: context.projectName,
|
|
57
57
|
projectRoot: normalizedOptions.projectRoot,
|
|
58
|
-
rootDir
|
|
59
|
-
|
|
58
|
+
// Keep the Windows drive letter on rootDir/tsConfig (only forward-slash them).
|
|
59
|
+
// joinPathFragments strips it via normalizePath, leaving them drive-less while
|
|
60
|
+
// the generated path mappings stay absolute drive-full, so alias-resolved files
|
|
61
|
+
// fail TypeScript's rootDir containment check (TS6059) on Windows.
|
|
62
|
+
rootDir: normalizedOptions.rootDir.replace(/\\/g, '/'),
|
|
63
|
+
tsConfig: normalizedOptions.tsConfig.replace(/\\/g, '/'),
|
|
60
64
|
watch: normalizedOptions.watch,
|
|
61
65
|
deleteOutputPath: normalizedOptions.clean,
|
|
62
66
|
getCustomTransformers: (0, lib_1.getCustomTrasformersFactory)(normalizedOptions.transformers),
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { type Tree } from '@nx/devkit';
|
|
2
2
|
/**
|
|
3
|
-
* Two
|
|
3
|
+
* Two passes over every tsconfig*.json in the workspace. The default-preserving
|
|
4
|
+
* pass runs first, then the ignoreDeprecations pass, so a default it pins to a
|
|
5
|
+
* now-deprecated value ("esModuleInterop": false) is picked up and silenced by
|
|
6
|
+
* the deprecation pass in the same run.
|
|
4
7
|
*
|
|
5
|
-
* 1.
|
|
6
|
-
* compilerOptions (or ts-node.compilerOptions) block that directly carries a
|
|
7
|
-
* TS6 hard-deprecated option value (moduleResolution node/node10/classic,
|
|
8
|
-
* baseUrl, target es5, esModuleInterop false, outFile, module
|
|
9
|
-
* amd/umd/system/none, alwaysStrict false, allowSyntheticDefaultImports
|
|
10
|
-
* false, downlevelIteration set to any value).
|
|
11
|
-
*
|
|
12
|
-
* 2. default-preserving pass - for every chain root (no "extends" key), pins
|
|
8
|
+
* 1. default-preserving pass - for every chain root (no "extends" key), pins
|
|
13
9
|
* the TS6 compiler-option defaults that changed in a way that breaks existing
|
|
14
10
|
* workspaces back to their pre-TS6 value, but only when the root does not set
|
|
15
11
|
* them explicitly:
|
|
@@ -23,10 +19,25 @@ import { type Tree } from '@nx/devkit';
|
|
|
23
19
|
* whereas TS5 loaded them all; the "*" wildcard restores that default so
|
|
24
20
|
* a config relying on it (e.g. ts-node type-checking jest.config.ts)
|
|
25
21
|
* keeps finding @types/node.
|
|
22
|
+
* - "esModuleInterop": false - TS6 flips its default from false to true, so
|
|
23
|
+
* `import * as x from '<cjs>'` that used to bind x to the callable module
|
|
24
|
+
* now binds a non-callable namespace object, breaking any call/`new` on
|
|
25
|
+
* such an import at runtime. Pinning false restores the pre-TS6 behavior.
|
|
26
|
+
* Unlike the others, false is itself deprecated in TS6 (removed in TS7),
|
|
27
|
+
* which is why this pass must precede the ignoreDeprecations pass; it
|
|
28
|
+
* defers the interop change to the eventual TS7 migration.
|
|
26
29
|
* Files with "extends" inherit from their chain root and are left untouched.
|
|
27
30
|
* Pure solution-style containers (root has `"files": []` and no "include")
|
|
28
31
|
* select no source files, so pinning there is noise and they are skipped.
|
|
29
32
|
*
|
|
33
|
+
* 2. ignoreDeprecations pass - adds `ignoreDeprecations: "6.0"` to any
|
|
34
|
+
* compilerOptions (or ts-node.compilerOptions) block that directly carries a
|
|
35
|
+
* TS6 hard-deprecated option value (moduleResolution node/node10/classic,
|
|
36
|
+
* baseUrl, target es5, esModuleInterop false, outFile, module
|
|
37
|
+
* amd/umd/system/none, alwaysStrict false, allowSyntheticDefaultImports
|
|
38
|
+
* false, downlevelIteration set to any value), including an "esModuleInterop":
|
|
39
|
+
* false the default-preserving pass just added.
|
|
40
|
+
*
|
|
30
41
|
* Only runs on TS6 workspaces (gated by `requires` in migrations.json), because
|
|
31
42
|
* `ignoreDeprecations: "6.0"` is itself a hard error (TS5103) on TS 5.x.
|
|
32
43
|
*/
|
|
@@ -8,16 +8,12 @@ const FORMATTING_OPTIONS = {
|
|
|
8
8
|
formattingOptions: { keepLines: true, insertSpaces: true, tabSize: 2 },
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
11
|
-
* Two
|
|
11
|
+
* Two passes over every tsconfig*.json in the workspace. The default-preserving
|
|
12
|
+
* pass runs first, then the ignoreDeprecations pass, so a default it pins to a
|
|
13
|
+
* now-deprecated value ("esModuleInterop": false) is picked up and silenced by
|
|
14
|
+
* the deprecation pass in the same run.
|
|
12
15
|
*
|
|
13
|
-
* 1.
|
|
14
|
-
* compilerOptions (or ts-node.compilerOptions) block that directly carries a
|
|
15
|
-
* TS6 hard-deprecated option value (moduleResolution node/node10/classic,
|
|
16
|
-
* baseUrl, target es5, esModuleInterop false, outFile, module
|
|
17
|
-
* amd/umd/system/none, alwaysStrict false, allowSyntheticDefaultImports
|
|
18
|
-
* false, downlevelIteration set to any value).
|
|
19
|
-
*
|
|
20
|
-
* 2. default-preserving pass - for every chain root (no "extends" key), pins
|
|
16
|
+
* 1. default-preserving pass - for every chain root (no "extends" key), pins
|
|
21
17
|
* the TS6 compiler-option defaults that changed in a way that breaks existing
|
|
22
18
|
* workspaces back to their pre-TS6 value, but only when the root does not set
|
|
23
19
|
* them explicitly:
|
|
@@ -31,10 +27,25 @@ const FORMATTING_OPTIONS = {
|
|
|
31
27
|
* whereas TS5 loaded them all; the "*" wildcard restores that default so
|
|
32
28
|
* a config relying on it (e.g. ts-node type-checking jest.config.ts)
|
|
33
29
|
* keeps finding @types/node.
|
|
30
|
+
* - "esModuleInterop": false - TS6 flips its default from false to true, so
|
|
31
|
+
* `import * as x from '<cjs>'` that used to bind x to the callable module
|
|
32
|
+
* now binds a non-callable namespace object, breaking any call/`new` on
|
|
33
|
+
* such an import at runtime. Pinning false restores the pre-TS6 behavior.
|
|
34
|
+
* Unlike the others, false is itself deprecated in TS6 (removed in TS7),
|
|
35
|
+
* which is why this pass must precede the ignoreDeprecations pass; it
|
|
36
|
+
* defers the interop change to the eventual TS7 migration.
|
|
34
37
|
* Files with "extends" inherit from their chain root and are left untouched.
|
|
35
38
|
* Pure solution-style containers (root has `"files": []` and no "include")
|
|
36
39
|
* select no source files, so pinning there is noise and they are skipped.
|
|
37
40
|
*
|
|
41
|
+
* 2. ignoreDeprecations pass - adds `ignoreDeprecations: "6.0"` to any
|
|
42
|
+
* compilerOptions (or ts-node.compilerOptions) block that directly carries a
|
|
43
|
+
* TS6 hard-deprecated option value (moduleResolution node/node10/classic,
|
|
44
|
+
* baseUrl, target es5, esModuleInterop false, outFile, module
|
|
45
|
+
* amd/umd/system/none, alwaysStrict false, allowSyntheticDefaultImports
|
|
46
|
+
* false, downlevelIteration set to any value), including an "esModuleInterop":
|
|
47
|
+
* false the default-preserving pass just added.
|
|
48
|
+
*
|
|
38
49
|
* Only runs on TS6 workspaces (gated by `requires` in migrations.json), because
|
|
39
50
|
* `ignoreDeprecations: "6.0"` is itself a hard error (TS5103) on TS 5.x.
|
|
40
51
|
*/
|
|
@@ -46,18 +57,20 @@ async function default_1(tree) {
|
|
|
46
57
|
if (!name.startsWith('tsconfig') || !name.endsWith('.json')) {
|
|
47
58
|
return;
|
|
48
59
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
60
|
+
// Pin defaults first: a pinned "esModuleInterop": false is a deprecated
|
|
61
|
+
// value the deprecation pass then silences.
|
|
52
62
|
if (pinPreTs6Defaults(tree, filePath)) {
|
|
53
63
|
defaultsPinCount += 1;
|
|
54
64
|
}
|
|
65
|
+
if (addIgnoreDeprecations(tree, filePath)) {
|
|
66
|
+
deprecationCount += 1;
|
|
67
|
+
}
|
|
55
68
|
});
|
|
56
69
|
if (deprecationCount > 0) {
|
|
57
70
|
devkit_1.logger.info(`Added "ignoreDeprecations": "6.0" to ${deprecationCount} tsconfig file(s) carrying TS6-deprecated options.`);
|
|
58
71
|
}
|
|
59
72
|
if (defaultsPinCount > 0) {
|
|
60
|
-
devkit_1.logger.info(`Pinned pre-TS6 compiler option defaults ("strict", "noUncheckedSideEffectImports", "types") on ${defaultsPinCount} tsconfig chain root(s) to preserve existing behavior.`);
|
|
73
|
+
devkit_1.logger.info(`Pinned pre-TS6 compiler option defaults ("strict", "noUncheckedSideEffectImports", "types", "esModuleInterop") on ${defaultsPinCount} tsconfig chain root(s) to preserve existing behavior.`);
|
|
61
74
|
}
|
|
62
75
|
await (0, devkit_1.formatFiles)(tree);
|
|
63
76
|
}
|
|
@@ -151,6 +164,11 @@ const DEFAULT_PRESERVING_PINS = [
|
|
|
151
164
|
['noUncheckedSideEffectImports', false],
|
|
152
165
|
// TS6 loads no @types when `types` is unset (TS5 loaded all); "*" restores it.
|
|
153
166
|
['types', ['*']],
|
|
167
|
+
// TS6 flips esModuleInterop's default false->true, changing `import * as
|
|
168
|
+
// <cjs>` call semantics at runtime; false preserves pre-TS6 behavior. It is
|
|
169
|
+
// itself deprecated (removed in TS7), so the deprecation pass (run after this
|
|
170
|
+
// one) silences it. See the file-level doc for the ordering rationale.
|
|
171
|
+
['esModuleInterop', false],
|
|
154
172
|
];
|
|
155
173
|
function pinPreTs6Defaults(tree, tsconfigPath) {
|
|
156
174
|
const original = tree.read(tsconfigPath, 'utf-8');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
TypeScript 6 turns several long-deprecated compiler options into hard errors and flips a few option defaults to stricter values. So that an existing workspace keeps compiling on TypeScript 6 without being migrated to a full TypeScript 6 setup, this migration makes two edits to the `tsconfig*.json` files in the workspace:
|
|
4
4
|
|
|
5
5
|
- Adds `"ignoreDeprecations": "6.0"` to any `compilerOptions` (or `ts-node.compilerOptions`) block that directly sets a TypeScript 6 deprecated option - for example `moduleResolution` set to `node`/`node10`/`classic`, `baseUrl`, `target` set to `es5`, `esModuleInterop: false`, `outFile`, `module` set to `amd`/`umd`/`system`/`none`, `alwaysStrict: false`, `allowSyntheticDefaultImports: false`, or `downlevelIteration`.
|
|
6
|
-
- Pins `"strict": false`, `"noUncheckedSideEffectImports": false`,
|
|
6
|
+
- Pins `"strict": false`, `"noUncheckedSideEffectImports": false`, `"types": ["*"]`, and `"esModuleInterop": false` on every chain-root tsconfig (one without an `extends`) that does not already set them. TypeScript 6 treats an absent `strict` as `true` (it was `false` when unset before), defaults `noUncheckedSideEffectImports` to `true` (which turns a bare side-effect import such as `import './styles.css'` without an ambient module declaration into an error), no longer auto-loads every `@types` package when `types` is unset the way TypeScript 5 did (the `"*"` wildcard restores that last default), and flips `esModuleInterop` from `false` to `true` (so an `import * as x from '<cjs>'` binds a non-callable namespace object and a call or `new` on that import fails at runtime). Pinning all four preserves the pre-TypeScript 6 behavior. Because `esModuleInterop: false` is itself a TypeScript 6 deprecated value, this pin runs before the `ignoreDeprecations` edit above, so the added `false` is silenced in the same run.
|
|
7
7
|
|
|
8
8
|
Files that use `extends` inherit these settings from their chain root and are left untouched, and pure solution-style tsconfigs (`"files": []` with no `include`) are skipped. The migration only runs when the workspace is on TypeScript 6.
|
|
9
9
|
|
|
@@ -23,16 +23,17 @@ Files that use `extends` inherit these settings from their chain root and are le
|
|
|
23
23
|
|
|
24
24
|
##### After
|
|
25
25
|
|
|
26
|
-
```json title="tsconfig.json" {6-
|
|
26
|
+
```json title="tsconfig.json" {6-10}
|
|
27
27
|
{
|
|
28
28
|
"compilerOptions": {
|
|
29
29
|
"target": "es5",
|
|
30
30
|
"module": "esnext",
|
|
31
31
|
"moduleResolution": "bundler",
|
|
32
|
-
"ignoreDeprecations": "6.0",
|
|
33
32
|
"strict": false,
|
|
34
33
|
"noUncheckedSideEffectImports": false,
|
|
35
|
-
"types": ["*"]
|
|
34
|
+
"types": ["*"],
|
|
35
|
+
"esModuleInterop": false,
|
|
36
|
+
"ignoreDeprecations": "6.0"
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
```
|
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.0",
|
|
34
|
-
"description": "Adds `\"ignoreDeprecations\": \"6.0\"` to tsconfig files whose compilerOptions (or ts-node.compilerOptions) directly carry a TypeScript 6 deprecated option value (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`,
|
|
34
|
+
"description": "Adds `\"ignoreDeprecations\": \"6.0\"` to tsconfig files whose compilerOptions (or ts-node.compilerOptions) directly carry a TypeScript 6 deprecated option value (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.",
|
|
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.0-beta.
|
|
3
|
+
"version": "23.1.0-beta.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -144,11 +144,11 @@
|
|
|
144
144
|
"source-map-support": "0.5.19",
|
|
145
145
|
"tinyglobby": "^0.2.12",
|
|
146
146
|
"tslib": "^2.3.0",
|
|
147
|
-
"@nx/
|
|
148
|
-
"@nx/
|
|
147
|
+
"@nx/workspace": "23.1.0-beta.7",
|
|
148
|
+
"@nx/devkit": "23.1.0-beta.7"
|
|
149
149
|
},
|
|
150
150
|
"devDependencies": {
|
|
151
|
-
"nx": "23.1.0-beta.
|
|
151
|
+
"nx": "23.1.0-beta.7"
|
|
152
152
|
},
|
|
153
153
|
"peerDependencies": {
|
|
154
154
|
"@swc/cli": ">=0.6.0 <0.9.0",
|