@rsbuild/plugin-type-check 1.3.6 → 1.5.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
@@ -117,8 +117,8 @@ const defaultOptions = {
117
117
  memoryLimit: 8192,
118
118
  // use tsconfig of user project
119
119
  configFile: tsconfigPath,
120
- // use typescript of user project
121
- typescriptPath: require.resolve('typescript'),
120
+ // resolve the default TypeScript package from user project
121
+ resolveRoot: api.context.rootPath,
122
122
  },
123
123
  issue: {
124
124
  // ignore types errors from node_modules
@@ -130,12 +130,51 @@ const defaultOptions = {
130
130
  // we only want to display error messages
131
131
  },
132
132
  error(message: string) {
133
- console.error(message.replace(/ERROR/g, 'Type Error'));
133
+ console.error(
134
+ message
135
+ .replace(/ERROR/g, 'Type Error')
136
+ .replace(/WARNING/g, 'Type Warning'),
137
+ );
134
138
  },
135
139
  },
136
140
  };
137
141
  ```
138
142
 
143
+ #### TypeScript Go support
144
+
145
+ TypeScript Go support is powered by `ts-checker-rspack-plugin`'s experimental, CLI-based integration for [typescript-go](https://github.com/microsoft/typescript-go). It runs the TypeScript Go checker binary for type checking and can reduce type-checking time by about 5-10x.
146
+
147
+ Install TypeScript 7.0 RC to use TypeScript Go automatically:
148
+
149
+ ```sh
150
+ # with npm
151
+ npm install -D typescript@rc
152
+
153
+ # with yarn
154
+ yarn add -D typescript@rc
155
+
156
+ # with pnpm
157
+ pnpm add -D typescript@rc
158
+ ```
159
+
160
+ You can also install `@typescript/native-preview` and set `typescript.tsgo` to `true`:
161
+
162
+ ```ts
163
+ pluginTypeCheck({
164
+ tsCheckerOptions: {
165
+ typescript: {
166
+ tsgo: true,
167
+ },
168
+ },
169
+ });
170
+ ```
171
+
172
+ When `tsgo` is enabled and `typescript.typescriptPath` is set manually, it must point to an absolute `typescript/package.json` path from TypeScript 7+ or `@typescript/native-preview/package.json`.
173
+
174
+ > The `@typescript/native-preview` usage is deprecated and kept only for compatibility. We recommend installing `typescript@rc` to use `tsgo`.
175
+
176
+ For supported options and limitations, see [ts-checker-rspack-plugin - TypeScript Go support](https://github.com/rstackjs/ts-checker-rspack-plugin#typescript-go-support).
177
+
139
178
  #### Object Type
140
179
 
141
180
  When the value of `tsCheckerOptions` is an object, it will be deeply merged with the default configuration.
package/dist/index.cjs CHANGED
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
3
- return "u" < typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
4
- }();
5
2
  var __webpack_require__ = {};
6
3
  (()=>{
7
4
  __webpack_require__.n = (module)=>{
@@ -45,14 +42,12 @@ __webpack_require__.d(__webpack_exports__, {
45
42
  });
46
43
  const external_node_fs_namespaceObject = require("node:fs");
47
44
  var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
48
- const external_node_module_namespaceObject = require("node:module");
49
45
  const external_deepmerge_namespaceObject = require("deepmerge");
50
46
  var external_deepmerge_default = /*#__PURE__*/ __webpack_require__.n(external_deepmerge_namespaceObject);
51
47
  const external_json5_namespaceObject = require("json5");
52
48
  var external_json5_default = /*#__PURE__*/ __webpack_require__.n(external_json5_namespaceObject);
53
49
  const external_reduce_configs_namespaceObject = require("reduce-configs");
54
50
  const external_ts_checker_rspack_plugin_namespaceObject = require("ts-checker-rspack-plugin");
55
- const src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
56
51
  const PLUGIN_TYPE_CHECK_NAME = 'rsbuild:type-check';
57
52
  const pluginTypeCheck = (options = {})=>({
58
53
  name: PLUGIN_TYPE_CHECK_NAME,
@@ -68,17 +63,6 @@ const pluginTypeCheck = (options = {})=>({
68
63
  if (!tsconfigPath || false === enable) return;
69
64
  if (checkedTsconfig.has(tsconfigPath) && checkedTsconfig.get(tsconfigPath) !== environment.name) return;
70
65
  checkedTsconfig.set(tsconfigPath, environment.name);
71
- let typescriptPath;
72
- try {
73
- typescriptPath = src_require.resolve("typescript", {
74
- paths: [
75
- api.context.rootPath
76
- ]
77
- });
78
- } catch {
79
- logger.warn('"typescript" is not found in current project, Type checker will not work.');
80
- return;
81
- }
82
66
  const { references } = external_json5_default().parse(external_node_fs_default().readFileSync(tsconfigPath, 'utf-8'));
83
67
  const useReference = Array.isArray(references) && references.length > 0;
84
68
  const defaultOptions = {
@@ -87,7 +71,7 @@ const pluginTypeCheck = (options = {})=>({
87
71
  build: useReference,
88
72
  memoryLimit: 8192,
89
73
  configFile: tsconfigPath,
90
- typescriptPath
74
+ resolveRoot: api.context.rootPath
91
75
  },
92
76
  issue: {
93
77
  exclude: [
@@ -106,7 +90,7 @@ const pluginTypeCheck = (options = {})=>({
106
90
  config: tsCheckerOptions,
107
91
  mergeFn: external_deepmerge_default()
108
92
  });
109
- if (isProd) logger.info('Type checker is enabled. It may take some time.');
93
+ if (isProd) logger.info('Type checker is enabled.');
110
94
  chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(external_ts_checker_rspack_plugin_namespaceObject.TsCheckerRspackPlugin, [
111
95
  mergedOptions
112
96
  ]);
package/dist/index.js CHANGED
@@ -1,10 +1,8 @@
1
1
  import node_fs from "node:fs";
2
- import { createRequire } from "node:module";
3
2
  import deepmerge from "deepmerge";
4
3
  import json5 from "json5";
5
4
  import { reduceConfigs } from "reduce-configs";
6
5
  import { TsCheckerRspackPlugin } from "ts-checker-rspack-plugin";
7
- const src_require = createRequire(import.meta.url);
8
6
  const PLUGIN_TYPE_CHECK_NAME = 'rsbuild:type-check';
9
7
  const pluginTypeCheck = (options = {})=>({
10
8
  name: PLUGIN_TYPE_CHECK_NAME,
@@ -20,17 +18,6 @@ const pluginTypeCheck = (options = {})=>({
20
18
  if (!tsconfigPath || false === enable) return;
21
19
  if (checkedTsconfig.has(tsconfigPath) && checkedTsconfig.get(tsconfigPath) !== environment.name) return;
22
20
  checkedTsconfig.set(tsconfigPath, environment.name);
23
- let typescriptPath;
24
- try {
25
- typescriptPath = src_require.resolve("typescript", {
26
- paths: [
27
- api.context.rootPath
28
- ]
29
- });
30
- } catch {
31
- logger.warn('"typescript" is not found in current project, Type checker will not work.');
32
- return;
33
- }
34
21
  const { references } = json5.parse(node_fs.readFileSync(tsconfigPath, 'utf-8'));
35
22
  const useReference = Array.isArray(references) && references.length > 0;
36
23
  const defaultOptions = {
@@ -39,7 +26,7 @@ const pluginTypeCheck = (options = {})=>({
39
26
  build: useReference,
40
27
  memoryLimit: 8192,
41
28
  configFile: tsconfigPath,
42
- typescriptPath
29
+ resolveRoot: api.context.rootPath
43
30
  },
44
31
  issue: {
45
32
  exclude: [
@@ -58,7 +45,7 @@ const pluginTypeCheck = (options = {})=>({
58
45
  config: tsCheckerOptions,
59
46
  mergeFn: deepmerge
60
47
  });
61
- if (isProd) logger.info('Type checker is enabled. It may take some time.');
48
+ if (isProd) logger.info('Type checker is enabled.');
62
49
  chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(TsCheckerRspackPlugin, [
63
50
  mergedOptions
64
51
  ]);
package/package.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-type-check",
3
- "version": "1.3.6",
4
- "repository": "https://github.com/rstackjs/rsbuild-plugin-type-check",
3
+ "version": "1.5.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/rstackjs/rsbuild-plugin-type-check"
7
+ },
8
+ "homepage": "https://github.com/rstackjs/rsbuild-plugin-type-check#readme",
9
+ "bugs": {
10
+ "url": "https://github.com/rstackjs/rsbuild-plugin-type-check/issues"
11
+ },
5
12
  "license": "MIT",
6
13
  "type": "module",
7
14
  "exports": {
@@ -20,29 +27,34 @@
20
27
  },
21
28
  "dependencies": {
22
29
  "deepmerge": "^4.3.1",
23
- "ts-checker-rspack-plugin": "^1.3.1",
24
30
  "json5": "^2.2.3",
25
- "reduce-configs": "^1.1.2"
31
+ "reduce-configs": "^1.1.2",
32
+ "ts-checker-rspack-plugin": "^1.5.1"
26
33
  },
27
34
  "devDependencies": {
28
- "@playwright/test": "^1.60.0",
29
- "@rsbuild/core": "^2.0.9",
30
- "@rslib/core": "^0.22.0",
31
- "@rslint/core": "^0.5.3",
35
+ "@playwright/test": "^1.61.1",
36
+ "@rsbuild/core": "^2.0.15",
37
+ "@rslib/core": "^0.23.0",
38
+ "@rslint/core": "^0.6.3",
32
39
  "@types/fs-extra": "^11.0.4",
33
- "@types/node": "^24.12.4",
40
+ "@types/node": "^24.13.2",
41
+ "@typescript/native-preview": "7.0.0-dev.20260624.1",
34
42
  "fs-extra": "^11.3.5",
35
- "playwright": "^1.60.0",
36
- "prettier": "^3.8.3",
43
+ "playwright": "^1.61.1",
44
+ "prettier": "^3.8.4",
37
45
  "simple-git-hooks": "^2.13.1",
38
46
  "typescript": "^6.0.3"
39
47
  },
40
48
  "peerDependencies": {
41
- "@rsbuild/core": "^1.0.0 || ^2.0.0"
49
+ "@rsbuild/core": "^1.0.0 || ^2.0.0-0",
50
+ "@typescript/native-preview": "^7.0.0-0"
42
51
  },
43
52
  "peerDependenciesMeta": {
44
53
  "@rsbuild/core": {
45
54
  "optional": true
55
+ },
56
+ "@typescript/native-preview": {
57
+ "optional": true
46
58
  }
47
59
  },
48
60
  "publishConfig": {
@@ -51,10 +63,10 @@
51
63
  },
52
64
  "scripts": {
53
65
  "build": "rslib",
66
+ "bump": "npx bumpp",
54
67
  "dev": "rslib -w",
55
68
  "lint": "rslint && prettier -c .",
56
69
  "lint:write": "rslint --fix && prettier -w .",
57
- "test": "playwright test",
58
- "bump": "npx bumpp"
70
+ "test": "playwright test"
59
71
  }
60
72
  }