@rsbuild/plugin-react 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 +5 -2
- package/dist/index.js +460 -9
- package/dist/index.mjs +527 -0
- package/package.json +5 -4
- package/dist/antd.d.ts +0 -2
- package/dist/antd.js +0 -62
- package/dist/arco.d.ts +0 -2
- package/dist/arco.js +0 -56
- package/dist/react.d.ts +0 -2
- package/dist/react.js +0 -107
- package/dist/splitChunks.d.ts +0 -3
- package/dist/splitChunks.js +0 -81
package/dist/react.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var react_exports = {};
|
|
30
|
-
__export(react_exports, {
|
|
31
|
-
applyBasicReactSupport: () => applyBasicReactSupport
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(react_exports);
|
|
34
|
-
var import_shared = require("@rsbuild/shared");
|
|
35
|
-
function getReactRefreshEntry(compiler) {
|
|
36
|
-
var _a, _b, _c, _d, _e;
|
|
37
|
-
const hot = (_b = (_a = compiler.options.devServer) == null ? void 0 : _a.hot) != null ? _b : true;
|
|
38
|
-
const refresh = (_e = (_d = (_c = compiler.options.builtins) == null ? void 0 : _c.react) == null ? void 0 : _d.refresh) != null ? _e : true;
|
|
39
|
-
if (hot && refresh) {
|
|
40
|
-
const reactRefreshEntryPath = require.resolve("@rspack/plugin-react-refresh/react-refresh-entry");
|
|
41
|
-
return reactRefreshEntryPath;
|
|
42
|
-
}
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
const setupCompiler = (compiler) => {
|
|
46
|
-
if (!(0, import_shared.isClientCompiler)(compiler)) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const reactRefreshEntry = getReactRefreshEntry(compiler);
|
|
50
|
-
if (!reactRefreshEntry) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
for (const key in compiler.options.entry) {
|
|
54
|
-
compiler.options.entry[key].import = [
|
|
55
|
-
reactRefreshEntry,
|
|
56
|
-
...compiler.options.entry[key].import || []
|
|
57
|
-
];
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const applyBasicReactSupport = (api) => {
|
|
61
|
-
api.onAfterCreateCompiler(({ compiler: multiCompiler }) => {
|
|
62
|
-
if ((0, import_shared.isProd)()) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (multiCompiler.compilers) {
|
|
66
|
-
multiCompiler.compilers.forEach(setupCompiler);
|
|
67
|
-
} else {
|
|
68
|
-
setupCompiler(multiCompiler);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd: isProd2, target }) => {
|
|
72
|
-
const config = api.getNormalizedConfig();
|
|
73
|
-
const usingHMR = (0, import_shared.isUsingHMR)(config, { isProd: isProd2, target });
|
|
74
|
-
const rule = chain.module.rule(CHAIN_ID.RULE.JS);
|
|
75
|
-
const reactOptions = {
|
|
76
|
-
development: !isProd2,
|
|
77
|
-
refresh: usingHMR,
|
|
78
|
-
runtime: "automatic"
|
|
79
|
-
};
|
|
80
|
-
rule.use(CHAIN_ID.USE.SWC).tap((options) => {
|
|
81
|
-
options.jsc.transform.react = {
|
|
82
|
-
...reactOptions
|
|
83
|
-
};
|
|
84
|
-
return options;
|
|
85
|
-
});
|
|
86
|
-
if (chain.module.rules.has(CHAIN_ID.RULE.JS_DATA_URI)) {
|
|
87
|
-
chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).use(CHAIN_ID.USE.SWC).tap((options) => {
|
|
88
|
-
options.jsc.transform.react = {
|
|
89
|
-
...reactOptions
|
|
90
|
-
};
|
|
91
|
-
return options;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
if (!usingHMR) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const { default: ReactRefreshRspackPlugin } = await Promise.resolve().then(() => __toESM(require(
|
|
98
|
-
// TODO https://github.com/web-infra-dev/rspack/issues/4471
|
|
99
|
-
"@rspack/plugin-react-refresh"
|
|
100
|
-
)));
|
|
101
|
-
chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin);
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
105
|
-
0 && (module.exports = {
|
|
106
|
-
applyBasicReactSupport
|
|
107
|
-
});
|
package/dist/splitChunks.d.ts
DELETED
package/dist/splitChunks.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var splitChunks_exports = {};
|
|
20
|
-
__export(splitChunks_exports, {
|
|
21
|
-
applySplitChunksRule: () => applySplitChunksRule,
|
|
22
|
-
splitByExperience: () => splitByExperience
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(splitChunks_exports);
|
|
25
|
-
var import_splitChunks = require("@rsbuild/core/plugins/splitChunks");
|
|
26
|
-
var import_shared = require("@rsbuild/shared");
|
|
27
|
-
async function splitByExperience(rootPath) {
|
|
28
|
-
const experienceCacheGroup = {};
|
|
29
|
-
const packageRegExps = {
|
|
30
|
-
react: (0, import_splitChunks.createDependenciesRegExp)("react", "react-dom", "scheduler"),
|
|
31
|
-
router: (0, import_splitChunks.createDependenciesRegExp)(
|
|
32
|
-
"react-router",
|
|
33
|
-
"react-router-dom",
|
|
34
|
-
"@remix-run/router",
|
|
35
|
-
"history"
|
|
36
|
-
)
|
|
37
|
-
};
|
|
38
|
-
if ((0, import_shared.isPackageInstalled)("antd", rootPath)) {
|
|
39
|
-
packageRegExps.antd = (0, import_splitChunks.createDependenciesRegExp)("antd");
|
|
40
|
-
}
|
|
41
|
-
if ((0, import_shared.isPackageInstalled)("@arco-design/web-react", rootPath)) {
|
|
42
|
-
packageRegExps.arco = (0, import_splitChunks.createDependenciesRegExp)(/@?arco-design/);
|
|
43
|
-
}
|
|
44
|
-
if ((0, import_shared.isPackageInstalled)("@douyinfe/semi-ui", rootPath)) {
|
|
45
|
-
packageRegExps.semi = (0, import_splitChunks.createDependenciesRegExp)(
|
|
46
|
-
/@(ies|douyinfe)[\\/]semi-.*/
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
Object.entries(packageRegExps).forEach(([name, test]) => {
|
|
50
|
-
const key = `lib-${name}`;
|
|
51
|
-
experienceCacheGroup[key] = {
|
|
52
|
-
test,
|
|
53
|
-
priority: 0,
|
|
54
|
-
name: key,
|
|
55
|
-
reuseExistingChunk: true
|
|
56
|
-
};
|
|
57
|
-
});
|
|
58
|
-
return experienceCacheGroup;
|
|
59
|
-
}
|
|
60
|
-
const applySplitChunksRule = (api) => {
|
|
61
|
-
api.modifyRsbuildConfig(async (rsbuildConfig) => {
|
|
62
|
-
const { chunkSplit } = rsbuildConfig.performance || {};
|
|
63
|
-
if ((chunkSplit == null ? void 0 : chunkSplit.strategy) !== "split-by-experience") {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const cacheGroups = await splitByExperience(api.context.rootPath);
|
|
67
|
-
const override = rsbuildConfig.performance.chunkSplit.override;
|
|
68
|
-
rsbuildConfig.performance.chunkSplit.override = {
|
|
69
|
-
cacheGroups: {
|
|
70
|
-
...cacheGroups,
|
|
71
|
-
...override ? override.cacheGroups : {}
|
|
72
|
-
},
|
|
73
|
-
...override || {}
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
-
0 && (module.exports = {
|
|
79
|
-
applySplitChunksRule,
|
|
80
|
-
splitByExperience
|
|
81
|
-
});
|