BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Rolldown, a Rollup-Compatible Rust-Based Bundler for JavaScript, is Now Open -Sourced

Rolldown, a Rollup-Compatible Rust-Based Bundler for JavaScript, is Now Open -Sourced

Rolldown is a new JavaScript bundler written in Rust for performance. Rolldown intends to be compatible with Rollup’s APIs and plugins. The Rolldown project is led by Evan You (creator of the Vue web framework) and is intended to become Vite’s next bundler.

JavaScript is increasingly being used for serious, large applications. In order to provide better developer experience across the development lifecycle, Rust-based JavaScript toolchains (e.g., linter, parser, builder) have, in recent years, taken a significant part of the landscape. The goal is to provide fast iteration cycles to developers even across large codebases.

Justin Schroeder explains the motivation behind Rolldown as follows:

It didn’t take long for Vite to become the standard development and build environment for nearly every major meta-framework: @nuxt_js, @solid_js start, @sveltejs kit, @remix_run, @angular CLI, etc. (basically everything except Next). Rollup is still the underpinning of all of these. […] We find ourselves in a world where Rollup['s] performance could be improved. esbuild ( @evanwallace), a bundler written in Go, showed the world just how much faster a “native” bundler can be, but esbuild was not Rollup-compatible and had its fair share of shortcomings as well (no TypeScript, limited tree shaking, etc.).

Rolldown, which self-describes as a fast Rust-based bundler for JavaScript with a Rollup-compatible API, seeks to provide faster build times while still leveraging as much as possible the existing Rollup ecosystem. According to the Rolldown team, Rolldown is designed to serve as the future lower-level bundler used in Vite. Vite users should be able to transition to a Vite version that uses Rolldown internally with minimal friction. Rolldown will also be directly usable as a standalone bundler.

The Rolldown team explained that the expected speed improvements do not simply come from Rust code compiling to native binaries. First, writing the entire tool in Rust rather than incrementally improving Rollup with extra Rust-based modules is an important design choice:

The performance gain from partially moving components to Rust is often significantly offset by the cost of passing data between Rust and JavaScript, as shown in Rollup 4’s adoption of the Rust-based SWC parser.

Second, Rust makes it easier to write code that can run safely in parallel on multi-core devices:

To achieve optimal performance, the entire parse/transform/codegen pipeline needs to happen on the native side and be parallelized as much as possible.

Third, Rolldown will strive to use a single parse and AST tree. Vite sometimes parses the same TypeScript file 5 times at various levels in the stack, with the corresponding parsing/serialization overhead.

Performance improvements thus result from a mix of native code, parallel execution, and smarter algorithms.

One Reddit user celebrated that Rust is increasingly being used as a go-to language for fast toolchains:

This is an interesting case of critical mass. A few years ago Rust was a pretty suboptimal language to start JavaScript tooling in (or Python for that matter). Some crazy folks however did not care, and just went for it. As time went on, that base level of investment into tooling all of a sudden meant that there was so much to leverage, that it went from an obscure language choice to a pretty reasonable one.

Rolldown is the latest member of a line of Rust-based toolchains. Rspack is a Webpack-compatible web bundler. esbuild is yet another fast bundler for the web. Biome tackles formatting and linting JavaScript codebases. The SWC compiler and bundler self-describes as a Rust-based platform for the Web. Oxc gathers a parser, linter, resolver, formatter, minifier, and more.

Rolldown is still in the early stages. The Rolldown team is actively looking for long-term contributors. Candidate contributors can review the contributing guidelines and the project’s code of conduct. Rolldown is now an open-source project under the MIT license.

About the Author

Rate this Article

Adoption
Style

BT