@rsbuild/plugin-type-check 1.0.1 → 1.1.0-beta.1

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,9 +12,9 @@ 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 [fork-ts-checker-webpack-plugin](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin).
15
+ This plugin internally integrates with [ts-checker-rspack-plugin](https://github.com/rspack-team/ts-checker-rspack-plugin).
16
16
 
17
- The type checking logic of `fork-ts-checker-webpack-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.
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
 
19
19
  The behavior of the plugin differs in the development and production builds:
20
20
 
@@ -98,7 +98,7 @@ pluginTypeCheck({
98
98
 
99
99
  ### forkTsCheckerOptions
100
100
 
101
- To modify the options of `fork-ts-checker-webpack-plugin`, please refer to [fork-ts-checker-webpack-plugin - README](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin#readme) to learn about available options.
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.
102
102
 
103
103
  - **Type:** `Object | Function`
104
104
  - **Default:**
@@ -107,7 +107,7 @@ To modify the options of `fork-ts-checker-webpack-plugin`, please refer to [fork
107
107
  const defaultOptions = {
108
108
  typescript: {
109
109
  // set 'readonly' to avoid emitting tsbuildinfo,
110
- // as the generated tsbuildinfo will break fork-ts-checker
110
+ // as the generated tsbuildinfo will break ts-checker-rspack-plugin
111
111
  mode: "readonly",
112
112
  // enable build when using project reference
113
113
  build: useReference,
@@ -193,7 +193,7 @@ pluginTypeCheck({
193
193
  ## Notes
194
194
 
195
195
  - 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.
196
- - Some errors will be displayed as warnings in IDEs such as VS Code, but they will still be displayed as errors in the `fork-ts-checker-webpack-plugin` check. For details, please refer to: [Why are some errors reported as warnings?](https://code.visualstudio.com/docs/typescript/typescript-compiling#_why-are-some-errors-reported-as-warnings).
196
+ - Some errors will be displayed as warnings in IDEs such as VS Code, but they will still be displayed as errors in the `ts-checker-rspack-plugin` check. For details, please refer to: [Why are some errors reported as warnings?](https://code.visualstudio.com/docs/typescript/typescript-compiling#_why-are-some-errors-reported-as-warnings).
197
197
 
198
198
  ## Performance Optimization
199
199
 
@@ -210,7 +210,7 @@ For example, properly configuring the `include` and `exclude` scopes in `tsconfi
210
210
 
211
211
  ## Vue Components
212
212
 
213
- `fork-ts-checker-webpack-plugin` does not support checking TypeScript code in `.vue` components. You can check for type issues in `.vue` files in the following ways:
213
+ `ts-checker-rspack-plugin` does not support checking TypeScript code in `.vue` components. You can check for type issues in `.vue` files in the following ways:
214
214
 
215
215
  1. Install the [vue-tsc](https://github.com/vuejs/language-tools/tree/master/packages/tsc) package, which provides the ability to check types in `.vue` files.
216
216
 
package/dist/index.cjs CHANGED
@@ -1,128 +1,141 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- PLUGIN_TYPE_CHECK_NAME: () => PLUGIN_TYPE_CHECK_NAME,
34
- pluginTypeCheck: () => pluginTypeCheck
2
+ // The require scope
3
+ var __webpack_require__ = {};
4
+ /************************************************************************/ // webpack/runtime/compat_get_default_export
5
+ (()=>{
6
+ // 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
+ } : function() {
11
+ return module1;
12
+ };
13
+ __webpack_require__.d(getter, {
14
+ a: getter
15
+ });
16
+ return getter;
17
+ };
18
+ })();
19
+ // webpack/runtime/define_property_getters
20
+ (()=>{
21
+ __webpack_require__.d = function(exports1, definition) {
22
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
23
+ enumerable: true,
24
+ get: definition[key]
25
+ });
26
+ };
27
+ })();
28
+ // webpack/runtime/has_own_property
29
+ (()=>{
30
+ __webpack_require__.o = function(obj, prop) {
31
+ return Object.prototype.hasOwnProperty.call(obj, prop);
32
+ };
33
+ })();
34
+ // webpack/runtime/make_namespace_object
35
+ (()=>{
36
+ // define __esModule on exports
37
+ __webpack_require__.r = function(exports1) {
38
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
39
+ value: 'Module'
40
+ });
41
+ Object.defineProperty(exports1, '__esModule', {
42
+ value: true
43
+ });
44
+ };
45
+ })();
46
+ /************************************************************************/ var __webpack_exports__ = {};
47
+ // ESM COMPAT FLAG
48
+ __webpack_require__.r(__webpack_exports__);
49
+ // EXPORTS
50
+ __webpack_require__.d(__webpack_exports__, {
51
+ PLUGIN_TYPE_CHECK_NAME: ()=>/* binding */ PLUGIN_TYPE_CHECK_NAME,
52
+ pluginTypeCheck: ()=>/* binding */ pluginTypeCheck
35
53
  });
36
- module.exports = __toCommonJS(src_exports);
37
-
38
- // node_modules/.pnpm/tsup@8.2.4_postcss@8.4.38_typescript@5.5.4/node_modules/tsup/assets/cjs_shims.js
39
- var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
40
- var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
41
-
42
- // src/index.ts
43
- var import_node_fs = __toESM(require("fs"), 1);
44
- var import_node_module = require("module");
45
- var import_core = require("@rsbuild/core");
46
- var import_deepmerge = __toESM(require("deepmerge"), 1);
47
- var import_fork_ts_checker_webpack_plugin = __toESM(require("fork-ts-checker-webpack-plugin"), 1);
48
- var import_json5 = __toESM(require("json5"), 1);
49
- var import_reduce_configs = require("reduce-configs");
50
- var require2 = (0, import_node_module.createRequire)(importMetaUrl);
51
- var PLUGIN_TYPE_CHECK_NAME = "rsbuild:type-check";
52
- var pluginTypeCheck = (options = {}) => {
53
- return {
54
- name: PLUGIN_TYPE_CHECK_NAME,
55
- setup(api) {
56
- const NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/;
57
- const checkedTsconfig = /* @__PURE__ */ new Map();
58
- api.modifyBundlerChain(
59
- async (chain, { isProd, environment, CHAIN_ID }) => {
60
- const { enable = true, forkTsCheckerOptions } = options;
61
- const { tsconfigPath } = environment;
62
- if (!tsconfigPath || enable === false) {
63
- return;
64
- }
65
- if (checkedTsconfig.has(tsconfigPath) && checkedTsconfig.get(tsconfigPath) !== environment.name) {
66
- return;
67
- }
68
- checkedTsconfig.set(tsconfigPath, environment.name);
69
- let typescriptPath;
70
- try {
71
- typescriptPath = require2.resolve("typescript", {
72
- paths: [api.context.rootPath]
54
+ const external_node_fs_namespaceObject = require("node:fs");
55
+ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
56
+ const external_node_module_namespaceObject = require("node:module");
57
+ const core_namespaceObject = require("@rsbuild/core");
58
+ const external_deepmerge_namespaceObject = require("deepmerge");
59
+ var external_deepmerge_default = /*#__PURE__*/ __webpack_require__.n(external_deepmerge_namespaceObject);
60
+ const external_json5_namespaceObject = require("json5");
61
+ var external_json5_default = /*#__PURE__*/ __webpack_require__.n(external_json5_namespaceObject);
62
+ const external_reduce_configs_namespaceObject = require("reduce-configs");
63
+ 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 PLUGIN_TYPE_CHECK_NAME = 'rsbuild:type-check';
68
+ const pluginTypeCheck = (options = {})=>({
69
+ name: PLUGIN_TYPE_CHECK_NAME,
70
+ setup (api) {
71
+ const NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/;
72
+ const checkedTsconfig = new Map();
73
+ api.modifyBundlerChain(async (chain, { isProd, environment, CHAIN_ID })=>{
74
+ const { enable = true, forkTsCheckerOptions } = options;
75
+ const { tsconfigPath } = environment;
76
+ if (!tsconfigPath || false === enable) return;
77
+ // If there are identical tsconfig.json files,
78
+ // apply type checker only once to avoid duplicate checks.
79
+ if (checkedTsconfig.has(tsconfigPath) && checkedTsconfig.get(tsconfigPath) !== environment.name) return;
80
+ checkedTsconfig.set(tsconfigPath, environment.name);
81
+ // use typescript of user project
82
+ let typescriptPath;
83
+ try {
84
+ typescriptPath = src_require.resolve('typescript', {
85
+ paths: [
86
+ api.context.rootPath
87
+ ]
88
+ });
89
+ } catch (err) {
90
+ core_namespaceObject.logger.warn('"typescript" is not found in current project, Type checker will not work.');
91
+ return;
92
+ }
93
+ const { references } = external_json5_default().parse(external_node_fs_default().readFileSync(tsconfigPath, 'utf-8'));
94
+ const useReference = Array.isArray(references) && references.length > 0;
95
+ const defaultOptions = {
96
+ typescript: {
97
+ // set 'readonly' to avoid emitting tsbuildinfo,
98
+ // as the generated tsbuildinfo will break ts-checker-rspack-plugin
99
+ mode: 'readonly',
100
+ // enable build when using project reference
101
+ build: useReference,
102
+ // avoid OOM issue
103
+ memoryLimit: 8192,
104
+ // use tsconfig of user project
105
+ configFile: tsconfigPath,
106
+ // use typescript of user project
107
+ typescriptPath
108
+ },
109
+ issue: {
110
+ // ignore types errors from node_modules
111
+ exclude: [
112
+ ({ file = '' })=>NODE_MODULES_REGEX.test(file)
113
+ ]
114
+ },
115
+ logger: {
116
+ log () {
117
+ // do nothing
118
+ // we only want to display error messages
119
+ },
120
+ error (message) {
121
+ console.error(message.replace(/ERROR/g, 'Type Error'));
122
+ }
123
+ }
124
+ };
125
+ const typeCheckerOptions = (0, external_reduce_configs_namespaceObject.reduceConfigs)({
126
+ initial: defaultOptions,
127
+ config: forkTsCheckerOptions,
128
+ mergeFn: external_deepmerge_default()
129
+ });
130
+ if (isProd) core_namespaceObject.logger.info('Type checker is enabled. It may take some time.');
131
+ chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(external_ts_checker_rspack_plugin_namespaceObject.TsCheckerRspackPlugin, [
132
+ typeCheckerOptions
133
+ ]);
73
134
  });
74
- } catch (err) {
75
- import_core.logger.warn(
76
- '"typescript" is not found in current project, Type checker will not work.'
77
- );
78
- return;
79
- }
80
- const { references } = import_json5.default.parse(
81
- import_node_fs.default.readFileSync(tsconfigPath, "utf-8")
82
- );
83
- const useReference = Array.isArray(references) && references.length > 0;
84
- const defaultOptions = {
85
- typescript: {
86
- // set 'readonly' to avoid emitting tsbuildinfo,
87
- // as the generated tsbuildinfo will break fork-ts-checker
88
- mode: "readonly",
89
- // enable build when using project reference
90
- build: useReference,
91
- // avoid OOM issue
92
- memoryLimit: 8192,
93
- // use tsconfig of user project
94
- configFile: tsconfigPath,
95
- // use typescript of user project
96
- typescriptPath
97
- },
98
- issue: {
99
- // ignore types errors from node_modules
100
- exclude: [({ file = "" }) => NODE_MODULES_REGEX.test(file)]
101
- },
102
- logger: {
103
- log() {
104
- },
105
- error(message) {
106
- console.error(message.replace(/ERROR/g, "Type Error"));
107
- }
108
- }
109
- };
110
- const typeCheckerOptions = (0, import_reduce_configs.reduceConfigs)({
111
- initial: defaultOptions,
112
- config: forkTsCheckerOptions,
113
- mergeFn: import_deepmerge.default
114
- });
115
- if (isProd) {
116
- import_core.logger.info("Type checker is enabled. It may take some time.");
117
- }
118
- chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(import_fork_ts_checker_webpack_plugin.default, [typeCheckerOptions]);
119
135
  }
120
- );
121
- }
122
- };
123
- };
124
- // Annotate the CommonJS export names for ESM import in node:
125
- 0 && (module.exports = {
126
- PLUGIN_TYPE_CHECK_NAME,
127
- pluginTypeCheck
136
+ });
137
+ var __webpack_export_target__ = exports;
138
+ for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
139
+ if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
140
+ value: true
128
141
  });
package/dist/index.d.ts CHANGED
@@ -1,21 +1,19 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
- import ForkTSCheckerPlugin from 'fork-ts-checker-webpack-plugin';
3
- import { ConfigChain } from 'reduce-configs';
4
-
5
- type ForkTsCheckerOptions = NonNullable<ConstructorParameters<typeof ForkTSCheckerPlugin>[0]>;
6
- type PluginTypeCheckerOptions = {
1
+ import { type RsbuildPlugin } from '@rsbuild/core';
2
+ import { type ConfigChain } from 'reduce-configs';
3
+ import { TsCheckerRspackPlugin } from 'ts-checker-rspack-plugin';
4
+ type ForkTsCheckerOptions = NonNullable<ConstructorParameters<typeof TsCheckerRspackPlugin>[0]>;
5
+ export type PluginTypeCheckerOptions = {
7
6
  /**
8
7
  * Whether to enable TypeScript type checking.
9
8
  * @default true
10
9
  */
11
10
  enable?: boolean;
12
11
  /**
13
- * To modify the options of `fork-ts-checker-webpack-plugin`.
14
- * @see https://github.com/TypeStrong/fork-ts-checker-webpack-plugin#readme
12
+ * To modify the options of `ts-checker-rspack-plugin`.
13
+ * @see https://github.com/rspack-contrib/ts-checker-rspack-plugin#readme
15
14
  */
16
15
  forkTsCheckerOptions?: ConfigChain<ForkTsCheckerOptions>;
17
16
  };
18
- declare const PLUGIN_TYPE_CHECK_NAME = "rsbuild:type-check";
19
- declare const pluginTypeCheck: (options?: PluginTypeCheckerOptions) => RsbuildPlugin;
20
-
21
- export { PLUGIN_TYPE_CHECK_NAME, type PluginTypeCheckerOptions, pluginTypeCheck };
17
+ export declare const PLUGIN_TYPE_CHECK_NAME = "rsbuild:type-check";
18
+ export declare const pluginTypeCheck: (options?: PluginTypeCheckerOptions) => RsbuildPlugin;
19
+ export {};
package/dist/index.js CHANGED
@@ -1,86 +1,79 @@
1
- // src/index.ts
2
- import fs from "node:fs";
3
- import { createRequire } from "node:module";
4
- import { logger } from "@rsbuild/core";
5
- import deepmerge from "deepmerge";
6
- import ForkTSCheckerPlugin from "fork-ts-checker-webpack-plugin";
7
- import json5 from "json5";
8
- import { reduceConfigs } from "reduce-configs";
9
- var require2 = createRequire(import.meta.url);
10
- var PLUGIN_TYPE_CHECK_NAME = "rsbuild:type-check";
11
- var pluginTypeCheck = (options = {}) => {
12
- return {
13
- name: PLUGIN_TYPE_CHECK_NAME,
14
- setup(api) {
15
- const NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/;
16
- const checkedTsconfig = /* @__PURE__ */ new Map();
17
- api.modifyBundlerChain(
18
- async (chain, { isProd, environment, CHAIN_ID }) => {
19
- const { enable = true, forkTsCheckerOptions } = options;
20
- const { tsconfigPath } = environment;
21
- if (!tsconfigPath || enable === false) {
22
- return;
23
- }
24
- if (checkedTsconfig.has(tsconfigPath) && checkedTsconfig.get(tsconfigPath) !== environment.name) {
25
- return;
26
- }
27
- checkedTsconfig.set(tsconfigPath, environment.name);
28
- let typescriptPath;
29
- try {
30
- typescriptPath = require2.resolve("typescript", {
31
- paths: [api.context.rootPath]
1
+ import * as __WEBPACK_EXTERNAL_MODULE_node_fs__ from "node:fs";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_node_module__ from "node:module";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core__ from "@rsbuild/core";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_deepmerge__ from "deepmerge";
5
+ import * as __WEBPACK_EXTERNAL_MODULE_json5__ from "json5";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_reduce_configs__ from "reduce-configs";
7
+ import * as __WEBPACK_EXTERNAL_MODULE_ts_checker_rspack_plugin__ from "ts-checker-rspack-plugin";
8
+ const src_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url);
9
+ const PLUGIN_TYPE_CHECK_NAME = 'rsbuild:type-check';
10
+ const pluginTypeCheck = (options = {})=>({
11
+ name: PLUGIN_TYPE_CHECK_NAME,
12
+ setup (api) {
13
+ const NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/;
14
+ const checkedTsconfig = new Map();
15
+ api.modifyBundlerChain(async (chain, { isProd, environment, CHAIN_ID })=>{
16
+ const { enable = true, forkTsCheckerOptions } = options;
17
+ const { tsconfigPath } = environment;
18
+ if (!tsconfigPath || false === enable) return;
19
+ // If there are identical tsconfig.json files,
20
+ // apply type checker only once to avoid duplicate checks.
21
+ if (checkedTsconfig.has(tsconfigPath) && checkedTsconfig.get(tsconfigPath) !== environment.name) return;
22
+ checkedTsconfig.set(tsconfigPath, environment.name);
23
+ // use typescript of user project
24
+ let typescriptPath;
25
+ try {
26
+ typescriptPath = src_require.resolve('typescript', {
27
+ paths: [
28
+ api.context.rootPath
29
+ ]
30
+ });
31
+ } catch (err) {
32
+ __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.logger.warn('"typescript" is not found in current project, Type checker will not work.');
33
+ return;
34
+ }
35
+ const { references } = __WEBPACK_EXTERNAL_MODULE_json5__["default"].parse(__WEBPACK_EXTERNAL_MODULE_node_fs__["default"].readFileSync(tsconfigPath, 'utf-8'));
36
+ const useReference = Array.isArray(references) && references.length > 0;
37
+ const defaultOptions = {
38
+ typescript: {
39
+ // set 'readonly' to avoid emitting tsbuildinfo,
40
+ // as the generated tsbuildinfo will break ts-checker-rspack-plugin
41
+ mode: 'readonly',
42
+ // enable build when using project reference
43
+ build: useReference,
44
+ // avoid OOM issue
45
+ memoryLimit: 8192,
46
+ // use tsconfig of user project
47
+ configFile: tsconfigPath,
48
+ // use typescript of user project
49
+ typescriptPath
50
+ },
51
+ issue: {
52
+ // ignore types errors from node_modules
53
+ exclude: [
54
+ ({ file = '' })=>NODE_MODULES_REGEX.test(file)
55
+ ]
56
+ },
57
+ logger: {
58
+ log () {
59
+ // do nothing
60
+ // we only want to display error messages
61
+ },
62
+ error (message) {
63
+ console.error(message.replace(/ERROR/g, 'Type Error'));
64
+ }
65
+ }
66
+ };
67
+ const typeCheckerOptions = (0, __WEBPACK_EXTERNAL_MODULE_reduce_configs__.reduceConfigs)({
68
+ initial: defaultOptions,
69
+ config: forkTsCheckerOptions,
70
+ mergeFn: __WEBPACK_EXTERNAL_MODULE_deepmerge__["default"]
71
+ });
72
+ if (isProd) __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.logger.info('Type checker is enabled. It may take some time.');
73
+ chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(__WEBPACK_EXTERNAL_MODULE_ts_checker_rspack_plugin__.TsCheckerRspackPlugin, [
74
+ typeCheckerOptions
75
+ ]);
32
76
  });
33
- } catch (err) {
34
- logger.warn(
35
- '"typescript" is not found in current project, Type checker will not work.'
36
- );
37
- return;
38
- }
39
- const { references } = json5.parse(
40
- fs.readFileSync(tsconfigPath, "utf-8")
41
- );
42
- const useReference = Array.isArray(references) && references.length > 0;
43
- const defaultOptions = {
44
- typescript: {
45
- // set 'readonly' to avoid emitting tsbuildinfo,
46
- // as the generated tsbuildinfo will break fork-ts-checker
47
- mode: "readonly",
48
- // enable build when using project reference
49
- build: useReference,
50
- // avoid OOM issue
51
- memoryLimit: 8192,
52
- // use tsconfig of user project
53
- configFile: tsconfigPath,
54
- // use typescript of user project
55
- typescriptPath
56
- },
57
- issue: {
58
- // ignore types errors from node_modules
59
- exclude: [({ file = "" }) => NODE_MODULES_REGEX.test(file)]
60
- },
61
- logger: {
62
- log() {
63
- },
64
- error(message) {
65
- console.error(message.replace(/ERROR/g, "Type Error"));
66
- }
67
- }
68
- };
69
- const typeCheckerOptions = reduceConfigs({
70
- initial: defaultOptions,
71
- config: forkTsCheckerOptions,
72
- mergeFn: deepmerge
73
- });
74
- if (isProd) {
75
- logger.info("Type checker is enabled. It may take some time.");
76
- }
77
- chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(ForkTSCheckerPlugin, [typeCheckerOptions]);
78
77
  }
79
- );
80
- }
81
- };
82
- };
83
- export {
84
- PLUGIN_TYPE_CHECK_NAME,
85
- pluginTypeCheck
86
- };
78
+ });
79
+ export { PLUGIN_TYPE_CHECK_NAME, pluginTypeCheck };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-type-check",
3
- "version": "1.0.1",
3
+ "version": "1.1.0-beta.1",
4
4
  "repository": "https://github.com/rspack-contrib/rsbuild-plugin-type-check",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,6 +17,15 @@
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
+ },
20
29
  "simple-git-hooks": {
21
30
  "pre-commit": "npx nano-staged"
22
31
  },
@@ -27,41 +36,34 @@
27
36
  },
28
37
  "dependencies": {
29
38
  "deepmerge": "^4.3.1",
30
- "fork-ts-checker-webpack-plugin": "9.0.2",
39
+ "ts-checker-rspack-plugin": "^1.0.0",
31
40
  "json5": "^2.2.3",
32
- "reduce-configs": "^1.0.0",
33
- "webpack": "^5.94.0"
41
+ "reduce-configs": "^1.0.0"
34
42
  },
35
43
  "devDependencies": {
36
- "@biomejs/biome": "^1.8.3",
37
- "@playwright/test": "^1.46.1",
38
- "@rsbuild/core": "^1.0.1-rc.5",
44
+ "@biomejs/biome": "^1.9.4",
45
+ "@playwright/test": "^1.48.2",
46
+ "@rsbuild/core": "^1.0.19",
47
+ "@rslib/core": "^0.0.16",
39
48
  "@types/fs-extra": "^11.0.4",
40
- "@types/node": "^20.16.2",
49
+ "@types/node": "^22.8.6",
41
50
  "fs-extra": "^11.2.0",
42
51
  "nano-staged": "^0.8.0",
43
- "playwright": "^1.46.1",
52
+ "playwright": "^1.48.2",
44
53
  "simple-git-hooks": "^2.11.1",
45
- "tsup": "^8.2.4",
46
- "typescript": "^5.5.4"
54
+ "typescript": "^5.6.3"
47
55
  },
48
56
  "peerDependencies": {
49
- "@rsbuild/core": "1.x || ^1.0.1-beta.0"
57
+ "@rsbuild/core": "1.x"
50
58
  },
51
59
  "peerDependenciesMeta": {
52
60
  "@rsbuild/core": {
53
61
  "optional": true
54
62
  }
55
63
  },
64
+ "packageManager": "pnpm@9.12.3",
56
65
  "publishConfig": {
57
66
  "access": "public",
58
67
  "registry": "https://registry.npmjs.org/"
59
- },
60
- "scripts": {
61
- "build": "tsup",
62
- "dev": "tsup --watch",
63
- "lint": "biome check .",
64
- "lint:write": "biome check . --write",
65
- "test": "playwright test"
66
68
  }
67
- }
69
+ }
package/dist/index.d.cts DELETED
@@ -1,21 +0,0 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
- import ForkTSCheckerPlugin from 'fork-ts-checker-webpack-plugin';
3
- import { ConfigChain } from 'reduce-configs';
4
-
5
- type ForkTsCheckerOptions = NonNullable<ConstructorParameters<typeof ForkTSCheckerPlugin>[0]>;
6
- type PluginTypeCheckerOptions = {
7
- /**
8
- * Whether to enable TypeScript type checking.
9
- * @default true
10
- */
11
- enable?: boolean;
12
- /**
13
- * To modify the options of `fork-ts-checker-webpack-plugin`.
14
- * @see https://github.com/TypeStrong/fork-ts-checker-webpack-plugin#readme
15
- */
16
- forkTsCheckerOptions?: ConfigChain<ForkTsCheckerOptions>;
17
- };
18
- declare const PLUGIN_TYPE_CHECK_NAME = "rsbuild:type-check";
19
- declare const pluginTypeCheck: (options?: PluginTypeCheckerOptions) => RsbuildPlugin;
20
-
21
- export { PLUGIN_TYPE_CHECK_NAME, type PluginTypeCheckerOptions, pluginTypeCheck };