-
-
Notifications
You must be signed in to change notification settings - Fork 57
docs: tsup migration guide #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| ["modernjs-module"] | ||
| ["modernjs-module", "tsup"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.