@rsbuild/plugin-react 1.0.0-alpha.2 → 1.0.0-alpha.3
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 +23 -28
- package/dist/index.js +22 -27
- package/package.json +5 -6
package/dist/index.cjs
CHANGED
|
@@ -37,7 +37,6 @@ module.exports = __toCommonJS(src_exports);
|
|
|
37
37
|
|
|
38
38
|
// src/react.ts
|
|
39
39
|
var import_node_path = __toESM(require("path"));
|
|
40
|
-
var import_shared = require("@rsbuild/shared");
|
|
41
40
|
var modifySwcLoaderOptions = ({
|
|
42
41
|
chain,
|
|
43
42
|
CHAIN_ID,
|
|
@@ -69,19 +68,16 @@ var applyBasicReactSupport = (api, options) => {
|
|
|
69
68
|
chain,
|
|
70
69
|
CHAIN_ID,
|
|
71
70
|
modifier: (opts) => {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
react: reactOptions
|
|
81
|
-
}
|
|
82
|
-
}
|
|
71
|
+
opts.jsc ||= {};
|
|
72
|
+
opts.jsc.transform ||= {};
|
|
73
|
+
opts.jsc.transform.react = reactOptions;
|
|
74
|
+
opts.jsc.parser = {
|
|
75
|
+
...opts.jsc.parser,
|
|
76
|
+
syntax: "typescript",
|
|
77
|
+
// enable supports for React JSX/TSX compilation
|
|
78
|
+
tsx: true
|
|
83
79
|
};
|
|
84
|
-
return
|
|
80
|
+
return opts;
|
|
85
81
|
}
|
|
86
82
|
});
|
|
87
83
|
if (!usingHMR) {
|
|
@@ -92,9 +88,10 @@ var applyBasicReactSupport = (api, options) => {
|
|
|
92
88
|
import_node_path.default.dirname(REACT_REFRESH_PATH)
|
|
93
89
|
);
|
|
94
90
|
const { default: ReactRefreshRspackPlugin } = await import("@rspack/plugin-react-refresh");
|
|
91
|
+
const SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/;
|
|
95
92
|
chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin, [
|
|
96
93
|
{
|
|
97
|
-
include: [
|
|
94
|
+
include: [SCRIPT_REGEX],
|
|
98
95
|
...options.reactRefreshOptions
|
|
99
96
|
}
|
|
100
97
|
]);
|
|
@@ -125,7 +122,6 @@ var applyReactProfiler = (api) => {
|
|
|
125
122
|
};
|
|
126
123
|
|
|
127
124
|
// src/splitChunks.ts
|
|
128
|
-
var import_shared2 = require("@rsbuild/shared");
|
|
129
125
|
var isPlainObject = (obj) => obj !== null && typeof obj === "object" && Object.prototype.toString.call(obj) === "[object Object]";
|
|
130
126
|
var applySplitChunksRule = (api, options = {
|
|
131
127
|
react: true,
|
|
@@ -142,20 +138,19 @@ var applySplitChunksRule = (api, options = {
|
|
|
142
138
|
}
|
|
143
139
|
const extraGroups = {};
|
|
144
140
|
if (options.react) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
"react
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
141
|
+
const isProd = process.env.NODE_ENV === "production";
|
|
142
|
+
extraGroups.react = {
|
|
143
|
+
name: "lib-react",
|
|
144
|
+
test: isProd ? /[\\/]node_modules[\\/](?:react|react-dom|scheduler)[\\/]/ : /[\\/]node_modules[\\/](?:react|react-dom|scheduler|react-refresh|@rspack[\\/]plugin-react-refresh)[\\/]/,
|
|
145
|
+
priority: 0
|
|
146
|
+
};
|
|
151
147
|
}
|
|
152
148
|
if (options.router) {
|
|
153
|
-
extraGroups.router =
|
|
154
|
-
"
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
];
|
|
149
|
+
extraGroups.router = {
|
|
150
|
+
name: "lib-router",
|
|
151
|
+
test: /[\\/]node_modules[\\/](?:react-router|react-router-dom|history|@remix-run[\\/]router)[\\/]/,
|
|
152
|
+
priority: 0
|
|
153
|
+
};
|
|
159
154
|
}
|
|
160
155
|
if (!Object.keys(extraGroups).length) {
|
|
161
156
|
return;
|
|
@@ -164,7 +159,7 @@ var applySplitChunksRule = (api, options = {
|
|
|
164
159
|
...currentConfig,
|
|
165
160
|
cacheGroups: {
|
|
166
161
|
...currentConfig.cacheGroups,
|
|
167
|
-
...
|
|
162
|
+
...extraGroups
|
|
168
163
|
}
|
|
169
164
|
});
|
|
170
165
|
});
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,6 @@ import path from "path";
|
|
|
15
15
|
|
|
16
16
|
// src/react.ts
|
|
17
17
|
import path2 from "path";
|
|
18
|
-
import { SCRIPT_REGEX, deepmerge } from "@rsbuild/shared";
|
|
19
18
|
var modifySwcLoaderOptions = ({
|
|
20
19
|
chain,
|
|
21
20
|
CHAIN_ID,
|
|
@@ -47,19 +46,16 @@ var applyBasicReactSupport = (api, options) => {
|
|
|
47
46
|
chain,
|
|
48
47
|
CHAIN_ID,
|
|
49
48
|
modifier: (opts) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
react: reactOptions
|
|
59
|
-
}
|
|
60
|
-
}
|
|
49
|
+
opts.jsc ||= {};
|
|
50
|
+
opts.jsc.transform ||= {};
|
|
51
|
+
opts.jsc.transform.react = reactOptions;
|
|
52
|
+
opts.jsc.parser = {
|
|
53
|
+
...opts.jsc.parser,
|
|
54
|
+
syntax: "typescript",
|
|
55
|
+
// enable supports for React JSX/TSX compilation
|
|
56
|
+
tsx: true
|
|
61
57
|
};
|
|
62
|
-
return
|
|
58
|
+
return opts;
|
|
63
59
|
}
|
|
64
60
|
});
|
|
65
61
|
if (!usingHMR) {
|
|
@@ -70,6 +66,7 @@ var applyBasicReactSupport = (api, options) => {
|
|
|
70
66
|
path2.dirname(REACT_REFRESH_PATH)
|
|
71
67
|
);
|
|
72
68
|
const { default: ReactRefreshRspackPlugin } = await import("@rspack/plugin-react-refresh");
|
|
69
|
+
const SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/;
|
|
73
70
|
chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactRefreshRspackPlugin, [
|
|
74
71
|
{
|
|
75
72
|
include: [SCRIPT_REGEX],
|
|
@@ -103,7 +100,6 @@ var applyReactProfiler = (api) => {
|
|
|
103
100
|
};
|
|
104
101
|
|
|
105
102
|
// src/splitChunks.ts
|
|
106
|
-
import { createCacheGroups } from "@rsbuild/shared";
|
|
107
103
|
var isPlainObject = (obj) => obj !== null && typeof obj === "object" && Object.prototype.toString.call(obj) === "[object Object]";
|
|
108
104
|
var applySplitChunksRule = (api, options = {
|
|
109
105
|
react: true,
|
|
@@ -120,20 +116,19 @@ var applySplitChunksRule = (api, options = {
|
|
|
120
116
|
}
|
|
121
117
|
const extraGroups = {};
|
|
122
118
|
if (options.react) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
"react
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
119
|
+
const isProd = process.env.NODE_ENV === "production";
|
|
120
|
+
extraGroups.react = {
|
|
121
|
+
name: "lib-react",
|
|
122
|
+
test: isProd ? /[\\/]node_modules[\\/](?:react|react-dom|scheduler)[\\/]/ : /[\\/]node_modules[\\/](?:react|react-dom|scheduler|react-refresh|@rspack[\\/]plugin-react-refresh)[\\/]/,
|
|
123
|
+
priority: 0
|
|
124
|
+
};
|
|
129
125
|
}
|
|
130
126
|
if (options.router) {
|
|
131
|
-
extraGroups.router =
|
|
132
|
-
"
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
];
|
|
127
|
+
extraGroups.router = {
|
|
128
|
+
name: "lib-router",
|
|
129
|
+
test: /[\\/]node_modules[\\/](?:react-router|react-router-dom|history|@remix-run[\\/]router)[\\/]/,
|
|
130
|
+
priority: 0
|
|
131
|
+
};
|
|
137
132
|
}
|
|
138
133
|
if (!Object.keys(extraGroups).length) {
|
|
139
134
|
return;
|
|
@@ -142,7 +137,7 @@ var applySplitChunksRule = (api, options = {
|
|
|
142
137
|
...currentConfig,
|
|
143
138
|
cacheGroups: {
|
|
144
139
|
...currentConfig.cacheGroups,
|
|
145
|
-
...
|
|
140
|
+
...extraGroups
|
|
146
141
|
}
|
|
147
142
|
});
|
|
148
143
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-react",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
4
|
"description": "React plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,17 +23,16 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@rspack/plugin-react-refresh": "1.0.0-alpha.0",
|
|
26
|
-
"react-refresh": "^0.14.2"
|
|
27
|
-
"@rsbuild/shared": "1.0.0-alpha.2"
|
|
26
|
+
"react-refresh": "^0.14.2"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
30
29
|
"@types/node": "18.x",
|
|
31
30
|
"typescript": "^5.5.2",
|
|
32
|
-
"@rsbuild/core": "1.0.0-alpha.
|
|
33
|
-
"@scripts/test-helper": "1.0.0-alpha.
|
|
31
|
+
"@rsbuild/core": "1.0.0-alpha.3",
|
|
32
|
+
"@scripts/test-helper": "1.0.0-alpha.3"
|
|
34
33
|
},
|
|
35
34
|
"peerDependencies": {
|
|
36
|
-
"@rsbuild/core": "^1.0.0-alpha.
|
|
35
|
+
"@rsbuild/core": "^1.0.0-alpha.3"
|
|
37
36
|
},
|
|
38
37
|
"publishConfig": {
|
|
39
38
|
"access": "public",
|