@modern-js/rsbuild-plugin-esbuild 2.54.6 → 2.56.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/dist/index.js +47 -5
- package/package.json +5 -6
package/dist/index.js
CHANGED
|
@@ -32,14 +32,56 @@ __export(src_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(src_exports);
|
|
34
34
|
var import_path = __toESM(require("path"));
|
|
35
|
-
|
|
35
|
+
const JS_REGEX = /\.(?:js|mjs|cjs|jsx)$/;
|
|
36
36
|
const TS_REGEX = /\.(?:ts|mts|cts|tsx)$/;
|
|
37
|
+
const NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/;
|
|
38
|
+
const castArray = (arr) => {
|
|
39
|
+
if (arr === void 0) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
return Array.isArray(arr) ? arr : [
|
|
43
|
+
arr
|
|
44
|
+
];
|
|
45
|
+
};
|
|
46
|
+
function applyScriptCondition({ rule, chain, config, context, includes, excludes }) {
|
|
47
|
+
rule.include.add({
|
|
48
|
+
and: [
|
|
49
|
+
context.rootPath,
|
|
50
|
+
{
|
|
51
|
+
not: NODE_MODULES_REGEX
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
});
|
|
55
|
+
rule.include.add(/\.(?:ts|tsx|jsx|mts|cts)$/);
|
|
56
|
+
const target = castArray(chain.get("target"));
|
|
57
|
+
const legacyTarget = [
|
|
58
|
+
"es5",
|
|
59
|
+
"es6",
|
|
60
|
+
"es2015",
|
|
61
|
+
"es2016"
|
|
62
|
+
];
|
|
63
|
+
if (legacyTarget.some((item) => target.includes(item))) {
|
|
64
|
+
rule.include.add(/[\\/]@rsbuild[\\/]core[\\/]dist[\\/]/);
|
|
65
|
+
}
|
|
66
|
+
for (const condition of [
|
|
67
|
+
...includes,
|
|
68
|
+
...config.source.include || []
|
|
69
|
+
]) {
|
|
70
|
+
rule.include.add(condition);
|
|
71
|
+
}
|
|
72
|
+
for (const condition of [
|
|
73
|
+
...excludes,
|
|
74
|
+
...config.source.exclude || []
|
|
75
|
+
]) {
|
|
76
|
+
rule.exclude.add(condition);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
37
79
|
function pluginEsbuild(userOptions = {}) {
|
|
38
80
|
return {
|
|
39
81
|
name: "modernjs:esbuild",
|
|
40
82
|
setup(api) {
|
|
41
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd, target }) => {
|
|
42
|
-
const rsbuildConfig =
|
|
83
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd, target, environment }) => {
|
|
84
|
+
const rsbuildConfig = environment.config;
|
|
43
85
|
const esbuildLoaderPath = import_path.default.join(__dirname, "../compiled/esbuild-loader/index.js");
|
|
44
86
|
const options = {
|
|
45
87
|
loader: {
|
|
@@ -56,7 +98,7 @@ function pluginEsbuild(userOptions = {}) {
|
|
|
56
98
|
if (options.loader !== false) {
|
|
57
99
|
chain.module.rule(CHAIN_ID.RULE.JS).uses.delete(CHAIN_ID.USE.BABEL);
|
|
58
100
|
chain.module.rule(CHAIN_ID.RULE.TS).uses.delete(CHAIN_ID.USE.BABEL).delete(CHAIN_ID.USE.TS);
|
|
59
|
-
chain.module.rule(CHAIN_ID.RULE.JS).test(
|
|
101
|
+
chain.module.rule(CHAIN_ID.RULE.JS).test(JS_REGEX).use("esbuild").loader(esbuildLoaderPath).options({
|
|
60
102
|
loader: "jsx",
|
|
61
103
|
...options === null || options === void 0 ? void 0 : options.loader
|
|
62
104
|
});
|
|
@@ -65,7 +107,7 @@ function pluginEsbuild(userOptions = {}) {
|
|
|
65
107
|
loader: "tsx",
|
|
66
108
|
...options === null || options === void 0 ? void 0 : options.loader
|
|
67
109
|
});
|
|
68
|
-
|
|
110
|
+
applyScriptCondition({
|
|
69
111
|
chain,
|
|
70
112
|
rule,
|
|
71
113
|
config: rsbuildConfig,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/rsbuild-plugin-esbuild",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.56.0",
|
|
4
4
|
"description": "Esbuild Rsbuild plugin and Modern.js",
|
|
5
5
|
"homepage": "https://modernjs.dev",
|
|
6
6
|
"repository": {
|
|
@@ -23,15 +23,14 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@swc/helpers": "0.5.3",
|
|
26
|
-
"@rsbuild/shared": "0.7.10",
|
|
27
26
|
"esbuild": "0.17.19",
|
|
28
|
-
"webpack": "^5.
|
|
27
|
+
"webpack": "^5.93.0"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
31
|
-
"@rsbuild/core": "0.
|
|
32
|
-
"@rsbuild/webpack": "0.
|
|
30
|
+
"@rsbuild/core": "1.0.1-beta.3",
|
|
31
|
+
"@rsbuild/webpack": "1.0.1-beta.3",
|
|
33
32
|
"typescript": "^5.4.2",
|
|
34
|
-
"@scripts/build": "2.
|
|
33
|
+
"@scripts/build": "2.56.0"
|
|
35
34
|
},
|
|
36
35
|
"publishConfig": {
|
|
37
36
|
"access": "public",
|