You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/document/builder-doc/docs/en/guide/advanced/rspack-start.mdx
+67-7Lines changed: 67 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ Builder aims to eliminate the main differences between different bundlers and he
65
65
66
66
This article will introduce the differences between webpack and Rspack from the perspective of Builder. If you need to know more in-depth differences, please refer to the [Rspack documentation](http://rspack.dev/guide/migrate-from-webpack.html).
67
67
68
-
### Builder configuration differences
68
+
### 1. Builder configuration differences
69
69
70
70
Currently, most of configuration options in Builder have been adapted for Rspack.
71
71
Throughout this process, Builder's work includes but is not limited to:
@@ -112,8 +112,9 @@ Unsupported configurations and capabilities include:
@@ -156,30 +157,44 @@ Unsupported configurations and capabilities include:
156
157
In addition to the above configurations, some of the supported configurations may have differences in their capabilities. For specific differences in configurations, please refer to the corresponding API for each configuration.
157
158
:::
158
159
159
-
### Migrating from webpackChain to bundlerChain
160
+
### 2. Migrating from webpackChain to bundlerChain
160
161
161
162
Builder supports modifying Rspack config via [bundlerChain](/api/config-tools.html#toolsbundlerchain). configurations modified via bundlerChain will take effect on both webpack and Rspack builds.
162
163
164
+
```diff
165
+
export default {
166
+
tools: {
167
+
- webpackChain: (chain, { env }) => {
168
+
+ bundlerChain: (chain, { env }) => {
169
+
if (env === 'development') {
170
+
chain.devtool('cheap-module-eval-source-map');
171
+
}
172
+
},
173
+
},
174
+
};
175
+
```
176
+
163
177
:::tip
164
178
The bundlerChain only provides consistent api modification for Rspack & webpack configurations, the actual plugin / loader availability depends on the actual Rspack / webpack support.
165
179
:::
166
180
167
-
### CHAIN_ID differences
181
+
####CHAIN_ID differences
168
182
169
183
Because of some implementation differences between webpack and Rspack, there are some differences in the rules configuration.
170
184
171
185
You can see all the rules that are supported in both Rspack & webpack via [tools.bundlerChain#CHAIN_ID](/api/config-tools.html#chain_id).
172
186
173
-
### Modify the Rspack Configuration Object
187
+
### 3. Migrating from tools.webpack to tools.rspack
174
188
175
189
BundlerChain only supports modifying the Rspack & webpack intersection config, more Rspack-exclusive features need to be modified via [tools.rspack](/api/config-tools.html#toolsrspack).
176
190
177
191
Before modify the Rspack configuration object, you may should know [the config diff between Rspack and Webapck](https://www.rspack.dev/guide/config-diff.html).
178
192
179
-
```ts
193
+
```diff
180
194
export default {
181
195
tools: {
182
-
rspack: (config, { env }) => {
196
+
- webppack: (config, { env }) => {
197
+
+ rspack: (config, { env }) => {
183
198
if (env === 'development') {
184
199
config.devtool = 'cheap-module-eval-source-map';
185
200
}
@@ -190,3 +205,48 @@ export default {
190
205
```
191
206
192
207
More information about Rspack, please refer to the [Rspack website](https://www.rspack.dev/).
208
+
209
+
### 4. Babel Configuration Migration
210
+
211
+
By default, Rspack uses SWC for transpilation and compression. Therefore, when using Rspack for building, babel-loader is not loaded by default.
212
+
213
+
For most common Babel plugins, you can find corresponding alternatives in Rspack, and there are also corresponding compatible configuration options in Builder.
| babel-plugin-lodash | Not supported | Not supported |
222
+
| babel-plugin-styled-components | Not supported | Not supported |
223
+
|@babel/plugin-react-transform-remove-prop-types | Not supported | Not supported |
224
+
225
+
:::Tip
226
+
When using Rspack for building, you can still configure Babel plugins through [tools.babel](/api/config-tools.html#toolsbabel), but this will result in additional compilation overhead, which may slow down the Rspack build to some extent.
227
+
:::
228
+
229
+
### 5. SWC Configuration Support
230
+
231
+
Rspack has built-in support for some swc configurations, such as builtins.react, which can be referred to in [Builtins](https://www.rspack.dev/config/builtins.html).
232
+
233
+
Adding swc plugins and more custom configurations is not currently supported in Rspack. Relevant requirements can be tracked through the corresponding [issue](https://github.com/web-infra-dev/rspack/issues/3067).
234
+
235
+
### 6. Webpack Plugin Migration
236
+
237
+
Currently, only a limited number of webpack plugins are compatible with Rspack.
238
+
239
+
If you are using the following plugins (or indirect dependencies) in your project, you will need to temporarily remove them or use alternative solutions, otherwise you won't be able to switch to the Rspack build:
0 commit comments