@rsbuild/plugin-type-check 1.2.2 → 1.2.4
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 +8 -17
- package/dist/index.cjs +2 -2
- package/dist/index.js +14 -14
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -226,28 +226,19 @@ For example, properly configuring the `include` and `exclude` scopes in `tsconfi
|
|
|
226
226
|
|
|
227
227
|
## Vue Components
|
|
228
228
|
|
|
229
|
-
`
|
|
229
|
+
To enable typecheck in `.vue` files, use the custom TypeScript wrapper [`@esctn/vue-tsc-api`](https://www.npmjs.com/package/@esctn/vue-tsc-api). It works on top of [`vue-tsc`](https://www.npmjs.com/package/vue-tsc) — a popular CLI tool for type-checking Vue 3 code.
|
|
230
230
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
<PackageManagerTabs command="add vue-tsc -D" />
|
|
234
|
-
|
|
235
|
-
2. Add the `vue-tsc --noEmit` command to the `build` script in package.json:
|
|
236
|
-
|
|
237
|
-
```diff title="package.json"
|
|
238
|
-
{
|
|
239
|
-
"scripts": {
|
|
240
|
-
- "build": "rsbuild build"
|
|
241
|
-
+ "build": "vue-tsc --noEmit && rsbuild build"
|
|
242
|
-
}
|
|
243
|
-
}
|
|
231
|
+
```bash
|
|
232
|
+
npm add @esctn/vue-tsc-api -D
|
|
244
233
|
```
|
|
245
234
|
|
|
246
|
-
3. Since the production build uses `vue-tsc` for type checking, you can disable the Type Check plugin in production mode to avoid redundant checks.
|
|
247
|
-
|
|
248
235
|
```js
|
|
249
236
|
pluginTypeCheck({
|
|
250
|
-
|
|
237
|
+
tsCheckerOptions: {
|
|
238
|
+
typescript: {
|
|
239
|
+
typescriptPath: '@esctn/vue-tsc-api'
|
|
240
|
+
}
|
|
241
|
+
},
|
|
251
242
|
});
|
|
252
243
|
```
|
|
253
244
|
|
package/dist/index.cjs
CHANGED
|
@@ -36,8 +36,8 @@ var __webpack_require__ = {};
|
|
|
36
36
|
var __webpack_exports__ = {};
|
|
37
37
|
__webpack_require__.r(__webpack_exports__);
|
|
38
38
|
__webpack_require__.d(__webpack_exports__, {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
pluginTypeCheck: ()=>pluginTypeCheck,
|
|
40
|
+
PLUGIN_TYPE_CHECK_NAME: ()=>PLUGIN_TYPE_CHECK_NAME
|
|
41
41
|
});
|
|
42
42
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
43
43
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
const src_require =
|
|
1
|
+
import node_fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { logger } from "@rsbuild/core";
|
|
4
|
+
import deepmerge from "deepmerge";
|
|
5
|
+
import json5 from "json5";
|
|
6
|
+
import { reduceConfigs } from "reduce-configs";
|
|
7
|
+
import { TsCheckerRspackPlugin } from "ts-checker-rspack-plugin";
|
|
8
|
+
const src_require = createRequire(import.meta.url);
|
|
9
9
|
const PLUGIN_TYPE_CHECK_NAME = 'rsbuild:type-check';
|
|
10
10
|
const pluginTypeCheck = (options = {})=>({
|
|
11
11
|
name: PLUGIN_TYPE_CHECK_NAME,
|
|
@@ -28,10 +28,10 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
28
28
|
]
|
|
29
29
|
});
|
|
30
30
|
} catch (err) {
|
|
31
|
-
|
|
31
|
+
logger.warn('"typescript" is not found in current project, Type checker will not work.');
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
const { references } =
|
|
34
|
+
const { references } = json5.parse(node_fs.readFileSync(tsconfigPath, 'utf-8'));
|
|
35
35
|
const useReference = Array.isArray(references) && references.length > 0;
|
|
36
36
|
const defaultOptions = {
|
|
37
37
|
typescript: {
|
|
@@ -53,13 +53,13 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
const mergedOptions =
|
|
56
|
+
const mergedOptions = reduceConfigs({
|
|
57
57
|
initial: defaultOptions,
|
|
58
58
|
config: tsCheckerOptions,
|
|
59
|
-
mergeFn:
|
|
59
|
+
mergeFn: deepmerge
|
|
60
60
|
});
|
|
61
|
-
if (isProd)
|
|
62
|
-
chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(
|
|
61
|
+
if (isProd) logger.info('Type checker is enabled. It may take some time.');
|
|
62
|
+
chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(TsCheckerRspackPlugin, [
|
|
63
63
|
mergedOptions
|
|
64
64
|
]);
|
|
65
65
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-type-check",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"repository": "https://github.com/rspack-contrib/rsbuild-plugin-type-check",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"deepmerge": "^4.3.1",
|
|
39
|
-
"ts-checker-rspack-plugin": "^1.1.
|
|
39
|
+
"ts-checker-rspack-plugin": "^1.1.4",
|
|
40
40
|
"json5": "^2.2.3",
|
|
41
41
|
"reduce-configs": "^1.1.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@biomejs/biome": "^1.9.4",
|
|
45
|
-
"@playwright/test": "^1.
|
|
46
|
-
"@rsbuild/core": "^1.
|
|
47
|
-
"@rslib/core": "^0.
|
|
45
|
+
"@playwright/test": "^1.54.1",
|
|
46
|
+
"@rsbuild/core": "^1.4.12",
|
|
47
|
+
"@rslib/core": "^0.11.0",
|
|
48
48
|
"@types/fs-extra": "^11.0.4",
|
|
49
|
-
"@types/node": "^22.
|
|
49
|
+
"@types/node": "^22.17.0",
|
|
50
50
|
"fs-extra": "^11.3.0",
|
|
51
51
|
"nano-staged": "^0.8.0",
|
|
52
|
-
"playwright": "^1.
|
|
53
|
-
"simple-git-hooks": "^2.13.
|
|
54
|
-
"typescript": "^5.
|
|
52
|
+
"playwright": "^1.54.1",
|
|
53
|
+
"simple-git-hooks": "^2.13.1",
|
|
54
|
+
"typescript": "^5.9.2"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"@rsbuild/core": "1.x"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"optional": true
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
-
"packageManager": "pnpm@10.
|
|
64
|
+
"packageManager": "pnpm@10.14.0",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public",
|
|
67
67
|
"registry": "https://registry.npmjs.org/"
|