@rsbuild/plugin-type-check 1.3.3 → 1.3.5
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 +16 -13
- package/dist/index.cjs +5 -5
- package/dist/index.js +1 -1
- package/package.json +22 -29
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ Add plugin to your `rsbuild.config.ts`:
|
|
|
35
35
|
|
|
36
36
|
```ts
|
|
37
37
|
// rsbuild.config.ts
|
|
38
|
-
import { pluginTypeCheck } from
|
|
38
|
+
import { pluginTypeCheck } from '@rsbuild/plugin-type-check';
|
|
39
39
|
|
|
40
40
|
export default {
|
|
41
41
|
plugins: [pluginTypeCheck()],
|
|
@@ -86,7 +86,7 @@ Enable type checking only in production mode:
|
|
|
86
86
|
|
|
87
87
|
```js
|
|
88
88
|
pluginTypeCheck({
|
|
89
|
-
enable: process.env.NODE_ENV ===
|
|
89
|
+
enable: process.env.NODE_ENV === 'production',
|
|
90
90
|
});
|
|
91
91
|
```
|
|
92
92
|
|
|
@@ -94,7 +94,7 @@ Enable type checking only in development mode (it is not recommended to disable
|
|
|
94
94
|
|
|
95
95
|
```js
|
|
96
96
|
pluginTypeCheck({
|
|
97
|
-
enable: process.env.NODE_ENV ===
|
|
97
|
+
enable: process.env.NODE_ENV === 'development',
|
|
98
98
|
});
|
|
99
99
|
```
|
|
100
100
|
|
|
@@ -110,7 +110,7 @@ const defaultOptions = {
|
|
|
110
110
|
typescript: {
|
|
111
111
|
// set 'readonly' to avoid emitting tsbuildinfo,
|
|
112
112
|
// as the generated tsbuildinfo will break ts-checker-rspack-plugin
|
|
113
|
-
mode:
|
|
113
|
+
mode: 'readonly',
|
|
114
114
|
// enable build when using project reference
|
|
115
115
|
build: useReference,
|
|
116
116
|
// avoid OOM issue
|
|
@@ -118,11 +118,11 @@ const defaultOptions = {
|
|
|
118
118
|
// use tsconfig of user project
|
|
119
119
|
configFile: tsconfigPath,
|
|
120
120
|
// use typescript of user project
|
|
121
|
-
typescriptPath: require.resolve(
|
|
121
|
+
typescriptPath: require.resolve('typescript'),
|
|
122
122
|
},
|
|
123
123
|
issue: {
|
|
124
124
|
// ignore types errors from node_modules
|
|
125
|
-
exclude: [({ file =
|
|
125
|
+
exclude: [({ file = '' }) => /[\\/]node_modules[\\/]/.test(file)],
|
|
126
126
|
},
|
|
127
127
|
logger: {
|
|
128
128
|
log() {
|
|
@@ -130,7 +130,7 @@ const defaultOptions = {
|
|
|
130
130
|
// we only want to display error messages
|
|
131
131
|
},
|
|
132
132
|
error(message: string) {
|
|
133
|
-
console.error(message.replace(/ERROR/g,
|
|
133
|
+
console.error(message.replace(/ERROR/g, 'Type Error'));
|
|
134
134
|
},
|
|
135
135
|
},
|
|
136
136
|
};
|
|
@@ -144,7 +144,7 @@ When the value of `tsCheckerOptions` is an object, it will be deeply merged with
|
|
|
144
144
|
pluginTypeCheck({
|
|
145
145
|
tsCheckerOptions: {
|
|
146
146
|
issue: {
|
|
147
|
-
exclude: [({ file =
|
|
147
|
+
exclude: [({ file = '' }) => /[\\/]some-folder[\\/]/.test(file)],
|
|
148
148
|
},
|
|
149
149
|
},
|
|
150
150
|
});
|
|
@@ -174,7 +174,7 @@ pluginTypeCheck({
|
|
|
174
174
|
tsCheckerOptions: {
|
|
175
175
|
issue: {
|
|
176
176
|
// Ignore "Argument of type 'string' is not assignable to parameter of type 'number'.ts(2345)"
|
|
177
|
-
exclude: [{ code:
|
|
177
|
+
exclude: [{ code: 'TS2345' }],
|
|
178
178
|
},
|
|
179
179
|
},
|
|
180
180
|
});
|
|
@@ -186,7 +186,7 @@ Or exclude files under `/some-folder/` using `file`:
|
|
|
186
186
|
pluginTypeCheck({
|
|
187
187
|
tsCheckerOptions: {
|
|
188
188
|
issue: {
|
|
189
|
-
exclude: [({ file =
|
|
189
|
+
exclude: [({ file = '' }) => /[\\/]some-folder[\\/]/.test(file)],
|
|
190
190
|
},
|
|
191
191
|
},
|
|
192
192
|
});
|
|
@@ -206,6 +206,7 @@ pluginTypeCheck({
|
|
|
206
206
|
},
|
|
207
207
|
});
|
|
208
208
|
```
|
|
209
|
+
|
|
209
210
|
## Notes
|
|
210
211
|
|
|
211
212
|
- If you have enabled `ts-loader` in your project and manually configured `compileOnly: false`, please disable the Type Check plugin to avoid duplicate type checking.
|
|
@@ -213,7 +214,9 @@ pluginTypeCheck({
|
|
|
213
214
|
|
|
214
215
|
## Performance Optimization
|
|
215
216
|
|
|
216
|
-
|
|
217
|
+
This plugin delegates type checking to TypeScript, so overall performance is mostly determined by `tsc` itself.
|
|
218
|
+
|
|
219
|
+
If you need faster type checks, start by optimizing your TypeScript setup using the [official TypeScript performance guide](https://github.com/microsoft/TypeScript/wiki/Performance).
|
|
217
220
|
|
|
218
221
|
For example, properly configuring the `include` and `exclude` scopes in `tsconfig.json` can significantly reduce unnecessary type checking and improve TypeScript performance:
|
|
219
222
|
|
|
@@ -236,8 +239,8 @@ npm add @esctn/vue-tsc-api -D
|
|
|
236
239
|
pluginTypeCheck({
|
|
237
240
|
tsCheckerOptions: {
|
|
238
241
|
typescript: {
|
|
239
|
-
typescriptPath: '@esctn/vue-tsc-api'
|
|
240
|
-
}
|
|
242
|
+
typescriptPath: '@esctn/vue-tsc-api',
|
|
243
|
+
},
|
|
241
244
|
},
|
|
242
245
|
});
|
|
243
246
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
3
|
-
return
|
|
3
|
+
return "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
4
4
|
}();
|
|
5
5
|
var __webpack_require__ = {};
|
|
6
6
|
(()=>{
|
|
@@ -25,7 +25,7 @@ var __webpack_require__ = {};
|
|
|
25
25
|
})();
|
|
26
26
|
(()=>{
|
|
27
27
|
__webpack_require__.r = (exports1)=>{
|
|
28
|
-
if (
|
|
28
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
29
29
|
value: 'Module'
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports1, '__esModule', {
|
|
@@ -71,7 +71,7 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
71
71
|
api.context.rootPath
|
|
72
72
|
]
|
|
73
73
|
});
|
|
74
|
-
} catch
|
|
74
|
+
} catch {
|
|
75
75
|
logger.warn('"typescript" is not found in current project, Type checker will not work.');
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
@@ -111,10 +111,10 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
111
111
|
});
|
|
112
112
|
exports.PLUGIN_TYPE_CHECK_NAME = __webpack_exports__.PLUGIN_TYPE_CHECK_NAME;
|
|
113
113
|
exports.pluginTypeCheck = __webpack_exports__.pluginTypeCheck;
|
|
114
|
-
for(var
|
|
114
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
115
115
|
"PLUGIN_TYPE_CHECK_NAME",
|
|
116
116
|
"pluginTypeCheck"
|
|
117
|
-
].indexOf(
|
|
117
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
118
118
|
Object.defineProperty(exports, '__esModule', {
|
|
119
119
|
value: true
|
|
120
120
|
});
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-type-check",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"repository": "https://github.com/rstackjs/rsbuild-plugin-type-check",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -17,41 +17,27 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "rslib build",
|
|
22
|
-
"dev": "rslib build --watch",
|
|
23
|
-
"lint": "biome check .",
|
|
24
|
-
"lint:write": "biome check . --write",
|
|
25
|
-
"prepare": "simple-git-hooks && npm run build",
|
|
26
|
-
"test": "playwright test",
|
|
27
|
-
"bump": "npx bumpp"
|
|
28
|
-
},
|
|
29
20
|
"simple-git-hooks": {
|
|
30
|
-
"pre-commit": "
|
|
31
|
-
},
|
|
32
|
-
"nano-staged": {
|
|
33
|
-
"*.{js,jsx,ts,tsx,mjs,cjs}": [
|
|
34
|
-
"biome check --write --no-errors-on-unmatched"
|
|
35
|
-
]
|
|
21
|
+
"pre-commit": "pnpm run lint:write"
|
|
36
22
|
},
|
|
37
23
|
"dependencies": {
|
|
38
24
|
"deepmerge": "^4.3.1",
|
|
39
|
-
"ts-checker-rspack-plugin": "^1.
|
|
25
|
+
"ts-checker-rspack-plugin": "^1.3.0",
|
|
40
26
|
"json5": "^2.2.3",
|
|
41
|
-
"reduce-configs": "^1.1.
|
|
27
|
+
"reduce-configs": "^1.1.2"
|
|
42
28
|
},
|
|
43
29
|
"devDependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
30
|
+
"@playwright/test": "^1.60.0",
|
|
31
|
+
"@rsbuild/core": "^2.0.7",
|
|
32
|
+
"@rslib/core": "^0.21.5",
|
|
33
|
+
"@rslint/core": "^0.5.3",
|
|
48
34
|
"@types/fs-extra": "^11.0.4",
|
|
49
|
-
"@types/node": "^24.
|
|
50
|
-
"fs-extra": "^11.3.
|
|
51
|
-
"
|
|
52
|
-
"
|
|
35
|
+
"@types/node": "^24.12.4",
|
|
36
|
+
"fs-extra": "^11.3.5",
|
|
37
|
+
"playwright": "^1.60.0",
|
|
38
|
+
"prettier": "^3.8.3",
|
|
53
39
|
"simple-git-hooks": "^2.13.1",
|
|
54
|
-
"typescript": "^
|
|
40
|
+
"typescript": "^6.0.3"
|
|
55
41
|
},
|
|
56
42
|
"peerDependencies": {
|
|
57
43
|
"@rsbuild/core": "^1.0.0 || ^2.0.0-0"
|
|
@@ -61,9 +47,16 @@
|
|
|
61
47
|
"optional": true
|
|
62
48
|
}
|
|
63
49
|
},
|
|
64
|
-
"packageManager": "pnpm@10.24.0",
|
|
65
50
|
"publishConfig": {
|
|
66
51
|
"access": "public",
|
|
67
52
|
"registry": "https://registry.npmjs.org/"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "rslib",
|
|
56
|
+
"dev": "rslib -w",
|
|
57
|
+
"lint": "rslint && prettier -c .",
|
|
58
|
+
"lint:write": "rslint --fix && prettier -w .",
|
|
59
|
+
"test": "playwright test",
|
|
60
|
+
"bump": "npx bumpp"
|
|
68
61
|
}
|
|
69
|
-
}
|
|
62
|
+
}
|