You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guide/rolldown.md
+60-14Lines changed: 60 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,14 +10,16 @@ Rolldown focuses on three key principles:
10
10
11
11
-**Speed**: Built with Rust for maximum performance
12
12
-**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
14
14
15
15
## Why Vite is Migrating to Rolldown
16
16
17
17
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.
18
18
19
19
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.
20
20
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
+
21
23
For additional insights on the motivations behind Rolldown, see the [reasons why Rolldown is being built](https://rolldown.rs/guide/#why-rolldown).
22
24
23
25
## Benefits of Trying `rolldown-vite`
@@ -74,11 +76,27 @@ After adding these overrides, reinstall your dependencies and start your develop
74
76
75
77
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.
76
78
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
+
77
95
## Reporting Issues
78
96
79
97
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**.
80
98
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:
82
100
83
101
- A minimal reproduction of the issue
84
102
- 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
92
110
93
111
We encourage you to try out `rolldown-vite` and contribute to its development through feedback and issue reports.
94
112
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
+
95
134
## Plugin / Framework authors guide
96
135
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
98
141
99
142
- Rolldown is used for build (Rollup was used before)
100
143
- 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
104
147
- Oxc minifier is used for JS minification by default (esbuild was used before)
105
148
- Rolldown is used for bundling the config (esbuild was used before)
106
149
107
-
### Detecting rolldown-vite
150
+
### Detecting `rolldown-vite`
108
151
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:
110
157
111
-
- checking the `this.meta.rolldownVersion` existence
158
+
Checking the existence of `this.meta.rolldownVersion`:
112
159
113
160
```js
114
161
constplugin= {
@@ -122,7 +169,9 @@ const plugin = {
122
169
}
123
170
```
124
171
125
-
- checking the `rolldownVersion` export existence
172
+
<br>
173
+
174
+
Checking the existence of the `rolldownVersion` export:
126
175
127
176
```js
128
177
import*asvitefrom'vite'
@@ -138,15 +187,12 @@ If you have `vite` as a dependency (not a peer dependency), the `rolldownVersion
138
187
139
188
### Ignoring option validation in Rolldown
140
189
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.
146
191
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).
148
193
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**.
150
196
151
197
### `transformWithEsbuild` requires `esbuild` to be installed separately
0 commit comments