|
| 1 | +--- |
| 2 | +name: rspress-v2-upgrade |
| 3 | +description: Migrate Rspress projects from v1 to v2. Use when a user asks to upgrade Rspress, follow the v1-to-v2 guide, update configs/themes, or validate the upgrade. |
| 4 | +--- |
| 5 | + |
| 6 | +# Rspress v1 to v2 Upgrade |
| 7 | + |
| 8 | +## Workflow |
| 9 | + |
| 10 | +1. **Confirm current setup** |
| 11 | + - Read `package.json` to identify Rspress and plugin packages in use. |
| 12 | + - Locate the Rspress config file (commonly `rspress.config.(ts|js|mjs|cjs)`). |
| 13 | + - Check for custom theme files and MDX usage. |
| 14 | + |
| 15 | +2. **Open the official upgrade guide** |
| 16 | + - Use the v1 → v2 guide as the source of truth: |
| 17 | + - https://rspress.rs/zh/guide/migration/rspress-1-x |
| 18 | + |
| 19 | +3. **Plan the upgrade path** |
| 20 | + - List breaking changes that apply to the project's current config, plugins, and theme. |
| 21 | + - Note any removed or renamed packages, options, and APIs. |
| 22 | + |
| 23 | +4. **Update dependencies** |
| 24 | + - Replace `rspress` with `@rspress/core@^2.0.0`. |
| 25 | + - Remove packages now built into `@rspress/core` (e.g. `rspress` `@rspress/plugin-shiki`, `@rspress/plugin-auto-nav-sidebar`, `@rspress/plugin-container-syntax`, `@rspress/plugin-last-updated`, `@rspress/plugin-medium-zoom`, `@rspress/theme-default`, `@rspress/runtime`). |
| 26 | + - Bump remaining Rspress plugins to latest versions via `npx taze major --include /rspress/ -w -r`. |
| 27 | + - Ensure Node.js >= 20.9.0. |
| 28 | + |
| 29 | +5. **Apply config and code changes** |
| 30 | + - Update import paths (`rspress/runtime` → `@rspress/core/runtime`, `rspress/theme` → `@rspress/core/theme`, `@rspress/theme-default` → `@rspress/core/theme-original`). |
| 31 | + - Update the Rspress config to match v2 options and defaults. |
| 32 | + - Remove deprecated or unsupported settings. |
| 33 | + |
| 34 | +6. **Validate** |
| 35 | + - Run the build and dev server. |
| 36 | + - Fix any warnings or errors surfaced by the new version. If errors or warnings appear, refer back to the migration guide to identify which migration step was missed or incomplete, then apply the corresponding fix. |
0 commit comments