网页
综合
更新时间 2026-11-13 15:38:48
Rolldown Integration | Vite
自动蜘蛛
vite.dev
正文约 6000 字
Dependency Pre-Bundling
Static Asset Handling
Building for Production
Deploying a Static Site
Env Variables and Modes
Server-Side Rendering (SSR)
Environment Instances
Vite is planning to integrate Rolldown, a Rust-powered JavaScript bundler, to improve build performance and capabilities.
Rolldown is a modern, high-performance JavaScript bundler written in Rust. It's designed as a drop-in replacement for Rollup, aiming to provide significant performance improvements while maintaining compatibility with the existing ecosystem.
Rolldown focuses on three key principles:
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.
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.
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.
For additional insights on the motivations behind Rolldown, see the reasons why Rolldown is being built.
The rolldown-powered version of Vite is currently available as a separate package called rolldown-vite. If you have vite as a direct dependency, you can alias the vite package to rolldown-vite in your project's package.json, which should result in a drop-in replacement.
Please pin the version!
While these examples use @latest, we recommend using a specific version number to avoid unexpected breaking changes as rolldown-vite is considered experimental.
If you use a Vitepress or a meta framework that has Vite as peer dependency, you have to override the vite dependency in your package.json, which works slightly different depending on your package manager:
After adding these overrides, reinstall your dependencies and start your development server or build your project as usual. No further configuration changes are required.
If you are starting a new project, you can use create-vite as normal for rolldown-vite, too. The latest version will ask you whether to use rolldown-vite or not.
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 which is regularly updated.
Rolldown outputs an warning when unknown or invalid options are passed. Because some options available in Rollup are not supported by Rolldown, you may encounter warnings based on the options you or the meta framework you use set. Below, you can find an example of such an warning message:
Warning validate output options.
If you don't pass the option in yourself, this must be fixed by the utilized framework.
While Rolldown has support for the manualChunks option that is also exposed by Rollup, it is marked deprecated. Instead of it, Rolldown offers a more fine-grained setting via the advancedChunks option, which is more similar to webpack's splitChunk:
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.
Thanks to Rolldown and Oxc, various internal Vite plugins, such as the alias or resolve plugin, have been converted to Rust. Native plugins are now enabled by default, with the default value set to 'v1'.
If you encounter any issues, you can change the experimental.enableNativePlugin option in your Vite config to 'resolver' or false as a workaround. Note that this option will be removed in the future.
@vitejs/plugin-react v5.0.0+ uses Oxc's React refresh transform. If you are not using any Babel plugins (including the React compiler), the full transform would now be done by Oxc and will improve the build performance without any changes other than updating @vitejs/plugin-react.
If you are using @vitejs/plugin-react-swc without SWC plugins and custom SWC options, you can switch to the @vitejs/plugin-react plugin to utilize Oxc.
Previously, we recommended using @vitejs/plugin-react-oxc to utilize Oxc's React refresh transform. However, we have merged the implementation into @vitejs/plugin-react so that it is easier to switch to rolldown-vite. @vitejs/plugin-react-oxc is now deprecated and will no longer be updated.
Plugin authors have the option to use the hook filter feature to reduce the communication overhead between the Rust and JavaScript runtimes. But in case some of the used plugins are not using this feature (yet) but you still want to benefit from it, you can use the withFilter wrapper to wrap the plugin with a filter yourself.
Since this is an experimental integration, you may encounter issues. If you do, please report them in the vitejs/rolldown-vite repository, not the main Vite repository.
When reporting issues, please follow the appropriate issue template and provide what is requested there, commonly including:
For real-time discussions and troubleshooting, make sure to join the Rolldown Discord.
The versioning policy for rolldown-vite aligns its major and minor versions with those of the normal Vite package. This synchronization ensures that features present in a specific normal Vite minor release are also included in the corresponding rolldown-vite minor release. However, it's important to note that patch versions are not synchronized between the two projects. If you're wondering whether a specific change from normal Vite has been included in rolldown-vite, you can always check rolldown-vite's separate changelog for confirmation.
Furthermore, please be aware that rolldown-vite itself is considered experimental. Due to its experimental nature, breaking change
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。