@rsbuild/plugin-react 0.7.0-beta.4 → 0.7.0-beta.6
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.cjs +7 -5
- package/dist/index.js +6 -13
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -41,21 +41,22 @@ var import_node_path = __toESM(require("path"));
|
|
|
41
41
|
var import_shared = require("@rsbuild/shared");
|
|
42
42
|
var modifySwcLoaderOptions = ({
|
|
43
43
|
chain,
|
|
44
|
+
CHAIN_ID,
|
|
44
45
|
modifier
|
|
45
46
|
}) => {
|
|
46
|
-
const ruleIds = [
|
|
47
|
+
const ruleIds = [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI];
|
|
47
48
|
for (const ruleId of ruleIds) {
|
|
48
49
|
if (chain.module.rules.has(ruleId)) {
|
|
49
50
|
const rule = chain.module.rule(ruleId);
|
|
50
|
-
if (rule.uses.has(
|
|
51
|
-
rule.use(
|
|
51
|
+
if (rule.uses.has(CHAIN_ID.USE.SWC)) {
|
|
52
|
+
rule.use(CHAIN_ID.USE.SWC).tap(modifier);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
57
|
var applyBasicReactSupport = (api, options) => {
|
|
57
58
|
const REACT_REFRESH_PATH = require.resolve("react-refresh");
|
|
58
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID
|
|
59
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd: isProd2, target }) => {
|
|
59
60
|
const config = api.getNormalizedConfig();
|
|
60
61
|
const usingHMR = (0, import_shared.isUsingHMR)(config, { isProd: isProd2, target });
|
|
61
62
|
const reactOptions = {
|
|
@@ -66,6 +67,7 @@ var applyBasicReactSupport = (api, options) => {
|
|
|
66
67
|
};
|
|
67
68
|
modifySwcLoaderOptions({
|
|
68
69
|
chain,
|
|
70
|
+
CHAIN_ID,
|
|
69
71
|
modifier: (opts) => {
|
|
70
72
|
const extraOptions = {
|
|
71
73
|
jsc: {
|
|
@@ -87,7 +89,7 @@ var applyBasicReactSupport = (api, options) => {
|
|
|
87
89
|
}
|
|
88
90
|
chain.resolve.alias.set("react-refresh", import_node_path.default.dirname(REACT_REFRESH_PATH));
|
|
89
91
|
const { default: ReactRefreshRspackPlugin } = await import("@rspack/plugin-react-refresh");
|
|
90
|
-
chain.plugin(
|
|
92
|
+
chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin, [
|
|
91
93
|
{
|
|
92
94
|
include: [import_shared.SCRIPT_REGEX],
|
|
93
95
|
...options.reactRefreshOptions
|
package/dist/index.js
CHANGED
|
@@ -18,14 +18,10 @@ import { getNodeEnv } from "@rsbuild/shared";
|
|
|
18
18
|
|
|
19
19
|
// src/react.ts
|
|
20
20
|
import path2 from "path";
|
|
21
|
-
import {
|
|
22
|
-
CHAIN_ID,
|
|
23
|
-
SCRIPT_REGEX,
|
|
24
|
-
deepmerge,
|
|
25
|
-
isUsingHMR
|
|
26
|
-
} from "@rsbuild/shared";
|
|
21
|
+
import { SCRIPT_REGEX, deepmerge, isUsingHMR } from "@rsbuild/shared";
|
|
27
22
|
var modifySwcLoaderOptions = ({
|
|
28
23
|
chain,
|
|
24
|
+
CHAIN_ID,
|
|
29
25
|
modifier
|
|
30
26
|
}) => {
|
|
31
27
|
const ruleIds = [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI];
|
|
@@ -40,7 +36,7 @@ var modifySwcLoaderOptions = ({
|
|
|
40
36
|
};
|
|
41
37
|
var applyBasicReactSupport = (api, options) => {
|
|
42
38
|
const REACT_REFRESH_PATH = __require.resolve("react-refresh");
|
|
43
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID
|
|
39
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID, isDev, isProd: isProd2, target }) => {
|
|
44
40
|
const config = api.getNormalizedConfig();
|
|
45
41
|
const usingHMR = isUsingHMR(config, { isProd: isProd2, target });
|
|
46
42
|
const reactOptions = {
|
|
@@ -51,6 +47,7 @@ var applyBasicReactSupport = (api, options) => {
|
|
|
51
47
|
};
|
|
52
48
|
modifySwcLoaderOptions({
|
|
53
49
|
chain,
|
|
50
|
+
CHAIN_ID,
|
|
54
51
|
modifier: (opts) => {
|
|
55
52
|
const extraOptions = {
|
|
56
53
|
jsc: {
|
|
@@ -72,7 +69,7 @@ var applyBasicReactSupport = (api, options) => {
|
|
|
72
69
|
}
|
|
73
70
|
chain.resolve.alias.set("react-refresh", path2.dirname(REACT_REFRESH_PATH));
|
|
74
71
|
const { default: ReactRefreshRspackPlugin } = await import("@rspack/plugin-react-refresh");
|
|
75
|
-
chain.plugin(
|
|
72
|
+
chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin, [
|
|
76
73
|
{
|
|
77
74
|
include: [SCRIPT_REGEX],
|
|
78
75
|
...options.reactRefreshOptions
|
|
@@ -104,11 +101,7 @@ var applyReactProfiler = (api) => {
|
|
|
104
101
|
};
|
|
105
102
|
|
|
106
103
|
// src/splitChunks.ts
|
|
107
|
-
import {
|
|
108
|
-
createCacheGroups,
|
|
109
|
-
isPlainObject,
|
|
110
|
-
isProd
|
|
111
|
-
} from "@rsbuild/shared";
|
|
104
|
+
import { createCacheGroups, isPlainObject, isProd } from "@rsbuild/shared";
|
|
112
105
|
var applySplitChunksRule = (api, options = {
|
|
113
106
|
react: true,
|
|
114
107
|
router: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-react",
|
|
3
|
-
"version": "0.7.0-beta.
|
|
3
|
+
"version": "0.7.0-beta.6",
|
|
4
4
|
"description": "React plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@rspack/plugin-react-refresh": "0.7.0-beta.
|
|
25
|
+
"@rspack/plugin-react-refresh": "0.7.0-beta.1",
|
|
26
26
|
"react-refresh": "^0.14.2",
|
|
27
|
-
"@rsbuild/shared": "0.7.0-beta.
|
|
27
|
+
"@rsbuild/shared": "0.7.0-beta.6"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/node": "18.x",
|
|
31
31
|
"typescript": "^5.4.2",
|
|
32
|
-
"@rsbuild/core": "0.7.0-beta.
|
|
33
|
-
"@scripts/test-helper": "0.7.0-beta.
|
|
32
|
+
"@rsbuild/core": "0.7.0-beta.6",
|
|
33
|
+
"@scripts/test-helper": "0.7.0-beta.6"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@rsbuild/core": "^0.7.0-beta.
|
|
36
|
+
"@rsbuild/core": "^0.7.0-beta.6"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public",
|