@rsbuild/plugin-type-check 0.0.17 → 0.0.19
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/dist/index.d.ts +9 -7
- package/dist/index.js +4 -2
- package/dist/index.mjs +88 -0
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { RsbuildPlugin, RsbuildPluginAPI } from '@rsbuild/core';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { ChainedConfig } from '@rsbuild/shared';
|
|
3
|
+
import ForkTSCheckerPlugin from 'fork-ts-checker-webpack-plugin';
|
|
4
|
+
|
|
4
5
|
type ForkTsCheckerOptions = ConstructorParameters<typeof ForkTSCheckerPlugin>[0];
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
type PluginTypeCheckerOptions = {
|
|
7
|
+
enable?: boolean;
|
|
8
|
+
forkTsCheckerOptions?: ChainedConfig<ForkTsCheckerOptions>;
|
|
8
9
|
};
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
declare const pluginTypeCheck: (options?: PluginTypeCheckerOptions) => RsbuildPlugin<RsbuildPluginAPI>;
|
|
11
|
+
|
|
12
|
+
export { PluginTypeCheckerOptions, pluginTypeCheck };
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
29
31
|
var src_exports = {};
|
|
30
32
|
__export(src_exports, {
|
|
31
33
|
pluginTypeCheck: () => pluginTypeCheck
|
|
@@ -33,7 +35,7 @@ __export(src_exports, {
|
|
|
33
35
|
module.exports = __toCommonJS(src_exports);
|
|
34
36
|
var import_shared = require("@rsbuild/shared");
|
|
35
37
|
var import_deepmerge = require("@rsbuild/shared/deepmerge");
|
|
36
|
-
|
|
38
|
+
var pluginTypeCheck = (options = {}) => {
|
|
37
39
|
return {
|
|
38
40
|
name: "plugin-type-check",
|
|
39
41
|
setup(api) {
|
|
@@ -45,7 +47,7 @@ const pluginTypeCheck = (options = {}) => {
|
|
|
45
47
|
if (Array.isArray(api.context.target) && target !== api.context.target[0]) {
|
|
46
48
|
return;
|
|
47
49
|
}
|
|
48
|
-
const { default: ForkTsCheckerWebpackPlugin } = await
|
|
50
|
+
const { default: ForkTsCheckerWebpackPlugin } = await import("fork-ts-checker-webpack-plugin");
|
|
49
51
|
let typescriptPath;
|
|
50
52
|
try {
|
|
51
53
|
typescriptPath = require.resolve("typescript", {
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.40.0_typescript@5.2.2/node_modules/@modern-js/module-tools/shims/esm.js
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
11
|
+
import path from "path";
|
|
12
|
+
|
|
13
|
+
// ../../scripts/require_shims.js
|
|
14
|
+
import { createRequire } from "module";
|
|
15
|
+
global.require = createRequire(import.meta.url);
|
|
16
|
+
|
|
17
|
+
// src/index.ts
|
|
18
|
+
import {
|
|
19
|
+
logger,
|
|
20
|
+
CHAIN_ID,
|
|
21
|
+
mergeChainedOptions
|
|
22
|
+
} from "@rsbuild/shared";
|
|
23
|
+
import { deepmerge } from "@rsbuild/shared/deepmerge";
|
|
24
|
+
var pluginTypeCheck = (options = {}) => {
|
|
25
|
+
return {
|
|
26
|
+
name: "plugin-type-check",
|
|
27
|
+
setup(api) {
|
|
28
|
+
api.modifyBundlerChain(async (chain, { target }) => {
|
|
29
|
+
const { enable = true, forkTsCheckerOptions } = options;
|
|
30
|
+
if (!api.context.tsconfigPath || enable === false) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(api.context.target) && target !== api.context.target[0]) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const { default: ForkTsCheckerWebpackPlugin } = await import("fork-ts-checker-webpack-plugin");
|
|
37
|
+
let typescriptPath;
|
|
38
|
+
try {
|
|
39
|
+
typescriptPath = __require.resolve("typescript", {
|
|
40
|
+
paths: [api.context.rootPath]
|
|
41
|
+
});
|
|
42
|
+
} catch (err) {
|
|
43
|
+
logger.warn(
|
|
44
|
+
'"typescript" is not found in current project, Type checker will not work.'
|
|
45
|
+
);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const defaultOptions = {
|
|
49
|
+
typescript: {
|
|
50
|
+
// avoid OOM issue
|
|
51
|
+
memoryLimit: 8192,
|
|
52
|
+
// use tsconfig of user project
|
|
53
|
+
configFile: api.context.tsconfigPath,
|
|
54
|
+
typescriptPath
|
|
55
|
+
},
|
|
56
|
+
issue: {
|
|
57
|
+
exclude: [
|
|
58
|
+
{ file: "**/*.(spec|test).ts" },
|
|
59
|
+
{ file: "**/node_modules/**/*" }
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
logger: {
|
|
63
|
+
log() {
|
|
64
|
+
},
|
|
65
|
+
error(message) {
|
|
66
|
+
console.error(message.replace(/ERROR/g, "Type Error"));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const typeCheckerOptions = mergeChainedOptions({
|
|
71
|
+
defaults: defaultOptions,
|
|
72
|
+
options: forkTsCheckerOptions,
|
|
73
|
+
mergeFn: deepmerge
|
|
74
|
+
});
|
|
75
|
+
if (api.context.bundlerType === "rspack" && chain.get("mode") === "production") {
|
|
76
|
+
logger.info("Ts checker running...");
|
|
77
|
+
logger.info(
|
|
78
|
+
"Ts checker is running slowly and will block builds until it is complete, please be patient and wait."
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
chain.plugin(CHAIN_ID.PLUGIN.TS_CHECKER).use(ForkTsCheckerWebpackPlugin, [typeCheckerOptions]);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
export {
|
|
87
|
+
pluginTypeCheck
|
|
88
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-type-check",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "TS checker plugin of Rsbuild",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"repository": {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.mjs",
|
|
15
16
|
"default": "./dist/index.js"
|
|
16
17
|
}
|
|
17
18
|
},
|
|
@@ -22,15 +23,15 @@
|
|
|
22
23
|
],
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"fork-ts-checker-webpack-plugin": "9.0.0",
|
|
25
|
-
"@rsbuild/shared": "0.0.
|
|
26
|
+
"@rsbuild/shared": "0.0.19"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"typescript": "^5.2.2",
|
|
29
|
-
"@rsbuild/core": "0.0.
|
|
30
|
-
"@rsbuild/test-helper": "0.0.
|
|
30
|
+
"@rsbuild/core": "0.0.19",
|
|
31
|
+
"@rsbuild/test-helper": "0.0.19"
|
|
31
32
|
},
|
|
32
33
|
"peerDependencies": {
|
|
33
|
-
"@rsbuild/core": "^0.0.
|
|
34
|
+
"@rsbuild/core": "^0.0.19"
|
|
34
35
|
},
|
|
35
36
|
"publishConfig": {
|
|
36
37
|
"access": "public",
|