@rsbuild/plugin-type-check 1.3.6 → 1.4.0
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/README.md +24 -1
- package/dist/index.cjs +21 -12
- package/dist/index.js +21 -12
- package/package.json +11 -6
package/README.md
CHANGED
|
@@ -117,8 +117,11 @@ const defaultOptions = {
|
|
|
117
117
|
memoryLimit: 8192,
|
|
118
118
|
// use tsconfig of user project
|
|
119
119
|
configFile: tsconfigPath,
|
|
120
|
+
tsgo: false,
|
|
120
121
|
// use typescript of user project
|
|
121
|
-
typescriptPath:
|
|
122
|
+
typescriptPath: tsgo
|
|
123
|
+
? require.resolve('@typescript/native-preview/package.json')
|
|
124
|
+
: require.resolve('typescript'),
|
|
122
125
|
},
|
|
123
126
|
issue: {
|
|
124
127
|
// ignore types errors from node_modules
|
|
@@ -136,6 +139,26 @@ const defaultOptions = {
|
|
|
136
139
|
};
|
|
137
140
|
```
|
|
138
141
|
|
|
142
|
+
#### TypeScript Go support
|
|
143
|
+
|
|
144
|
+
TypeScript Go support is powered by `ts-checker-rspack-plugin`'s experimental, CLI-based integration for [typescript-go](https://github.com/microsoft/typescript-go). It runs the `tsgo` binary for type checking and can reduce type-checking time by about 5-10x.
|
|
145
|
+
|
|
146
|
+
To enable it, install `@typescript/native-preview` and set `typescript.tsgo` to `true`:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
pluginTypeCheck({
|
|
150
|
+
tsCheckerOptions: {
|
|
151
|
+
typescript: {
|
|
152
|
+
tsgo: true,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
When `tsgo` is enabled, the default `typescript.typescriptPath` resolves to `@typescript/native-preview/package.json`. If you set `typescript.typescriptPath` manually in `tsgo` mode, it must be an absolute path to `@typescript/native-preview/package.json`.
|
|
159
|
+
|
|
160
|
+
For supported options and limitations, see [ts-checker-rspack-plugin - TypeScript Go support](https://github.com/rstackjs/ts-checker-rspack-plugin#typescript-go-support).
|
|
161
|
+
|
|
139
162
|
#### Object Type
|
|
140
163
|
|
|
141
164
|
When the value of `tsCheckerOptions` is an object, it will be deeply merged with the default configuration.
|
package/dist/index.cjs
CHANGED
|
@@ -53,6 +53,17 @@ var external_json5_default = /*#__PURE__*/ __webpack_require__.n(external_json5_
|
|
|
53
53
|
const external_reduce_configs_namespaceObject = require("reduce-configs");
|
|
54
54
|
const external_ts_checker_rspack_plugin_namespaceObject = require("ts-checker-rspack-plugin");
|
|
55
55
|
const src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
|
|
56
|
+
const resolveProjectPackage = (packageName, rootPath)=>{
|
|
57
|
+
try {
|
|
58
|
+
return src_require.resolve(packageName, {
|
|
59
|
+
paths: [
|
|
60
|
+
rootPath
|
|
61
|
+
]
|
|
62
|
+
});
|
|
63
|
+
} catch {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
56
67
|
const PLUGIN_TYPE_CHECK_NAME = 'rsbuild:type-check';
|
|
57
68
|
const pluginTypeCheck = (options = {})=>({
|
|
58
69
|
name: PLUGIN_TYPE_CHECK_NAME,
|
|
@@ -68,26 +79,18 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
68
79
|
if (!tsconfigPath || false === enable) return;
|
|
69
80
|
if (checkedTsconfig.has(tsconfigPath) && checkedTsconfig.get(tsconfigPath) !== environment.name) return;
|
|
70
81
|
checkedTsconfig.set(tsconfigPath, environment.name);
|
|
71
|
-
let typescriptPath;
|
|
72
|
-
try {
|
|
73
|
-
typescriptPath = src_require.resolve("typescript", {
|
|
74
|
-
paths: [
|
|
75
|
-
api.context.rootPath
|
|
76
|
-
]
|
|
77
|
-
});
|
|
78
|
-
} catch {
|
|
79
|
-
logger.warn('"typescript" is not found in current project, Type checker will not work.');
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
82
|
const { references } = external_json5_default().parse(external_node_fs_default().readFileSync(tsconfigPath, 'utf-8'));
|
|
83
83
|
const useReference = Array.isArray(references) && references.length > 0;
|
|
84
|
+
const projectTypescriptPath = resolveProjectPackage("typescript", api.context.rootPath);
|
|
85
|
+
const projectTsgoPath = resolveProjectPackage("@typescript/native-preview/package.json", api.context.rootPath);
|
|
84
86
|
const defaultOptions = {
|
|
85
87
|
typescript: {
|
|
86
88
|
mode: 'readonly',
|
|
87
89
|
build: useReference,
|
|
88
90
|
memoryLimit: 8192,
|
|
89
91
|
configFile: tsconfigPath,
|
|
90
|
-
|
|
92
|
+
tsgo: false,
|
|
93
|
+
typescriptPath: projectTypescriptPath
|
|
91
94
|
},
|
|
92
95
|
issue: {
|
|
93
96
|
exclude: [
|
|
@@ -106,6 +109,12 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
106
109
|
config: tsCheckerOptions,
|
|
107
110
|
mergeFn: external_deepmerge_default()
|
|
108
111
|
});
|
|
112
|
+
if (mergedOptions.typescript && mergedOptions.typescript.tsgo && mergedOptions.typescript.typescriptPath === projectTypescriptPath) mergedOptions.typescript.typescriptPath = projectTsgoPath;
|
|
113
|
+
if (mergedOptions.typescript && !mergedOptions.typescript.typescriptPath) {
|
|
114
|
+
const typeCheckerPackage = mergedOptions.typescript.tsgo ? "@typescript/native-preview" : "typescript";
|
|
115
|
+
logger.warn(`"${typeCheckerPackage}" is not found in current project, Type checker will not work.`);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
109
118
|
if (isProd) logger.info('Type checker is enabled. It may take some time.');
|
|
110
119
|
chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(external_ts_checker_rspack_plugin_namespaceObject.TsCheckerRspackPlugin, [
|
|
111
120
|
mergedOptions
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,17 @@ import json5 from "json5";
|
|
|
5
5
|
import { reduceConfigs } from "reduce-configs";
|
|
6
6
|
import { TsCheckerRspackPlugin } from "ts-checker-rspack-plugin";
|
|
7
7
|
const src_require = createRequire(import.meta.url);
|
|
8
|
+
const resolveProjectPackage = (packageName, rootPath)=>{
|
|
9
|
+
try {
|
|
10
|
+
return src_require.resolve(packageName, {
|
|
11
|
+
paths: [
|
|
12
|
+
rootPath
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
} catch {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
8
19
|
const PLUGIN_TYPE_CHECK_NAME = 'rsbuild:type-check';
|
|
9
20
|
const pluginTypeCheck = (options = {})=>({
|
|
10
21
|
name: PLUGIN_TYPE_CHECK_NAME,
|
|
@@ -20,26 +31,18 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
20
31
|
if (!tsconfigPath || false === enable) return;
|
|
21
32
|
if (checkedTsconfig.has(tsconfigPath) && checkedTsconfig.get(tsconfigPath) !== environment.name) return;
|
|
22
33
|
checkedTsconfig.set(tsconfigPath, environment.name);
|
|
23
|
-
let typescriptPath;
|
|
24
|
-
try {
|
|
25
|
-
typescriptPath = src_require.resolve("typescript", {
|
|
26
|
-
paths: [
|
|
27
|
-
api.context.rootPath
|
|
28
|
-
]
|
|
29
|
-
});
|
|
30
|
-
} catch {
|
|
31
|
-
logger.warn('"typescript" is not found in current project, Type checker will not work.');
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
34
|
const { references } = json5.parse(node_fs.readFileSync(tsconfigPath, 'utf-8'));
|
|
35
35
|
const useReference = Array.isArray(references) && references.length > 0;
|
|
36
|
+
const projectTypescriptPath = resolveProjectPackage("typescript", api.context.rootPath);
|
|
37
|
+
const projectTsgoPath = resolveProjectPackage("@typescript/native-preview/package.json", api.context.rootPath);
|
|
36
38
|
const defaultOptions = {
|
|
37
39
|
typescript: {
|
|
38
40
|
mode: 'readonly',
|
|
39
41
|
build: useReference,
|
|
40
42
|
memoryLimit: 8192,
|
|
41
43
|
configFile: tsconfigPath,
|
|
42
|
-
|
|
44
|
+
tsgo: false,
|
|
45
|
+
typescriptPath: projectTypescriptPath
|
|
43
46
|
},
|
|
44
47
|
issue: {
|
|
45
48
|
exclude: [
|
|
@@ -58,6 +61,12 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
58
61
|
config: tsCheckerOptions,
|
|
59
62
|
mergeFn: deepmerge
|
|
60
63
|
});
|
|
64
|
+
if (mergedOptions.typescript && mergedOptions.typescript.tsgo && mergedOptions.typescript.typescriptPath === projectTypescriptPath) mergedOptions.typescript.typescriptPath = projectTsgoPath;
|
|
65
|
+
if (mergedOptions.typescript && !mergedOptions.typescript.typescriptPath) {
|
|
66
|
+
const typeCheckerPackage = mergedOptions.typescript.tsgo ? "@typescript/native-preview" : "typescript";
|
|
67
|
+
logger.warn(`"${typeCheckerPackage}" is not found in current project, Type checker will not work.`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
61
70
|
if (isProd) logger.info('Type checker is enabled. It may take some time.');
|
|
62
71
|
chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(TsCheckerRspackPlugin, [
|
|
63
72
|
mergedOptions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-type-check",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"repository": "https://github.com/rstackjs/rsbuild-plugin-type-check",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"deepmerge": "^4.3.1",
|
|
23
|
-
"ts-checker-rspack-plugin": "^1.3.1",
|
|
24
23
|
"json5": "^2.2.3",
|
|
25
|
-
"reduce-configs": "^1.1.2"
|
|
24
|
+
"reduce-configs": "^1.1.2",
|
|
25
|
+
"ts-checker-rspack-plugin": "^1.4.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@playwright/test": "^1.60.0",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@rslint/core": "^0.5.3",
|
|
32
32
|
"@types/fs-extra": "^11.0.4",
|
|
33
33
|
"@types/node": "^24.12.4",
|
|
34
|
+
"@typescript/native-preview": "7.0.0-dev.20260607.1",
|
|
34
35
|
"fs-extra": "^11.3.5",
|
|
35
36
|
"playwright": "^1.60.0",
|
|
36
37
|
"prettier": "^3.8.3",
|
|
@@ -38,11 +39,15 @@
|
|
|
38
39
|
"typescript": "^6.0.3"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
|
-
"@rsbuild/core": "^1.0.0 || ^2.0.0"
|
|
42
|
+
"@rsbuild/core": "^1.0.0 || ^2.0.0-0",
|
|
43
|
+
"@typescript/native-preview": "^7.0.0-0"
|
|
42
44
|
},
|
|
43
45
|
"peerDependenciesMeta": {
|
|
44
46
|
"@rsbuild/core": {
|
|
45
47
|
"optional": true
|
|
48
|
+
},
|
|
49
|
+
"@typescript/native-preview": {
|
|
50
|
+
"optional": true
|
|
46
51
|
}
|
|
47
52
|
},
|
|
48
53
|
"publishConfig": {
|
|
@@ -51,10 +56,10 @@
|
|
|
51
56
|
},
|
|
52
57
|
"scripts": {
|
|
53
58
|
"build": "rslib",
|
|
59
|
+
"bump": "npx bumpp",
|
|
54
60
|
"dev": "rslib -w",
|
|
55
61
|
"lint": "rslint && prettier -c .",
|
|
56
62
|
"lint:write": "rslint --fix && prettier -w .",
|
|
57
|
-
"test": "playwright test"
|
|
58
|
-
"bump": "npx bumpp"
|
|
63
|
+
"test": "playwright test"
|
|
59
64
|
}
|
|
60
65
|
}
|