Skip to content

Commit 904085f

Browse files
9aoychenjiahan
andauthored
docs: add rspack upgrade guide (#3734)
* docs: add the Relationship between Rspack and Modern.js Versions * fix: capitalization * Update packages/document/main-doc/docs/zh/guides/advanced-features/rspack-start.mdx Co-authored-by: neverland <[email protected]> * Update packages/document/main-doc/docs/zh/guides/advanced-features/rspack-start.mdx Co-authored-by: neverland <[email protected]> * Update packages/document/main-doc/docs/zh/guides/advanced-features/rspack-start.mdx Co-authored-by: neverland <[email protected]> * Update packages/document/main-doc/docs/zh/guides/advanced-features/rspack-start.mdx Co-authored-by: neverland <[email protected]> * Update packages/document/main-doc/docs/zh/guides/advanced-features/rspack-start.mdx Co-authored-by: neverland <[email protected]> * Update packages/document/main-doc/docs/zh/guides/advanced-features/rspack-start.mdx Co-authored-by: neverland <[email protected]> * Update packages/document/main-doc/docs/en/guides/advanced-features/rspack-start.mdx Co-authored-by: neverland <[email protected]> * Update packages/document/main-doc/docs/en/guides/advanced-features/rspack-start.mdx Co-authored-by: neverland <[email protected]> * Update packages/document/main-doc/docs/en/guides/advanced-features/rspack-start.mdx Co-authored-by: neverland <[email protected]> --------- Co-authored-by: neverland <[email protected]>
1 parent cd534f6 commit 904085f

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

packages/document/main-doc/docs/en/guides/advanced-features/rspack-start.mdx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,41 @@ import appTools, { defineConfig } from '@modern-js/app-tools';
5757
:::tip
5858
When migrating from webpack to Rspack, there may have some differences in build and configuration capabilities. For more details, please refer to [Configuration Differences](https://modernjs.dev/builder/en/guide/advanced/rspack-start.html#migrating-from-webpack-to-rspack).
5959
:::
60+
61+
## The relationship between Rspack and Modern.js versions
62+
63+
Usually, the latest version of Rspack will be integrated into Modern.js. You can update the Modern.js-related dependencies and built-in Rspack to the latest version by using `npx modern upgrade` in your project.
64+
65+
However, Modern.js uses a locked version dependency method (non-automatic upgrade) for Rspack. Due to differences in release cycles, the version of Rspack integrated into Modern.js may be behind the latest version of Rspack.
66+
67+
When Rspack is enabled for building through dev / build, the current version of Rspack used in the framework will be printed automatically:
68+
69+
![rspack_version_log](https://lf3-static.bytednsdoc.com/obj/eden-cn/6221eh7uhbfvhn/modern/img_v2_dfcf051f-21db-4741-a108-d9f7a82c3abg.png)
70+
71+
### Override the Built-in Rspack Version
72+
73+
You can override Rspack to a specific version using the capbilities provided by package managers such as pnpm, yarn, npm.
74+
75+
For example, if you are using pnpm, you can update the Rspack version with `overrides` as shown below:
76+
77+
```json title=package.json
78+
{
79+
"pnpm": {
80+
"overrides": {
81+
"@rspack/core": "nightly",
82+
"@rspack/dev-client": "nightly",
83+
"@rspack/dev-middleware": "nightly",
84+
"@rspack/plugin-html": "nightly",
85+
"@rspack/postcss-loader": "nightly"
86+
}
87+
}
88+
}
89+
```
90+
91+
:::tip What is Rspack Nightly Version
92+
The Rspack nightly build fully replicates the full release build for catching errors early.
93+
Usually it is available and any errors that arise will fixed promptly.
94+
However, if there are any break changes that require modern.js to modify the code, we recommend to wait for the next version of modern.js.
95+
:::
96+
97+
More examples of using package management tools, please refer to: [Lock nested dependency](/guides/get-started/upgrade.html#lock-nested-dependency).

packages/document/main-doc/docs/zh/guides/advanced-features/rspack-start.mdx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,40 @@ import appTools, { defineConfig } from '@modern-js/app-tools';
5858
:::tip
5959
从 webpack 迁移至 Rspack 时,存在一些构建能力和配置上的差异,详情可参考:[配置差异](https://modernjs.dev/builder/guide/advanced/rspack-start.html#从-webpack-迁移到-rspack)
6060
:::
61+
62+
## Rspack 和 Modern.js 的版本关系
63+
64+
通常情况下,Modern.js 内会集成 Rspack 的最新版本,通过 `npx modern upgrade` 即可将当前项目中的 Modern.js 相关依赖以及内置的 Rspack 更新至最新版本。
65+
66+
但 Modern.js 对于 Rspack 的依赖方式为锁版本方式(非自动升级),由于发版周期不同步等原因,可能会出现 Modern.js 内集成的 Rspack 版本落后于 Rspack 最新版本的情况。
67+
68+
当你执行 dev / build 命令时,Modern.js 会自动打印当前使用的 Rspack 版本:
69+
70+
![rspack_version_log](https://lf3-static.bytednsdoc.com/obj/eden-cn/6221eh7uhbfvhn/modern/img_v2_dfcf051f-21db-4741-a108-d9f7a82c3abg.png)
71+
72+
#### 修改内置 Rspack 版本
73+
74+
可以使用 pnpm / yarn / npm 等包管理工具自带的依赖升级功能来将 Rspack 强制升级到指定版本。
75+
76+
以 pnpm 为例,可通过 `overrides` 以下依赖更新 Rspack 版本:
77+
78+
```json title=package.json
79+
{
80+
"pnpm": {
81+
"overrides": {
82+
"@rspack/core": "nightly",
83+
"@rspack/dev-client": "nightly",
84+
"@rspack/dev-middleware": "nightly",
85+
"@rspack/plugin-html": "nightly",
86+
"@rspack/postcss-loader": "nightly"
87+
}
88+
}
89+
}
90+
```
91+
92+
:::tip Nightly 版本介绍
93+
每天,Rspack 会自动构建基于最新代码的 nightly 版本,用于测试和及早发现错误。
94+
通常情况下,这些版本是可用的。如果发现问题,我们会及时进行修复。但是,如果 Rspack 有一些 break change,需要 Modern.js 同步修改代码,那么我们建议等待下一个 Modern.js 版本再进行更新。
95+
:::
96+
97+
如果想了解其他包管理工具锁定依赖版本的示例,可以参考:[锁定子依赖](/guides/get-started/upgrade.html#%E9%94%81%E5%AE%9A%E5%AD%90%E4%BE%9D%E8%B5%96)

0 commit comments

Comments
 (0)