This chapter introduces how to migrate a Modern.js Builder (or EdenX Builder) project to Rsbuild.
Rsbuild is the new version of Modern.js Builder, with the following key differences:
First, you need to replace the npm dependencies related to Builder with Rsbuild's dependencies.
Next, you need to update the npm scripts in the package.json to Rsbuild's CLI commands.
builder.config.ts
to rsbuild.config.ts
.defineConfig
method from @modern-js/builder-cli
to @rsbuild/core
.builderPlugins
field to plugins
.Rsbuild and Builder have incompatible plugin systems, so you need to replace Builder's plugins with Rsbuild's plugins.
The following table shows the correspondence between Builder plugins and Rsbuild plugins:
Builder | Rsbuild |
---|---|
@modern-js/builder-plugin-vue | @rsbuild/plugin-vue |
@modern-js/builder-plugin-vue2 | @rsbuild/plugin-vue2 |
@modern-js/builder-plugin-stylus | @rsbuild/plugin-stylus |
@modern-js/builder-plugin-node-polyfill | @rsbuild/plugin-node-polyfill |
@modern-js/builder-plugin-image-compress | @rsbuild/plugin-image-compress |
@modern-js/builder-plugin-swc | Enabled by default, no need to use |
@modern-js/builder-plugin-esbuild | No longer supported |
For example, if you were using @modern-js/builder-plugin-vue
, you need to first install @rsbuild/plugin-vue
, then import the plugin in rsbuild.config.ts
and add it to the plugins
field.
Rsbuild is not coupled with any front-end UI framework. Therefore, if you are a React project, you need to manually add React Plugin:
If you are using SVGR in your current project, you also need to register SVGR Plugin:
If you are a user of other frameworks, you can refer to Rsbuild Plugin List to select the corresponding framework plugin.
Most configs in Rsbuild and Builder are consistent, with only a few adjustments.
You can refer to the Rsbuild options to view the configs of Rsbuild.
It is worth noting that, compared to Builder, there are some differences in default values and behaviors in Rsbuild:
dev
and server
configuration instead.After completing the above steps, you have migrated from Modern.js Builder to Rsbuild. You can now try starting the dev server by running the npm run dev
command.
If you encounter any issues during the build process, please debug according to the error logs.
The current document only covers part of the migration process. If you find suitable content to add, feel free to contribute to the documentation via pull request 🤝.
The documentation for rsbuild can be found in the rsbuild/packages/document directory.