@rsbuild/plugin-type-check 1.4.0 → 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,11 +117,8 @@ const defaultOptions = {
117
117
  memoryLimit: 8192,
118
118
  // use tsconfig of user project
119
119
  configFile: tsconfigPath,
120
- tsgo: false,
121
- // use typescript of user project
122
- typescriptPath: tsgo
123
- ? require.resolve('@typescript/native-preview/package.json')
124
- : require.resolve('typescript'),
120
+ // resolve the default TypeScript package from user project
121
+ resolveRoot: api.context.rootPath,
125
122
  },
126
123
  issue: {
127
124
  // ignore types errors from node_modules
@@ -133,7 +130,11 @@ const defaultOptions = {
133
130
  // we only want to display error messages
134
131
  },
135
132
  error(message: string) {
136
- 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
+ );
137
138
  },
138
139
  },
139
140
  };
@@ -141,9 +142,22 @@ const defaultOptions = {
141
142
 
142
143
  #### TypeScript Go support
143
144
 
144
- 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 `tsgo` binary for type checking and can reduce type-checking time by about 5-10x.
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.
145
146
 
146
- To enable it, install `@typescript/native-preview` and set `typescript.tsgo` to `true`:
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`:
147
161
 
148
162
  ```ts
149
163
  pluginTypeCheck({
@@ -155,7 +169,9 @@ pluginTypeCheck({
155
169
  });
156
170
  ```
157
171
 
158
- When `tsgo` is enabled, the default `typescript.typescriptPath` resolves to `@typescript/native-preview/package.json`. If you set `typescript.typescriptPath` manually in `tsgo` mode, it must be an absolute path to `@typescript/native-preview/package.json`.
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`.
159
175
 
160
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).
161
177
 
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,25 +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
- const resolveProjectPackage = (packageName, rootPath)=>{
57
- try {
58
- return src_require.resolve(packageName, {
59
- paths: [
60
- rootPath
61
- ]
62
- });
63
- } catch {
64
- return;
65
- }
66
- };
67
51
  const PLUGIN_TYPE_CHECK_NAME = 'rsbuild:type-check';
68
52
  const pluginTypeCheck = (options = {})=>({
69
53
  name: PLUGIN_TYPE_CHECK_NAME,
@@ -81,16 +65,13 @@ const pluginTypeCheck = (options = {})=>({
81
65
  checkedTsconfig.set(tsconfigPath, environment.name);
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
- const projectTypescriptPath = resolveProjectPackage("typescript", api.context.rootPath);
85
- const projectTsgoPath = resolveProjectPackage("@typescript/native-preview/package.json", api.context.rootPath);
86
68
  const defaultOptions = {
87
69
  typescript: {
88
70
  mode: 'readonly',
89
71
  build: useReference,
90
72
  memoryLimit: 8192,
91
73
  configFile: tsconfigPath,
92
- tsgo: false,
93
- typescriptPath: projectTypescriptPath
74
+ resolveRoot: api.context.rootPath
94
75
  },
95
76
  issue: {
96
77
  exclude: [
@@ -109,13 +90,7 @@ const pluginTypeCheck = (options = {})=>({
109
90
  config: tsCheckerOptions,
110
91
  mergeFn: external_deepmerge_default()
111
92
  });
112
- if (mergedOptions.typescript && mergedOptions.typescript.tsgo && mergedOptions.typescript.typescriptPath === projectTypescriptPath) mergedOptions.typescript.typescriptPath = projectTsgoPath;
113
- if (mergedOptions.typescript && !mergedOptions.typescript.typescriptPath) {
114
- const typeCheckerPackage = mergedOptions.typescript.tsgo ? "@typescript/native-preview" : "typescript";
115
- logger.warn(`"${typeCheckerPackage}" is not found in current project, Type checker will not work.`);
116
- return;
117
- }
118
- if (isProd) logger.info('Type checker is enabled. It may take some time.');
93
+ if (isProd) logger.info('Type checker is enabled.');
119
94
  chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(external_ts_checker_rspack_plugin_namespaceObject.TsCheckerRspackPlugin, [
120
95
  mergedOptions
121
96
  ]);
package/dist/index.js CHANGED
@@ -1,21 +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
- const resolveProjectPackage = (packageName, rootPath)=>{
9
- try {
10
- return src_require.resolve(packageName, {
11
- paths: [
12
- rootPath
13
- ]
14
- });
15
- } catch {
16
- return;
17
- }
18
- };
19
6
  const PLUGIN_TYPE_CHECK_NAME = 'rsbuild:type-check';
20
7
  const pluginTypeCheck = (options = {})=>({
21
8
  name: PLUGIN_TYPE_CHECK_NAME,
@@ -33,16 +20,13 @@ const pluginTypeCheck = (options = {})=>({
33
20
  checkedTsconfig.set(tsconfigPath, environment.name);
34
21
  const { references } = json5.parse(node_fs.readFileSync(tsconfigPath, 'utf-8'));
35
22
  const useReference = Array.isArray(references) && references.length > 0;
36
- const projectTypescriptPath = resolveProjectPackage("typescript", api.context.rootPath);
37
- const projectTsgoPath = resolveProjectPackage("@typescript/native-preview/package.json", api.context.rootPath);
38
23
  const defaultOptions = {
39
24
  typescript: {
40
25
  mode: 'readonly',
41
26
  build: useReference,
42
27
  memoryLimit: 8192,
43
28
  configFile: tsconfigPath,
44
- tsgo: false,
45
- typescriptPath: projectTypescriptPath
29
+ resolveRoot: api.context.rootPath
46
30
  },
47
31
  issue: {
48
32
  exclude: [
@@ -61,13 +45,7 @@ const pluginTypeCheck = (options = {})=>({
61
45
  config: tsCheckerOptions,
62
46
  mergeFn: deepmerge
63
47
  });
64
- if (mergedOptions.typescript && mergedOptions.typescript.tsgo && mergedOptions.typescript.typescriptPath === projectTypescriptPath) mergedOptions.typescript.typescriptPath = projectTsgoPath;
65
- if (mergedOptions.typescript && !mergedOptions.typescript.typescriptPath) {
66
- const typeCheckerPackage = mergedOptions.typescript.tsgo ? "@typescript/native-preview" : "typescript";
67
- logger.warn(`"${typeCheckerPackage}" is not found in current project, Type checker will not work.`);
68
- return;
69
- }
70
- if (isProd) logger.info('Type checker is enabled. It may take some time.');
48
+ if (isProd) logger.info('Type checker is enabled.');
71
49
  chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(TsCheckerRspackPlugin, [
72
50
  mergedOptions
73
51
  ]);
package/package.json CHANGED
@@ -1,7 +1,14 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-type-check",
3
- "version": "1.4.0",
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": {
@@ -22,19 +29,19 @@
22
29
  "deepmerge": "^4.3.1",
23
30
  "json5": "^2.2.3",
24
31
  "reduce-configs": "^1.1.2",
25
- "ts-checker-rspack-plugin": "^1.4.0"
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",
34
- "@typescript/native-preview": "7.0.0-dev.20260607.1",
40
+ "@types/node": "^24.13.2",
41
+ "@typescript/native-preview": "7.0.0-dev.20260624.1",
35
42
  "fs-extra": "^11.3.5",
36
- "playwright": "^1.60.0",
37
- "prettier": "^3.8.3",
43
+ "playwright": "^1.61.1",
44
+ "prettier": "^3.8.4",
38
45
  "simple-git-hooks": "^2.13.1",
39
46
  "typescript": "^6.0.3"
40
47
  },