close
logo
Rslib
Guide
Config
Blog
English
简体中文
Guide
Config
Blog
English
简体中文
logo
Rslib

Getting Started

Introduction
Quick start
Glossary
Packages

Solution

Node.js
React
Vue

Basic

CLI
Configure Rslib
Use TypeScript
Output format
Output structure
Upgrade Rslib

Advanced

Handle third-party dependencies
Output compatibility
Declaration files
Import static assets
Import SVGR
Import JSON files
Module Federation
Use Storybook

Migration

Modern.js Module
tsup

FAQ

Features FAQ
📝 Edit this page on GitHub
Previous PageModern.js Module
Next PageFeatures FAQ

#tsup

This section introduces how to migrate a project using tsup to Rslib.

#Installing dependencies

First, you need to replace the npm dependencies of tsup with Rslib's dependencies.

  • Remove tsup:
npm
yarn
pnpm
bun
npm remove tsup
  • Install Rslib:
npm
yarn
pnpm
bun
npm add @rslib/core -D

#Updating npm scripts

Next, you need to update the npm scripts in your package.json to use Rslib's CLI commands.

package.json
{
  "scripts": {
-   "build": "tsup",
-   "build:watch": "tsup --watch",
+   "build": "rslib build",
+   "build:watch": "rslib build --watch"
  }
}

#Create configuration file

Create a Rslib configuration file rslib.config.ts in the same directory as package.json, and add the following content:

rslib.config.ts
import { defineConfig } from '@rslib/core';

export default defineConfig({});

#Configuration migration

Here is the corresponding Rslib configuration for tsup configuration:

tsupRslib
bannerlib.banner
bundlelib.bundle
cleanoutput.cleanDistPath
definesource.define
dtslib.dts
entrysource.entry
externaloutput.externals / lib.autoExternal
formatlib.format
footerlib.footer
minifyoutput.minify
platformoutput.target
pluginsplugins
sourcemapoutput.sourceMap
shimslib.shims
terserOptionsoutput.minify
tsconfigsource.tsconfigPath

#Contents supplement

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 a pull request 🤝.

The documentation for Rslib can be found in the rslib/website directory.