@rsbuild/plugin-type-check 1.1.0-beta.1 → 1.1.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 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-team/ts-checker-rspack-plugin).
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
- ### forkTsCheckerOptions
99
+ ### tsCheckerOptions
100
100
 
101
- To modify the options of `ts-checker-rspack-plugin`, please refer to [ts-checker-rspack-plugin - README](https://github.com/rspack-team/ts-checker-rspack-plugin#readme) to learn about available options.
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 `forkTsCheckerOptions` is an object, it will be deeply merged with the default configuration.
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
- forkTsCheckerOptions: {
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 `forkTsCheckerOptions` 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.
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
- forkTsCheckerOptions(options) {
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
- forkTsCheckerOptions: {
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
- forkTsCheckerOptions: {
185
+ tsCheckerOptions: {
186
186
  issue: {
187
187
  exclude: [({ file = "" }) => /[\\/]some-folder[\\/]/.test(file)],
188
188
  },
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(module1) {
8
- var getter = module1 && module1.__esModule ? function() {
9
- return module1['default'];
10
+ __webpack_require__.n = function(module) {
11
+ var getter = module && module.__esModule ? function() {
12
+ return module['default'];
10
13
  } : function() {
11
- return module1;
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)(/*#__PURE__*/ function() {
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,14 +126,14 @@ const pluginTypeCheck = (options = {})=>({
122
126
  }
123
127
  }
124
128
  };
125
- const typeCheckerOptions = (0, external_reduce_configs_namespaceObject.reduceConfigs)({
129
+ const mergedOptions = (0, external_reduce_configs_namespaceObject.reduceConfigs)({
126
130
  initial: defaultOptions,
127
- config: forkTsCheckerOptions,
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
- typeCheckerOptions
136
+ mergedOptions
133
137
  ]);
134
138
  });
135
139
  }
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 ForkTsCheckerOptions = NonNullable<ConstructorParameters<typeof TsCheckerRspackPlugin>[0]>;
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
- forkTsCheckerOptions?: ConfigChain<ForkTsCheckerOptions>;
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 typeCheckerOptions = (0, __WEBPACK_EXTERNAL_MODULE_reduce_configs__.reduceConfigs)({
70
+ const mergedOptions = (0, __WEBPACK_EXTERNAL_MODULE_reduce_configs__.reduceConfigs)({
68
71
  initial: defaultOptions,
69
- config: forkTsCheckerOptions,
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
- typeCheckerOptions
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.1.0-beta.1",
3
+ "version": "1.1.0",
4
4
  "repository": "https://github.com/rspack-contrib/rsbuild-plugin-type-check",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -36,15 +36,15 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "deepmerge": "^4.3.1",
39
- "ts-checker-rspack-plugin": "^1.0.0",
39
+ "ts-checker-rspack-plugin": "^1.0.1",
40
40
  "json5": "^2.2.3",
41
41
  "reduce-configs": "^1.0.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@biomejs/biome": "^1.9.4",
45
45
  "@playwright/test": "^1.48.2",
46
- "@rsbuild/core": "^1.0.19",
47
- "@rslib/core": "^0.0.16",
46
+ "@rsbuild/core": "^1.1.5",
47
+ "@rslib/core": "^0.1.0",
48
48
  "@types/fs-extra": "^11.0.4",
49
49
  "@types/node": "^22.8.6",
50
50
  "fs-extra": "^11.2.0",