From 504e9a5518604b434a069a0e9babd34e0f829371 Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Sat, 7 Jun 2025 15:47:56 +0200 Subject: [PATCH 1/4] docs(rolldown): add @vitejs/plugin-react-oxc recommendation (#20152) --- guide/rolldown.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/guide/rolldown.md b/guide/rolldown.md index 2b26f8e7..41f4f803 100644 --- a/guide/rolldown.md +++ b/guide/rolldown.md @@ -109,6 +109,12 @@ Thanks to Rolldown and Oxc, various internal Vite plugins, such as the alias or To test them, you can set the `experimental.enableNativePlugin` option to `true` in your Vite config. +### `@vitejs/plugin-react-oxc` + +When using `@vitejs/plugin-react` or `@vitejs/plugin-react-swc`, you can switch to the `@vitejs/plugin-react-oxc` plugin, which uses Oxc for React's fast-refresh instead of Babel or SWC. It is designed to be a drop-in replacement, providing better build performance and aligning with the underlying architecture of `rolldown-vite`. + +Be aware that you can only switch to `@vitejs/plugin-react-oxc` if you are not using any Babel or SWC plugins (including the React compiler), or mutate the SWC options. + ### `withFilter` Wrapper Plugin authors have the option to use the [hook filter feature](#hook-filter-feature) to reduce the communication overhead between the Rust and JavaScript runtimes. From c08172f3011d097ccafa15470c703e41401bf2fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Exbrayat?= Date: Sat, 7 Jun 2025 15:48:18 +0200 Subject: [PATCH 2/4] docs(rolldown): add manualChunks to advancedChunks migration guide (#20161) --- guide/rolldown.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/guide/rolldown.md b/guide/rolldown.md index 41f4f803..1146ad24 100644 --- a/guide/rolldown.md +++ b/guide/rolldown.md @@ -99,6 +99,42 @@ Rolldown throws an error when unknown or invalid options are passed. Because som If you don't pass the option in yourself, this must be fixed by the utilized framework. You can suppress this error in the meantime by setting the `ROLLDOWN_OPTIONS_VALIDATION=loose` environment variable. +### API Differences + +#### `manualChunks` to `advancedChunks` + +Rolldown does not support the `manualChunks` option that was available in Rollup. Instead, it offers a more fine-grained setting via the [`advancedChunks` option](https://rolldown.rs/guide/in-depth/advanced-chunks#advanced-chunks), which is more similar to webpack's `splitChunk`: + +```js +// Old configuration (Rollup) +export default { + build: { + rollupOptions: { + output: { + manualChunks(id) { + if (/\/react(?:-dom)?/.test(id)) { + return 'vendor' + } + } + } + } + } +} + +// New configuration (Rolldown) +export default { + build: { + rollupOptions: { + output: { + advancedChunks: { + groups: [{ name: 'vendor', test: /\/react(?:-dom)?// }] + } + } + } + } +} +``` + ## Performance `rolldown-vite` is focused on ensuring compatibility with the existing ecosystem, so defaults are geared towards a smooth transition. You can get further performance gains by switching over to faster Rust-based internal plugins and other customizations. From 0cacf917012c23997366501075d182a7b253a07b Mon Sep 17 00:00:00 2001 From: Kylin <1159469891@qq.com> Date: Sun, 8 Jun 2025 10:05:40 +0800 Subject: [PATCH 3/4] docs: update content --- guide/rolldown.md | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/guide/rolldown.md b/guide/rolldown.md index 101d4e39..e9e4e768 100644 --- a/guide/rolldown.md +++ b/guide/rolldown.md @@ -99,17 +99,14 @@ Rolldown 专注于三个主要原则: 如果你自己没有传递这个选项,这个问题必须由使用的框架来解决。你可以通过设置 `ROLLDOWN_OPTIONS_VALIDATION=loose` 环境变量来暂时忽略这个错误。 -<<<<<<< HEAD -## 性能 {#performance} -======= -### API Differences +### API差异 {#api-differences} -#### `manualChunks` to `advancedChunks` +#### `manualChunks` 改为 `advancedChunks` {#manualchunks-changed-to-advancedchunks} -Rolldown does not support the `manualChunks` option that was available in Rollup. Instead, it offers a more fine-grained setting via the [`advancedChunks` option](https://rolldown.rs/guide/in-depth/advanced-chunks#advanced-chunks), which is more similar to webpack's `splitChunk`: +Rolldown 不再支持 Rollup 中可用的 `manualChunks` 选项。取而代之的是,它提供了一个更细粒度的设置:[`advancedChunks`](https://rolldown.rs/guide/in-depth/advanced-chunks#advanced-chunks),其行为与 webpack 的 `splitChunk` 类似。 ```js -// Old configuration (Rollup) +// 旧配置 (Rollup) export default { build: { rollupOptions: { @@ -124,7 +121,7 @@ export default { } } -// New configuration (Rolldown) +// 新配置 (Rolldown) export default { build: { rollupOptions: { @@ -138,8 +135,7 @@ export default { } ``` -## Performance ->>>>>>> c08172f3011d097ccafa15470c703e41401bf2fb +## 性能 {#performance} `rolldown-vite` 主要致力于确保与现有生态系统的兼容性,因此其默认配置旨在实现平滑过渡。如果你切换到更快的基于 Rust 的内部插件或进行其他自定义配置,还可以获得进一步的性能提升。 @@ -149,17 +145,13 @@ export default { 要测试它们,你可以在你的 Vite 配置中将 `experimental.enableNativePlugin` 选项设置为 `true`。 -<<<<<<< HEAD -### `withFilter` 包装器 {#withfilter-wrapper} -======= -### `@vitejs/plugin-react-oxc` +### `@vitejs/plugin-react-oxc` {#@vitejs/plugin-react-oxc} -When using `@vitejs/plugin-react` or `@vitejs/plugin-react-swc`, you can switch to the `@vitejs/plugin-react-oxc` plugin, which uses Oxc for React's fast-refresh instead of Babel or SWC. It is designed to be a drop-in replacement, providing better build performance and aligning with the underlying architecture of `rolldown-vite`. +当使用 `@vitejs/plugin-react` 或 `@vitejs/plugin-react-swc` 时,你可以切换到 `@vitejs/plugin-react-oxc` 插件,它使用 Oxc 来实现 React 的快速刷新(Fast Refresh),取代原先的 Babel 或 SWC。该插件的设计目标是作为替代品无缝接入,同时提供更好的构建性能,并与 `rolldown-vite` 的底层架构保持一致。 -Be aware that you can only switch to `@vitejs/plugin-react-oxc` if you are not using any Babel or SWC plugins (including the React compiler), or mutate the SWC options. +请注意,只有在未使用任何 Babel 或 SWC 插件(包括 React 编译器)且未修改 SWC 选项的情况下,你才可以切换到 `@vitejs/plugin-react-oxc`。 -### `withFilter` Wrapper ->>>>>>> c08172f3011d097ccafa15470c703e41401bf2fb +### `withFilter` 包装器 {#withfilter-wrapper} 插件作者可以选择使用 [钩子过滤功能](#hook-filter-feature),以减少 Rust 和 JavaScript 运行时之间的通信开销。 但如果你使用的某些插件还未采用该功能,而你又希望受益于它,可以使用 `withFilter` 包装器自行为插件添加过滤条件。 From db3cc8454d3f341ad0be0d5abef99b3a2de63efe Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Sun, 8 Jun 2025 13:40:06 +0800 Subject: [PATCH 4/4] Update guide/rolldown.md --- guide/rolldown.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/rolldown.md b/guide/rolldown.md index e9e4e768..efdf97d4 100644 --- a/guide/rolldown.md +++ b/guide/rolldown.md @@ -99,7 +99,7 @@ Rolldown 专注于三个主要原则: 如果你自己没有传递这个选项,这个问题必须由使用的框架来解决。你可以通过设置 `ROLLDOWN_OPTIONS_VALIDATION=loose` 环境变量来暂时忽略这个错误。 -### API差异 {#api-differences} +### API 差异 {#api-differences} #### `manualChunks` 改为 `advancedChunks` {#manualchunks-changed-to-advancedchunks}