@rsbuild/plugin-react 0.1.8 → 0.2.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 +10 -14
- package/dist/index.mjs +10 -14
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -63,7 +63,7 @@ var applyAntdSupport = (api) => {
|
|
|
63
63
|
...rsbuildConfig.source.transformImport || [],
|
|
64
64
|
{
|
|
65
65
|
libraryName: "antd",
|
|
66
|
-
libraryDirectory: (0, import_shared.isServerTarget)(api.context.
|
|
66
|
+
libraryDirectory: (0, import_shared.isServerTarget)(api.context.targets) ? "lib" : "es",
|
|
67
67
|
style: true
|
|
68
68
|
}
|
|
69
69
|
];
|
|
@@ -81,7 +81,7 @@ var applyArcoSupport = (api) => {
|
|
|
81
81
|
if (transformImport === false || !(0, import_shared2.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) {
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
const isUseSSR = (0, import_shared2.isServerTarget)(api.context.
|
|
84
|
+
const isUseSSR = (0, import_shared2.isServerTarget)(api.context.targets);
|
|
85
85
|
if (!transformImport?.some((item) => item.libraryName === ARCO_NAME)) {
|
|
86
86
|
transformImport.push({
|
|
87
87
|
libraryName: ARCO_NAME,
|
|
@@ -104,33 +104,29 @@ var applyArcoSupport = (api) => {
|
|
|
104
104
|
|
|
105
105
|
// src/splitChunks.ts
|
|
106
106
|
var import_shared3 = require("@rsbuild/shared");
|
|
107
|
-
var applySplitChunksRule = (api, options
|
|
107
|
+
var applySplitChunksRule = (api, options = {
|
|
108
|
+
react: true,
|
|
109
|
+
router: true
|
|
110
|
+
}) => {
|
|
108
111
|
api.modifyBundlerChain((chain) => {
|
|
109
112
|
const config = api.getNormalizedConfig();
|
|
110
|
-
|
|
111
|
-
if (chunkSplit?.strategy !== "split-by-experience") {
|
|
113
|
+
if (config.performance.chunkSplit.strategy !== "split-by-experience") {
|
|
112
114
|
return;
|
|
113
115
|
}
|
|
114
|
-
if (!options) {
|
|
115
|
-
options = {
|
|
116
|
-
react: true,
|
|
117
|
-
router: true
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
116
|
const currentConfig = chain.optimization.splitChunks.values();
|
|
121
117
|
if (!(0, import_shared3.isPlainObject)(currentConfig)) {
|
|
122
118
|
return;
|
|
123
119
|
}
|
|
124
120
|
const extraGroups = {};
|
|
125
|
-
if (options.react
|
|
121
|
+
if (options.react) {
|
|
126
122
|
extraGroups.react = [
|
|
127
123
|
"react",
|
|
128
124
|
"react-dom",
|
|
129
125
|
"scheduler",
|
|
130
|
-
...(0, import_shared3.isProd)() ? [] : ["react-refresh", "@
|
|
126
|
+
...(0, import_shared3.isProd)() ? [] : ["react-refresh", "@rspack/plugin-react-refresh"]
|
|
131
127
|
];
|
|
132
128
|
}
|
|
133
|
-
if (options.router
|
|
129
|
+
if (options.router) {
|
|
134
130
|
extraGroups.router = [
|
|
135
131
|
"react-router",
|
|
136
132
|
"react-router-dom",
|
package/dist/index.mjs
CHANGED
|
@@ -42,7 +42,7 @@ var applyAntdSupport = (api) => {
|
|
|
42
42
|
...rsbuildConfig.source.transformImport || [],
|
|
43
43
|
{
|
|
44
44
|
libraryName: "antd",
|
|
45
|
-
libraryDirectory: isServerTarget(api.context.
|
|
45
|
+
libraryDirectory: isServerTarget(api.context.targets) ? "lib" : "es",
|
|
46
46
|
style: true
|
|
47
47
|
}
|
|
48
48
|
];
|
|
@@ -63,7 +63,7 @@ var applyArcoSupport = (api) => {
|
|
|
63
63
|
if (transformImport === false || !isPackageInstalled(ARCO_NAME, api.context.rootPath)) {
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
|
-
const isUseSSR = isServerTarget2(api.context.
|
|
66
|
+
const isUseSSR = isServerTarget2(api.context.targets);
|
|
67
67
|
if (!transformImport?.some((item) => item.libraryName === ARCO_NAME)) {
|
|
68
68
|
transformImport.push({
|
|
69
69
|
libraryName: ARCO_NAME,
|
|
@@ -90,33 +90,29 @@ import {
|
|
|
90
90
|
isPlainObject,
|
|
91
91
|
createCacheGroups
|
|
92
92
|
} from "@rsbuild/shared";
|
|
93
|
-
var applySplitChunksRule = (api, options
|
|
93
|
+
var applySplitChunksRule = (api, options = {
|
|
94
|
+
react: true,
|
|
95
|
+
router: true
|
|
96
|
+
}) => {
|
|
94
97
|
api.modifyBundlerChain((chain) => {
|
|
95
98
|
const config = api.getNormalizedConfig();
|
|
96
|
-
|
|
97
|
-
if (chunkSplit?.strategy !== "split-by-experience") {
|
|
99
|
+
if (config.performance.chunkSplit.strategy !== "split-by-experience") {
|
|
98
100
|
return;
|
|
99
101
|
}
|
|
100
|
-
if (!options) {
|
|
101
|
-
options = {
|
|
102
|
-
react: true,
|
|
103
|
-
router: true
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
102
|
const currentConfig = chain.optimization.splitChunks.values();
|
|
107
103
|
if (!isPlainObject(currentConfig)) {
|
|
108
104
|
return;
|
|
109
105
|
}
|
|
110
106
|
const extraGroups = {};
|
|
111
|
-
if (options.react
|
|
107
|
+
if (options.react) {
|
|
112
108
|
extraGroups.react = [
|
|
113
109
|
"react",
|
|
114
110
|
"react-dom",
|
|
115
111
|
"scheduler",
|
|
116
|
-
...isProd() ? [] : ["react-refresh", "@
|
|
112
|
+
...isProd() ? [] : ["react-refresh", "@rspack/plugin-react-refresh"]
|
|
117
113
|
];
|
|
118
114
|
}
|
|
119
|
-
if (options.router
|
|
115
|
+
if (options.router) {
|
|
120
116
|
extraGroups.router = [
|
|
121
117
|
"react-router",
|
|
122
118
|
"react-router-dom",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"directory": "packages/plugin-react"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
+
"type": "commonjs",
|
|
11
12
|
"exports": {
|
|
12
13
|
".": {
|
|
13
14
|
"types": "./dist/index.d.ts",
|
|
@@ -21,17 +22,17 @@
|
|
|
21
22
|
"dist"
|
|
22
23
|
],
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@rspack/plugin-react-refresh": "0.4.
|
|
25
|
+
"@rspack/plugin-react-refresh": "0.4.2",
|
|
25
26
|
"react-refresh": "^0.14.0",
|
|
26
27
|
"semver": "^7.5.4",
|
|
27
|
-
"@rsbuild/shared": "0.
|
|
28
|
+
"@rsbuild/shared": "0.2.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@types/node": "
|
|
31
|
+
"@types/node": "16.x",
|
|
31
32
|
"@types/semver": "^7.5.4",
|
|
32
33
|
"typescript": "^5.3.0",
|
|
33
|
-
"@rsbuild/core": "0.
|
|
34
|
-
"@rsbuild/test-helper": "0.
|
|
34
|
+
"@rsbuild/core": "0.2.0",
|
|
35
|
+
"@rsbuild/test-helper": "0.2.0"
|
|
35
36
|
},
|
|
36
37
|
"publishConfig": {
|
|
37
38
|
"access": "public",
|