Skip to content

Commit e360f0a

Browse files
docs(rolldown): add further insights (#19823)
Co-authored-by: 翠 / green <green@sapphi.red>
1 parent 541dff1 commit e360f0a

1 file changed

Lines changed: 60 additions & 14 deletions

File tree

docs/guide/rolldown.md

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ Rolldown focuses on three key principles:
1010

1111
- **Speed**: Built with Rust for maximum performance
1212
- **Compatibility**: Works with existing Rollup plugins
13-
- **Developer Experience**: Familiar API for Rollup users
13+
- **Optimization**: Comes with features that go beyond what esbuild and Rollup implement
1414

1515
## Why Vite is Migrating to Rolldown
1616

1717
1. **Unification**: Vite currently uses esbuild for dependency pre-bundling and Rollup for production builds. Rolldown aims to unify these into a single, high-performance bundler that can be used for both purposes, reducing complexity.
1818

1919
2. **Performance**: Rolldown's Rust-based implementation offers significant performance improvements over JavaScript-based bundlers. While specific benchmarks may vary by project size and complexity, early tests show promising speed increases compared to Rollup.
2020

21+
3. **Additional Features**: Rolldown introduces features that are not available in Rollup or esbuild, such as advanced chunk splitting control, built-in HMR, and Module Federation.
22+
2123
For additional insights on the motivations behind Rolldown, see the [reasons why Rolldown is being built](https://rolldown.rs/guide/#why-rolldown).
2224

2325
## Benefits of Trying `rolldown-vite`
@@ -74,11 +76,27 @@ After adding these overrides, reinstall your dependencies and start your develop
7476

7577
While Rolldown aims to be a drop-in replacement for Rollup, there are features that are still being implemented and minor intentional behavior differences. For a comprehensive list, please refer to [this GitHub PR](https://github.com/vitejs/rolldown-vite/pull/84#issue-2903144667) which is regularly updated.
7678

79+
### Option Validation Errors
80+
81+
Rolldown throws an error when unknown or invalid options are passed. Because some options available in Rollup are not supported by Rolldown, you may encounter errors based on the options you or the meta framework you use set. Below, you can find an an example of such an error message:
82+
83+
> Error: Failed validate input options.
84+
>
85+
> - For the "preserveEntrySignatures". Invalid key: Expected never but received "preserveEntrySignatures".
86+
87+
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.
88+
89+
## Enabling Native Plugins
90+
91+
Thanks to Rolldown and Oxc, various internal Vite plugins, such as the alias or resolve plugin, have been converted to Rust. At the time of writing, using these plugins is not enabled by default, as their behavior may differ from the JavaScript versions.
92+
93+
To test them, you can set the `experimental.enableNativePlugin` option to `true` in your Vite config.
94+
7795
## Reporting Issues
7896

7997
Since this is an experimental integration, you may encounter issues. If you do, please report them in the [`vitejs/rolldown-vite`](https://github.com/vitejs/rolldown-vite) repository, **not the main Vite repository**.
8098

81-
When [reporting issues](https://github.com/vitejs/rolldown-vite/issues/new), please follow the issue template and provide:
99+
When [reporting issues](https://github.com/vitejs/rolldown-vite/issues/new), please follow the appropriate issue template and provide what is requested there, commonly including:
82100

83101
- A minimal reproduction of the issue
84102
- Your environment details (OS, Node version, package manager)
@@ -92,9 +110,34 @@ The `rolldown-vite` package is a temporary solution to gather feedback and stabi
92110

93111
We encourage you to try out `rolldown-vite` and contribute to its development through feedback and issue reports.
94112

113+
In the future, we will also introduce a "Full Bundle Mode" for Vite, which will serve bundled files in production _and development mode_.
114+
115+
### Why introducing a Full Bundle Mode?
116+
117+
Vite is known for its unbundled dev server approach, which is a main reason for Vite's speed and popularity when it was first introduced. This approach was initially an experiment to see just how far we could push the boundaries of development server performance without traditional bundling.
118+
119+
However, as projects scale in size and complexity, two main challenges have emerged:
120+
121+
1. **Development/Production inconsistency**: The unbundled JavaScript served in development versus the bundled production build creates different runtime behaviors. This can lead to issues that only manifest in production, making debugging more difficult.
122+
123+
2. **Performance degradation during development**: The unbundled approach results in each module being fetched separately, which creates a large number of network requests. While this has _no impact in production_, it causes significant overhead during dev server startup and when refreshing the page in development. The impact is especially noticeable in large applications where hundreds or even thousands of separate requests must be processed. These bottlenecks become even more severe when developers use network proxy, resulting in slower refresh times and degraded developer experience.
124+
125+
With the Rolldown integration, we have an opportunity to unify the development and production experiences while maintaining Vite's signature performance. A Full Bundle Mode would allow serving bundled files not only in production but also during development, combining the best of both worlds:
126+
127+
- Fast startup times even for large applications
128+
- Consistent behavior between development and production
129+
- Reduced network overhead on page refreshes
130+
- Maintained efficient HMR on top of ESM output
131+
132+
When the Full Bundle Mode is introduced, it will be an opt-in feature at first. Similar to the Rolldown integration, we are aiming to make it the default after gathering feedback and ensuring stability.
133+
95134
## Plugin / Framework authors guide
96135

97-
### The list of big changes
136+
::: tip
137+
This section is mostly relevant for plugin and framework authors. If you are a user, you can skip this section.
138+
:::
139+
140+
### Overview of Major Changes
98141

99142
- Rolldown is used for build (Rollup was used before)
100143
- Rolldown is used for the optimizer (esbuild was used before)
@@ -104,11 +147,15 @@ We encourage you to try out `rolldown-vite` and contribute to its development th
104147
- Oxc minifier is used for JS minification by default (esbuild was used before)
105148
- Rolldown is used for bundling the config (esbuild was used before)
106149

107-
### Detecting rolldown-vite
150+
### Detecting `rolldown-vite`
108151

109-
You can detect by either
152+
::: warning
153+
In most cases, you don't need to detect whether your plugin runs with `rolldown-vite` or `vite` and you should aim for consistent behavior across both, without conditional branching.
154+
:::
155+
156+
In case you need different behavior with `rolldown-vite`, you have two ways to detect if `rolldown-vite` is used:
110157

111-
- checking the `this.meta.rolldownVersion` existence
158+
Checking the existence of `this.meta.rolldownVersion`:
112159

113160
```js
114161
const plugin = {
@@ -122,7 +169,9 @@ const plugin = {
122169
}
123170
```
124171

125-
- checking the `rolldownVersion` export existence
172+
<br>
173+
174+
Checking the existence of the `rolldownVersion` export:
126175

127176
```js
128177
import * as vite from 'vite'
@@ -138,15 +187,12 @@ If you have `vite` as a dependency (not a peer dependency), the `rolldownVersion
138187

139188
### Ignoring option validation in Rolldown
140189

141-
Rolldown throws an error when unknown or invalid options are passed. Because some options available in Rollup are not supported by Rolldown, you may encounter errors. Below, you can find an an example of such an error message:
142-
143-
> Error: Failed validate input options.
144-
>
145-
> - For the "preserveEntrySignatures". Invalid key: Expected never but received "preserveEntrySignatures".
190+
As [mentioned above](#option-validation-errors), Rolldown throws an error when unknown or invalid options are passed.
146191

147-
This can be fixed by conditionally passing the option by checking whether it's running with `rolldown-vite` as shown above.
192+
This can be fixed by conditionally passing the option by checking whether it's running with `rolldown-vite` as [shown above](#detecting-rolldown-vite).
148193

149-
If you would like to suppress this error for now, you can set the `ROLLDOWN_OPTIONS_VALIDATION=loose` environment variable. However, keep in mind that you will eventually need to stop passing the options not supported by Rolldown.
194+
Suppressing the error by setting the `ROLLDOWN_OPTIONS_VALIDATION=loose` environment variable also works in this case.
195+
However, keep in mind that you will **eventually need to stop passing the options not supported by Rolldown**.
150196

151197
### `transformWithEsbuild` requires `esbuild` to be installed separately
152198

0 commit comments

Comments
 (0)