@rsbuild/plugin-type-check 1.2.0 → 1.2.2
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 +2 -0
- package/dist/index.cjs +17 -42
- package/dist/index.js +13 -27
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -10,6 +10,8 @@ An Rsbuild plugin to run TypeScript type checker in a separate process.
|
|
|
10
10
|
<a href="https://npmcharts.com/compare/@rsbuild/plugin-type-check?minimal=true"><img src="https://img.shields.io/npm/dm/@rsbuild/plugin-type-check.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" /></a>
|
|
11
11
|
</p>
|
|
12
12
|
|
|
13
|
+
<img width="1472" alt="Screenshot 2025-02-14 at 23 08 37" src="https://github.com/user-attachments/assets/15d38419-34af-4a69-8841-8f9c608d8b68" />
|
|
14
|
+
|
|
13
15
|
## Introduction
|
|
14
16
|
|
|
15
17
|
This plugin internally integrates with [ts-checker-rspack-plugin](https://github.com/rspack-contrib/ts-checker-rspack-plugin).
|
package/dist/index.cjs
CHANGED
|
@@ -2,42 +2,29 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
var getter = module && module.__esModule ? function() {
|
|
12
|
-
return module['default'];
|
|
13
|
-
} : function() {
|
|
14
|
-
return module;
|
|
15
|
-
};
|
|
7
|
+
__webpack_require__.n = (module)=>{
|
|
8
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
16
9
|
__webpack_require__.d(getter, {
|
|
17
10
|
a: getter
|
|
18
11
|
});
|
|
19
12
|
return getter;
|
|
20
13
|
};
|
|
21
14
|
})();
|
|
22
|
-
// webpack/runtime/define_property_getters
|
|
23
15
|
(()=>{
|
|
24
|
-
__webpack_require__.d =
|
|
16
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
25
17
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
26
18
|
enumerable: true,
|
|
27
19
|
get: definition[key]
|
|
28
20
|
});
|
|
29
21
|
};
|
|
30
22
|
})();
|
|
31
|
-
// webpack/runtime/has_own_property
|
|
32
23
|
(()=>{
|
|
33
|
-
__webpack_require__.o =
|
|
34
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
35
|
-
};
|
|
24
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
36
25
|
})();
|
|
37
|
-
// webpack/runtime/make_namespace_object
|
|
38
26
|
(()=>{
|
|
39
|
-
|
|
40
|
-
__webpack_require__.r = function(exports1) {
|
|
27
|
+
__webpack_require__.r = (exports1)=>{
|
|
41
28
|
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
42
29
|
value: 'Module'
|
|
43
30
|
});
|
|
@@ -46,13 +33,11 @@ var __webpack_require__ = {};
|
|
|
46
33
|
});
|
|
47
34
|
};
|
|
48
35
|
})();
|
|
49
|
-
|
|
50
|
-
// ESM COMPAT FLAG
|
|
36
|
+
var __webpack_exports__ = {};
|
|
51
37
|
__webpack_require__.r(__webpack_exports__);
|
|
52
|
-
// EXPORTS
|
|
53
38
|
__webpack_require__.d(__webpack_exports__, {
|
|
54
|
-
PLUGIN_TYPE_CHECK_NAME: ()
|
|
55
|
-
pluginTypeCheck: ()
|
|
39
|
+
PLUGIN_TYPE_CHECK_NAME: ()=>PLUGIN_TYPE_CHECK_NAME,
|
|
40
|
+
pluginTypeCheck: ()=>pluginTypeCheck
|
|
56
41
|
});
|
|
57
42
|
const external_node_fs_namespaceObject = require("node:fs");
|
|
58
43
|
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
@@ -75,17 +60,13 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
75
60
|
const { enable = true, forkTsCheckerOptions } = options;
|
|
76
61
|
let { tsCheckerOptions } = options;
|
|
77
62
|
const { tsconfigPath } = environment;
|
|
78
|
-
// compatible with the legacy option
|
|
79
63
|
if (void 0 === tsCheckerOptions && void 0 !== forkTsCheckerOptions) tsCheckerOptions = forkTsCheckerOptions;
|
|
80
64
|
if (!tsconfigPath || false === enable) return;
|
|
81
|
-
// If there are identical tsconfig.json files,
|
|
82
|
-
// apply type checker only once to avoid duplicate checks.
|
|
83
65
|
if (checkedTsconfig.has(tsconfigPath) && checkedTsconfig.get(tsconfigPath) !== environment.name) return;
|
|
84
66
|
checkedTsconfig.set(tsconfigPath, environment.name);
|
|
85
|
-
// use typescript of user project
|
|
86
67
|
let typescriptPath;
|
|
87
68
|
try {
|
|
88
|
-
typescriptPath = src_require.resolve(
|
|
69
|
+
typescriptPath = src_require.resolve("typescript", {
|
|
89
70
|
paths: [
|
|
90
71
|
api.context.rootPath
|
|
91
72
|
]
|
|
@@ -98,29 +79,19 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
98
79
|
const useReference = Array.isArray(references) && references.length > 0;
|
|
99
80
|
const defaultOptions = {
|
|
100
81
|
typescript: {
|
|
101
|
-
// set 'readonly' to avoid emitting tsbuildinfo,
|
|
102
|
-
// as the generated tsbuildinfo will break ts-checker-rspack-plugin
|
|
103
82
|
mode: 'readonly',
|
|
104
|
-
// enable build when using project reference
|
|
105
83
|
build: useReference,
|
|
106
|
-
// avoid OOM issue
|
|
107
84
|
memoryLimit: 8192,
|
|
108
|
-
// use tsconfig of user project
|
|
109
85
|
configFile: tsconfigPath,
|
|
110
|
-
// use typescript of user project
|
|
111
86
|
typescriptPath
|
|
112
87
|
},
|
|
113
88
|
issue: {
|
|
114
|
-
// ignore types errors from node_modules
|
|
115
89
|
exclude: [
|
|
116
90
|
({ file = '' })=>NODE_MODULES_REGEX.test(file)
|
|
117
91
|
]
|
|
118
92
|
},
|
|
119
93
|
logger: {
|
|
120
|
-
log () {
|
|
121
|
-
// do nothing
|
|
122
|
-
// we only want to display error messages
|
|
123
|
-
},
|
|
94
|
+
log () {},
|
|
124
95
|
error (message) {
|
|
125
96
|
console.error(message.replace(/ERROR/g, 'Type Error'));
|
|
126
97
|
}
|
|
@@ -138,8 +109,12 @@ const pluginTypeCheck = (options = {})=>({
|
|
|
138
109
|
});
|
|
139
110
|
}
|
|
140
111
|
});
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
112
|
+
exports.PLUGIN_TYPE_CHECK_NAME = __webpack_exports__.PLUGIN_TYPE_CHECK_NAME;
|
|
113
|
+
exports.pluginTypeCheck = __webpack_exports__.pluginTypeCheck;
|
|
114
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
115
|
+
"PLUGIN_TYPE_CHECK_NAME",
|
|
116
|
+
"pluginTypeCheck"
|
|
117
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
118
|
+
Object.defineProperty(exports, '__esModule', {
|
|
144
119
|
value: true
|
|
145
120
|
});
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
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
|
|
7
|
-
import * as
|
|
8
|
-
const src_require = (0,
|
|
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(
|
|
25
|
+
typescriptPath = src_require.resolve("typescript", {
|
|
30
26
|
paths: [
|
|
31
27
|
api.context.rootPath
|
|
32
28
|
]
|
|
33
29
|
});
|
|
34
30
|
} catch (err) {
|
|
35
|
-
|
|
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(
|
|
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,
|
|
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)
|
|
76
|
-
chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(
|
|
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.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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.1.
|
|
39
|
+
"ts-checker-rspack-plugin": "^1.1.2",
|
|
40
40
|
"json5": "^2.2.3",
|
|
41
41
|
"reduce-configs": "^1.1.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@biomejs/biome": "^1.9.4",
|
|
45
|
-
"@playwright/test": "^1.
|
|
46
|
-
"@rsbuild/core": "^1.
|
|
47
|
-
"@rslib/core": "^0.
|
|
45
|
+
"@playwright/test": "^1.52.0",
|
|
46
|
+
"@rsbuild/core": "^1.3.20",
|
|
47
|
+
"@rslib/core": "^0.7.1",
|
|
48
48
|
"@types/fs-extra": "^11.0.4",
|
|
49
|
-
"@types/node": "^22.
|
|
50
|
-
"fs-extra": "^11.
|
|
49
|
+
"@types/node": "^22.15.18",
|
|
50
|
+
"fs-extra": "^11.3.0",
|
|
51
51
|
"nano-staged": "^0.8.0",
|
|
52
|
-
"playwright": "^1.
|
|
53
|
-
"simple-git-hooks": "^2.
|
|
54
|
-
"typescript": "^5.
|
|
52
|
+
"playwright": "^1.52.0",
|
|
53
|
+
"simple-git-hooks": "^2.13.0",
|
|
54
|
+
"typescript": "^5.8.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@
|
|
64
|
+
"packageManager": "pnpm@10.11.0",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public",
|
|
67
67
|
"registry": "https://registry.npmjs.org/"
|