@rsbuild/plugin-type-check 1.1.0 → 1.2.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
@@ -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
@@ -2,11 +2,8 @@
2
2
  const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
3
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
4
  }();
5
- // The require scope
6
5
  var __webpack_require__ = {};
7
- /************************************************************************/ // webpack/runtime/compat_get_default_export
8
6
  (()=>{
9
- // getDefaultExport function for compatibility with non-ESM modules
10
7
  __webpack_require__.n = function(module) {
11
8
  var getter = module && module.__esModule ? function() {
12
9
  return module['default'];
@@ -19,7 +16,6 @@ var __webpack_require__ = {};
19
16
  return getter;
20
17
  };
21
18
  })();
22
- // webpack/runtime/define_property_getters
23
19
  (()=>{
24
20
  __webpack_require__.d = function(exports1, definition) {
25
21
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
@@ -28,15 +24,12 @@ var __webpack_require__ = {};
28
24
  });
29
25
  };
30
26
  })();
31
- // webpack/runtime/has_own_property
32
27
  (()=>{
33
28
  __webpack_require__.o = function(obj, prop) {
34
29
  return Object.prototype.hasOwnProperty.call(obj, prop);
35
30
  };
36
31
  })();
37
- // webpack/runtime/make_namespace_object
38
32
  (()=>{
39
- // define __esModule on exports
40
33
  __webpack_require__.r = function(exports1) {
41
34
  if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
42
35
  value: 'Module'
@@ -46,13 +39,11 @@ var __webpack_require__ = {};
46
39
  });
47
40
  };
48
41
  })();
49
- /************************************************************************/ var __webpack_exports__ = {};
50
- // ESM COMPAT FLAG
42
+ var __webpack_exports__ = {};
51
43
  __webpack_require__.r(__webpack_exports__);
52
- // EXPORTS
53
44
  __webpack_require__.d(__webpack_exports__, {
54
- PLUGIN_TYPE_CHECK_NAME: ()=>/* binding */ PLUGIN_TYPE_CHECK_NAME,
55
- pluginTypeCheck: ()=>/* binding */ pluginTypeCheck
45
+ pluginTypeCheck: ()=>pluginTypeCheck,
46
+ PLUGIN_TYPE_CHECK_NAME: ()=>PLUGIN_TYPE_CHECK_NAME
56
47
  });
57
48
  const external_node_fs_namespaceObject = require("node:fs");
58
49
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
@@ -75,17 +66,13 @@ const pluginTypeCheck = (options = {})=>({
75
66
  const { enable = true, forkTsCheckerOptions } = options;
76
67
  let { tsCheckerOptions } = options;
77
68
  const { tsconfigPath } = environment;
78
- // compatible with the legacy option
79
69
  if (void 0 === tsCheckerOptions && void 0 !== forkTsCheckerOptions) tsCheckerOptions = forkTsCheckerOptions;
80
70
  if (!tsconfigPath || false === enable) return;
81
- // If there are identical tsconfig.json files,
82
- // apply type checker only once to avoid duplicate checks.
83
71
  if (checkedTsconfig.has(tsconfigPath) && checkedTsconfig.get(tsconfigPath) !== environment.name) return;
84
72
  checkedTsconfig.set(tsconfigPath, environment.name);
85
- // use typescript of user project
86
73
  let typescriptPath;
87
74
  try {
88
- typescriptPath = src_require.resolve('typescript', {
75
+ typescriptPath = src_require.resolve("typescript", {
89
76
  paths: [
90
77
  api.context.rootPath
91
78
  ]
@@ -98,29 +85,19 @@ const pluginTypeCheck = (options = {})=>({
98
85
  const useReference = Array.isArray(references) && references.length > 0;
99
86
  const defaultOptions = {
100
87
  typescript: {
101
- // set 'readonly' to avoid emitting tsbuildinfo,
102
- // as the generated tsbuildinfo will break ts-checker-rspack-plugin
103
88
  mode: 'readonly',
104
- // enable build when using project reference
105
89
  build: useReference,
106
- // avoid OOM issue
107
90
  memoryLimit: 8192,
108
- // use tsconfig of user project
109
91
  configFile: tsconfigPath,
110
- // use typescript of user project
111
92
  typescriptPath
112
93
  },
113
94
  issue: {
114
- // ignore types errors from node_modules
115
95
  exclude: [
116
96
  ({ file = '' })=>NODE_MODULES_REGEX.test(file)
117
97
  ]
118
98
  },
119
99
  logger: {
120
- log () {
121
- // do nothing
122
- // we only want to display error messages
123
- },
100
+ log () {},
124
101
  error (message) {
125
102
  console.error(message.replace(/ERROR/g, 'Type Error'));
126
103
  }
@@ -139,7 +116,7 @@ const pluginTypeCheck = (options = {})=>({
139
116
  }
140
117
  });
141
118
  var __webpack_export_target__ = exports;
142
- for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
119
+ for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
143
120
  if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
144
121
  value: true
145
122
  });
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
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";
1
+ import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
2
+ import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
3
+ import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
4
4
  import * as __WEBPACK_EXTERNAL_MODULE_deepmerge__ from "deepmerge";
5
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);
6
+ import * as __WEBPACK_EXTERNAL_MODULE_reduce_configs_02786df6__ from "reduce-configs";
7
+ import * as __WEBPACK_EXTERNAL_MODULE_ts_checker_rspack_plugin_59177e58__ from "ts-checker-rspack-plugin";
8
+ const src_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.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,
@@ -16,64 +16,50 @@ const pluginTypeCheck = (options = {})=>({
16
16
  const { enable = true, forkTsCheckerOptions } = options;
17
17
  let { tsCheckerOptions } = options;
18
18
  const { tsconfigPath } = environment;
19
- // compatible with the legacy option
20
19
  if (void 0 === tsCheckerOptions && void 0 !== forkTsCheckerOptions) tsCheckerOptions = forkTsCheckerOptions;
21
20
  if (!tsconfigPath || false === enable) return;
22
- // If there are identical tsconfig.json files,
23
- // apply type checker only once to avoid duplicate checks.
24
21
  if (checkedTsconfig.has(tsconfigPath) && checkedTsconfig.get(tsconfigPath) !== environment.name) return;
25
22
  checkedTsconfig.set(tsconfigPath, environment.name);
26
- // use typescript of user project
27
23
  let typescriptPath;
28
24
  try {
29
- typescriptPath = src_require.resolve('typescript', {
25
+ typescriptPath = src_require.resolve("typescript", {
30
26
  paths: [
31
27
  api.context.rootPath
32
28
  ]
33
29
  });
34
30
  } catch (err) {
35
- __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.logger.warn('"typescript" is not found in current project, Type checker will not work.');
31
+ __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.logger.warn('"typescript" is not found in current project, Type checker will not work.');
36
32
  return;
37
33
  }
38
- const { references } = __WEBPACK_EXTERNAL_MODULE_json5__["default"].parse(__WEBPACK_EXTERNAL_MODULE_node_fs__["default"].readFileSync(tsconfigPath, 'utf-8'));
34
+ const { references } = __WEBPACK_EXTERNAL_MODULE_json5__["default"].parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(tsconfigPath, 'utf-8'));
39
35
  const useReference = Array.isArray(references) && references.length > 0;
40
36
  const defaultOptions = {
41
37
  typescript: {
42
- // set 'readonly' to avoid emitting tsbuildinfo,
43
- // as the generated tsbuildinfo will break ts-checker-rspack-plugin
44
38
  mode: 'readonly',
45
- // enable build when using project reference
46
39
  build: useReference,
47
- // avoid OOM issue
48
40
  memoryLimit: 8192,
49
- // use tsconfig of user project
50
41
  configFile: tsconfigPath,
51
- // use typescript of user project
52
42
  typescriptPath
53
43
  },
54
44
  issue: {
55
- // ignore types errors from node_modules
56
45
  exclude: [
57
46
  ({ file = '' })=>NODE_MODULES_REGEX.test(file)
58
47
  ]
59
48
  },
60
49
  logger: {
61
- log () {
62
- // do nothing
63
- // we only want to display error messages
64
- },
50
+ log () {},
65
51
  error (message) {
66
52
  console.error(message.replace(/ERROR/g, 'Type Error'));
67
53
  }
68
54
  }
69
55
  };
70
- const mergedOptions = (0, __WEBPACK_EXTERNAL_MODULE_reduce_configs__.reduceConfigs)({
56
+ const mergedOptions = (0, __WEBPACK_EXTERNAL_MODULE_reduce_configs_02786df6__.reduceConfigs)({
71
57
  initial: defaultOptions,
72
58
  config: tsCheckerOptions,
73
59
  mergeFn: __WEBPACK_EXTERNAL_MODULE_deepmerge__["default"]
74
60
  });
75
- if (isProd) __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.logger.info('Type checker is enabled. It may take some time.');
76
- chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(__WEBPACK_EXTERNAL_MODULE_ts_checker_rspack_plugin__.TsCheckerRspackPlugin, [
61
+ if (isProd) __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.logger.info('Type checker is enabled. It may take some time.');
62
+ chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(__WEBPACK_EXTERNAL_MODULE_ts_checker_rspack_plugin_59177e58__.TsCheckerRspackPlugin, [
77
63
  mergedOptions
78
64
  ]);
79
65
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-type-check",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
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.0.1",
39
+ "ts-checker-rspack-plugin": "^1.1.1",
40
40
  "json5": "^2.2.3",
41
- "reduce-configs": "^1.0.0"
41
+ "reduce-configs": "^1.1.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@biomejs/biome": "^1.9.4",
45
- "@playwright/test": "^1.48.2",
46
- "@rsbuild/core": "^1.1.5",
47
- "@rslib/core": "^0.1.0",
45
+ "@playwright/test": "^1.49.1",
46
+ "@rsbuild/core": "^1.1.13",
47
+ "@rslib/core": "^0.3.1",
48
48
  "@types/fs-extra": "^11.0.4",
49
- "@types/node": "^22.8.6",
49
+ "@types/node": "^22.10.5",
50
50
  "fs-extra": "^11.2.0",
51
51
  "nano-staged": "^0.8.0",
52
- "playwright": "^1.48.2",
52
+ "playwright": "^1.49.1",
53
53
  "simple-git-hooks": "^2.11.1",
54
- "typescript": "^5.6.3"
54
+ "typescript": "^5.7.3"
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.12.3",
64
+ "packageManager": "pnpm@9.15.3",
65
65
  "publishConfig": {
66
66
  "access": "public",
67
67
  "registry": "https://registry.npmjs.org/"