Chinese internet technology company Bytedance and Valor Software recently open-sourced Rspack, a web bundler written in Rust that aims to be a fast, drop-in replacement for Webpack. Some early benchmarks show a 10x improvement in cold start time.
Bytedance started developing Rspack to slash down production build times that had grown to ten minutes or even half an hour in some cases. Cold start times could also exceed several minutes. To alleviate the cost of migration and keep the flexibility and production optimizations offered by the Webpack configuration mechanism, Rspack was designed to have the following features:
- Fast Startup: Based on Rust, the build speed is extremely fast, bringing you the ultimate development experience.
- ⚡ [Hot Module Reloading (HMR)]: With a built-in incremental compilation mechanism, HMR is extremely fast and fully capable of developing large-scale projects.
- Webpack Interoperable: Compatible with the architecture and ecosystem of webpack, no need to build the ecosystem from scratch.
- Batteries Included: Out-of-the-box support for TypeScript, JSX, CSS, CSS Modules, Sass, and more.
- ️ Production Optimization: Various optimization strategies are built in by default, such as tree shaking, minification, etc.
- Framework-Agnostic: Not bound to any frontend framework, ensuring enough flexibility.
Observed speed improvements will depend on equipment, project structure, and size. Bytedance's benchmarks apply publicly available Webpack benchmarking tools to a custom codebase. Those benchmarks indicate over 10x improvement in development cold start vs. Webpack (with Babel); and 3x improvement in incremental build time. Nx reported similar results on its codebase:
We ran some initial stats also on our end and we saw some cool improvements. For large components, Rspack was about four times faster than the Webpack implementation. The dev server started like five times faster than the current Webpack implementation and we saw some overall four-and-a-half times faster production builds.
While Rspack was only recently open-sourced, it has been developed for already a year. Nonetheless, the project is still in its early stages and lacks many Webpack functionalities. The Rspack team emphasized that they plan to further increase their support of the Webpack ecosystem:
Rspack is compatible with Webpack’s configuration schema and loader architecture. You can seamlessly use familiar loaders such as
babel-loader
,less-loader
,sass-loader
, etc. Our long-term goal is to fully support the most popular loaders including more complex cases such asvue-loader
. There is still a big gap to reach the full capabilities of Webpack. Prioritization will be based on community feedback, so please tell us about your requirements!
Rspack was started by ByteDance’s internal platform development team. Internal developer platforms in particular and platform engineering teams in general are being increasingly used by businesses as part of their DevOps practices.
Rust is increasingly being used by web toolchains to dramatically improve performance. The popular Parcel bundler announced last year a new CSS parser, compiler, and minifier written in Rust (100 times faster than JavaScript-based CSSNano and 3 times faster than Go-based ESBuild). Two years ago, Parcel 2 already featured a Rust rewrite of its JavaScript compiler (with up to 10x build performance improvement). Front-end toolchain Rome released a few months ago a Rust-based linter and formatter with one or two orders of magnitude improvement over ESLint and Prettier. Rolldown is yet another effort in progress offering this time a Rollup-compatible API.
Webpack, Parcel, and Rollup are among the most popular bundlers used to build web applications.
Rspack is open-source software distributed under the MIT license. Feedback is welcome and should follow the contributing guidelines and the code of conduct.