Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion website/docs/en/guide/migration/_meta.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["modernjs-module"]
["modernjs-module", "tsup"]
88 changes: 87 additions & 1 deletion website/docs/en/guide/migration/tsup.mdx
Original file line number Diff line number Diff line change
@@ -1 +1,87 @@
# tsup
# Tsup

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

## Installing Dependencies

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

import { PackageManagerTabs } from '@theme';

- Remove tsup:

<PackageManagerTabs command="remove tsup" />

- Install Rslib:

<PackageManagerTabs command="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.

```diff title="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:

```ts title="rslib.config.ts"
import { defineConfig } from '@rslib/core';

export default defineConfig({});
```

## Configuration Migration

Here is the corresponding Rslib configuration for tsup configuration:

| tsup | Rslib |
| ------------- | ------------------------------------------------------------------------------------------ |
| banner | [lib.banner](/config/lib/banner) |
| bundle | [lib.bundle](/config/lib/bundle) |
| clean | [output.cleanDistPath](/config/rsbuild/output) |
| define | [source.define](/config/rsbuild/source) |
| dts | [lib.dts](/config/lib/dts) |
| entry | [source.entry](/config/rsbuild/source) |
| external | [output.externals](/config/rsbuild/output) / [lib.autoExternal](/config/lib/auto-external) |
| format | [lib.format](/config/lib/format) |
| footer | [lib.footer](/config/lib/footer) |
| minify | [output.minify](/config/rsbuild/output) |
| platform | [output.target](/config/rsbuild/output) |
| plugins | [plugins](/config/rsbuild/plugins) |
| sourcemap | [output.sourceMap](/config/rsbuild/output) |
| shims | [lib.shims](/config/lib/shims) |
| terserOptions | [output.minify](/config/rsbuild/output) |
| tsconfig | [source.tsconfigPath](/config/rsbuild/source) |

## Platform

For `platform`, tsup defaults to `node` while Rslib defaults to `web` (the same as tsup's `browser`).

If your target platform is `node`, you can set `output.target` to `node`:

```ts title="rslib.config.ts"
import { defineConfig } from '@rslib/core';

export default defineConfig({
output: {
target: 'node',
},
});
```

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

> The documentation for Rslib can be found in the [rslib/website](https://github.com/web-infra-dev/rslib/tree/main/website) directory.
7 changes: 7 additions & 0 deletions website/docs/en/guide/start/quick-start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,10 @@ Options:
--tools select additional tools (biome, eslint, prettier)
--override override files in target directory
```

## Migration

If you need to migrate from an existing project to Rslib, you can refer to the following guides:

- [Migrating from tsup](/guide/migration/tsup)
- [Migrating from Modern.js Module](/guide/migration/modernjs-module)
Loading