This section introduces how to migrate a project using Modern.js Module to Rslib.
Rslib
has a minimal dependency footprint. For the basic functionality you only need the package @rslib/core
.
You can create a new Rslib project by following the Quick Start to see the package.json
file. Then update your existing package.json
file like below:
main
, lint-staged
, simple-git-hooks
, sideEffects
and publishConfig
types
field from ./dist/types/index.d.ts
to ./dist/index.d.ts
module
field from ./dist/es/index.js
to ./dist/index.js
prepare
, build:watch
, reset
, change
, bump
, pre
, change-status
, gen-release-note
, release
, new
, upgrade
build
from modern build
to rslib build
dev
from modern dev
to rslib build --watch
lint
name to check
and keep the valueformat
with the value biome format --write
test
with the value vitest run
exports
(object)
"."
(object)"types": "./dist/index.d.ts"
and "import": "./dist/index.js"
files
with the value ["dist"]
devDependencies
can vary
@modern-js/module-tools
with @rslib/core
rimraf
, lint-staged
and simple-git-hooks
anymore for startersdependencies
and peerDependencies
if neededYour package.json
should look something like this:
Now we have a clean slate to work with. We will continue with the Rslib
configuration. It follows the same pattern as all Rs*
projects. Since this step is very unique for every environment, below is an basic example:
Replace your modern.config.ts
with a rslib.config.ts
:
If you use Typescript in your Modern.js Module
and need to generate declaration files, add the following changes:
If you use React in your Modern.js Module
, add the following changes:
In addition, you have to install the @rsbuild/plugin-react
package as devDependencies
.
If you use Sass in your Modern.js Module
, add the following changes:
In addition, you have to install the @rsbuild/plugin-sass
package as devDependencies
.
If you run Typescript together with Sass, you might run into DTS generation errors. This can be resolved by adding a global.d.ts
file in your /src
directory.
If you use CSS Modules in your Modern.js Module
, add the following changes:
This migration doc is contributed by community user YanPes. Much appreciation for his contribution!
Rslib is designed to be next generation of Modern.js Module and we will provide more detailed guide and scripts for migration in 2025 Q1.