@rsbuild/plugin-type-check 1.1.0-beta.1 → 1.2.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 +23 -9
- package/dist/index.cjs +15 -11
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -3
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ An Rsbuild plugin to run TypeScript type checker in a separate process.
|
|
|
12
12
|
|
|
13
13
|
## Introduction
|
|
14
14
|
|
|
15
|
-
This plugin internally integrates with [ts-checker-rspack-plugin](https://github.com/rspack-
|
|
15
|
+
This plugin internally integrates with [ts-checker-rspack-plugin](https://github.com/rspack-contrib/ts-checker-rspack-plugin).
|
|
16
16
|
|
|
17
17
|
The type checking logic of `ts-checker-rspack-plugin` is similar to the native `tsc` command of TypeScript. It automatically reads the configuration options from `tsconfig.json` and can also be modified via the configuration options provided by the Type Check plugin.
|
|
18
18
|
|
|
@@ -96,9 +96,9 @@ pluginTypeCheck({
|
|
|
96
96
|
});
|
|
97
97
|
```
|
|
98
98
|
|
|
99
|
-
###
|
|
99
|
+
### tsCheckerOptions
|
|
100
100
|
|
|
101
|
-
|
|
101
|
+
Modify the options of `ts-checker-rspack-plugin`, please refer to [ts-checker-rspack-plugin - README](https://github.com/rspack-contrib/ts-checker-rspack-plugin#readme) to learn about available options.
|
|
102
102
|
|
|
103
103
|
- **Type:** `Object | Function`
|
|
104
104
|
- **Default:**
|
|
@@ -136,11 +136,11 @@ const defaultOptions = {
|
|
|
136
136
|
|
|
137
137
|
#### Object Type
|
|
138
138
|
|
|
139
|
-
When the value of `
|
|
139
|
+
When the value of `tsCheckerOptions` is an object, it will be deeply merged with the default configuration.
|
|
140
140
|
|
|
141
141
|
```ts
|
|
142
142
|
pluginTypeCheck({
|
|
143
|
-
|
|
143
|
+
tsCheckerOptions: {
|
|
144
144
|
issue: {
|
|
145
145
|
exclude: [({ file = "" }) => /[\\/]some-folder[\\/]/.test(file)],
|
|
146
146
|
},
|
|
@@ -150,11 +150,11 @@ pluginTypeCheck({
|
|
|
150
150
|
|
|
151
151
|
#### Function Type
|
|
152
152
|
|
|
153
|
-
When the value of `
|
|
153
|
+
When the value of `tsCheckerOptions` is a function, the default configuration will be passed as the first argument. You can directly modify the configuration object or return an object as the final configuration.
|
|
154
154
|
|
|
155
155
|
```ts
|
|
156
156
|
pluginTypeCheck({
|
|
157
|
-
|
|
157
|
+
tsCheckerOptions(options) {
|
|
158
158
|
options.async = false;
|
|
159
159
|
return options;
|
|
160
160
|
},
|
|
@@ -169,7 +169,7 @@ For example, the type mismatch error can be excluded using `code: 'TS2345'`:
|
|
|
169
169
|
|
|
170
170
|
```ts
|
|
171
171
|
pluginTypeCheck({
|
|
172
|
-
|
|
172
|
+
tsCheckerOptions: {
|
|
173
173
|
issue: {
|
|
174
174
|
// Ignore "Argument of type 'string' is not assignable to parameter of type 'number'.ts(2345)"
|
|
175
175
|
exclude: [{ code: "TS2345" }],
|
|
@@ -182,7 +182,7 @@ Or exclude files under `/some-folder/` using `file`:
|
|
|
182
182
|
|
|
183
183
|
```ts
|
|
184
184
|
pluginTypeCheck({
|
|
185
|
-
|
|
185
|
+
tsCheckerOptions: {
|
|
186
186
|
issue: {
|
|
187
187
|
exclude: [({ file = "" }) => /[\\/]some-folder[\\/]/.test(file)],
|
|
188
188
|
},
|
|
@@ -190,6 +190,20 @@ pluginTypeCheck({
|
|
|
190
190
|
});
|
|
191
191
|
```
|
|
192
192
|
|
|
193
|
+
#### Disable type errors from the error overlay
|
|
194
|
+
|
|
195
|
+
By default, type errors will be reported to Dev Server and displayed in the Rsbuild error overlay in development mode.
|
|
196
|
+
|
|
197
|
+
If you don't want type errors to be displayed in the error overlay, you can disable it by setting `devServer: false`:
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
pluginTypeCheck({
|
|
201
|
+
tsCheckerOptions: {
|
|
202
|
+
async: true,
|
|
203
|
+
devServer: false,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
```
|
|
193
207
|
## Notes
|
|
194
208
|
|
|
195
209
|
- 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.
|
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
|
|
3
|
+
return 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
4
|
+
}();
|
|
2
5
|
// The require scope
|
|
3
6
|
var __webpack_require__ = {};
|
|
4
7
|
/************************************************************************/ // webpack/runtime/compat_get_default_export
|
|
5
8
|
(()=>{
|
|
6
9
|
// getDefaultExport function for compatibility with non-ESM modules
|
|
7
|
-
__webpack_require__.n = function(
|
|
8
|
-
var getter =
|
|
9
|
-
return
|
|
10
|
+
__webpack_require__.n = function(module) {
|
|
11
|
+
var getter = module && module.__esModule ? function() {
|
|
12
|
+
return module['default'];
|
|
10
13
|
} : function() {
|
|
11
|
-
return
|
|
14
|
+
return module;
|
|
12
15
|
};
|
|
13
16
|
__webpack_require__.d(getter, {
|
|
14
17
|
a: getter
|
|
@@ -61,9 +64,7 @@ const external_json5_namespaceObject = require("json5");
|
|
|
61
64
|
var external_json5_default = /*#__PURE__*/ __webpack_require__.n(external_json5_namespaceObject);
|
|
62
65
|
const external_reduce_configs_namespaceObject = require("reduce-configs");
|
|
63
66
|
const external_ts_checker_rspack_plugin_namespaceObject = require("ts-checker-rspack-plugin");
|
|
64
|
-
const src_require = (0, external_node_module_namespaceObject.createRequire)(
|
|
65
|
-
return 'undefined' == typeof document ? new (module.require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
66
|
-
}());
|
|
67
|
+
const src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
|
|
67
68
|
const PLUGIN_TYPE_CHECK_NAME = 'rsbuild:type-check';
|
|
68
69
|
const pluginTypeCheck = (options = {})=>({
|
|
69
70
|
name: PLUGIN_TYPE_CHECK_NAME,
|
|
@@ -72,7 +73,10 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
72
73
|
const checkedTsconfig = new Map();
|
|
73
74
|
api.modifyBundlerChain(async (chain, { isProd, environment, CHAIN_ID })=>{
|
|
74
75
|
const { enable = true, forkTsCheckerOptions } = options;
|
|
76
|
+
let { tsCheckerOptions } = options;
|
|
75
77
|
const { tsconfigPath } = environment;
|
|
78
|
+
// compatible with the legacy option
|
|
79
|
+
if (void 0 === tsCheckerOptions && void 0 !== forkTsCheckerOptions) tsCheckerOptions = forkTsCheckerOptions;
|
|
76
80
|
if (!tsconfigPath || false === enable) return;
|
|
77
81
|
// If there are identical tsconfig.json files,
|
|
78
82
|
// apply type checker only once to avoid duplicate checks.
|
|
@@ -122,20 +126,20 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
122
126
|
}
|
|
123
127
|
}
|
|
124
128
|
};
|
|
125
|
-
const
|
|
129
|
+
const mergedOptions = (0, external_reduce_configs_namespaceObject.reduceConfigs)({
|
|
126
130
|
initial: defaultOptions,
|
|
127
|
-
config:
|
|
131
|
+
config: tsCheckerOptions,
|
|
128
132
|
mergeFn: external_deepmerge_default()
|
|
129
133
|
});
|
|
130
134
|
if (isProd) core_namespaceObject.logger.info('Type checker is enabled. It may take some time.');
|
|
131
135
|
chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(external_ts_checker_rspack_plugin_namespaceObject.TsCheckerRspackPlugin, [
|
|
132
|
-
|
|
136
|
+
mergedOptions
|
|
133
137
|
]);
|
|
134
138
|
});
|
|
135
139
|
}
|
|
136
140
|
});
|
|
137
141
|
var __webpack_export_target__ = exports;
|
|
138
|
-
for(var
|
|
142
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
139
143
|
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
140
144
|
value: true
|
|
141
145
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type RsbuildPlugin } from '@rsbuild/core';
|
|
2
2
|
import { type ConfigChain } from 'reduce-configs';
|
|
3
3
|
import { TsCheckerRspackPlugin } from 'ts-checker-rspack-plugin';
|
|
4
|
-
type
|
|
4
|
+
type TsCheckerOptions = NonNullable<ConstructorParameters<typeof TsCheckerRspackPlugin>[0]>;
|
|
5
5
|
export type PluginTypeCheckerOptions = {
|
|
6
6
|
/**
|
|
7
7
|
* Whether to enable TypeScript type checking.
|
|
@@ -12,7 +12,11 @@ export type PluginTypeCheckerOptions = {
|
|
|
12
12
|
* To modify the options of `ts-checker-rspack-plugin`.
|
|
13
13
|
* @see https://github.com/rspack-contrib/ts-checker-rspack-plugin#readme
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
tsCheckerOptions?: ConfigChain<TsCheckerOptions>;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated use `tsCheckerOptions` instead.
|
|
18
|
+
*/
|
|
19
|
+
forkTsCheckerOptions?: ConfigChain<TsCheckerOptions>;
|
|
16
20
|
};
|
|
17
21
|
export declare const PLUGIN_TYPE_CHECK_NAME = "rsbuild:type-check";
|
|
18
22
|
export declare const pluginTypeCheck: (options?: PluginTypeCheckerOptions) => RsbuildPlugin;
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,10 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
14
14
|
const checkedTsconfig = new Map();
|
|
15
15
|
api.modifyBundlerChain(async (chain, { isProd, environment, CHAIN_ID })=>{
|
|
16
16
|
const { enable = true, forkTsCheckerOptions } = options;
|
|
17
|
+
let { tsCheckerOptions } = options;
|
|
17
18
|
const { tsconfigPath } = environment;
|
|
19
|
+
// compatible with the legacy option
|
|
20
|
+
if (void 0 === tsCheckerOptions && void 0 !== forkTsCheckerOptions) tsCheckerOptions = forkTsCheckerOptions;
|
|
18
21
|
if (!tsconfigPath || false === enable) return;
|
|
19
22
|
// If there are identical tsconfig.json files,
|
|
20
23
|
// apply type checker only once to avoid duplicate checks.
|
|
@@ -64,14 +67,14 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
};
|
|
67
|
-
const
|
|
70
|
+
const mergedOptions = (0, __WEBPACK_EXTERNAL_MODULE_reduce_configs__.reduceConfigs)({
|
|
68
71
|
initial: defaultOptions,
|
|
69
|
-
config:
|
|
72
|
+
config: tsCheckerOptions,
|
|
70
73
|
mergeFn: __WEBPACK_EXTERNAL_MODULE_deepmerge__["default"]
|
|
71
74
|
});
|
|
72
75
|
if (isProd) __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.logger.info('Type checker is enabled. It may take some time.');
|
|
73
76
|
chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(__WEBPACK_EXTERNAL_MODULE_ts_checker_rspack_plugin__.TsCheckerRspackPlugin, [
|
|
74
|
-
|
|
77
|
+
mergedOptions
|
|
75
78
|
]);
|
|
76
79
|
});
|
|
77
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-type-check",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
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.
|
|
39
|
+
"ts-checker-rspack-plugin": "^1.1.0",
|
|
40
40
|
"json5": "^2.2.3",
|
|
41
|
-
"reduce-configs": "^1.
|
|
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.49.0",
|
|
46
|
+
"@rsbuild/core": "^1.1.6",
|
|
47
|
+
"@rslib/core": "^0.1.1",
|
|
48
48
|
"@types/fs-extra": "^11.0.4",
|
|
49
|
-
"@types/node": "^22.
|
|
49
|
+
"@types/node": "^22.10.1",
|
|
50
50
|
"fs-extra": "^11.2.0",
|
|
51
51
|
"nano-staged": "^0.8.0",
|
|
52
|
-
"playwright": "^1.
|
|
52
|
+
"playwright": "^1.49.0",
|
|
53
53
|
"simple-git-hooks": "^2.11.1",
|
|
54
|
-
"typescript": "^5.
|
|
54
|
+
"typescript": "^5.7.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@9.
|
|
64
|
+
"packageManager": "pnpm@9.14.4",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public",
|
|
67
67
|
"registry": "https://registry.npmjs.org/"
|