跪拜 Guibai
← All articles
Frontend

Rspack 2.1 Ships Rust-Powered React Compiler: Up to 13x Faster Than Babel

By WebInfra ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Rspack is pushing the Rust-in-JS-build-tools thesis hard, and 2.1 shows it's not just about raw speed — it's about matching or exceeding the ergonomics of Babel and webpack while being an order of magnitude faster. For any team hitting build-time walls on large React projects, the Rust React Compiler alone is a compelling reason to evaluate Rspack. The broader ecosystem play — Rslint, Rstest, Rslib — signals a bet that the entire frontend toolchain can be Rust-native, not just the bundler.

Summary

Rspack 2.1 is out, and the headline number is a Rust-native React Compiler that benchmarks 7-13x faster than the Babel-based approach. The `rspack dev` command drops from 10.6 seconds to 0.7 seconds in tests. This isn't just a port — it's a direct integration via the built-in SWC loader, meaning no extra Babel pass is needed.

Beyond the React Compiler, Rspack 2.1 ships general build performance improvements of about 16% over 2.0, and HMR is about 5% faster. TypeScript 7 (the Go port) is now supported via `ts-checker-rspack-plugin`, cutting type-checking time by roughly 60%. A new circular dependency plugin uses a smarter graph algorithm to avoid redundant traversals in large module graphs.

The release also introduces branch-aware dependency pruning and ESM export existence detection — Rspack can now statically inline boolean constants and prune entire branches of dynamic imports. The `pureFunctions` optimization, previously experimental, is now on by default in production. And `export const` in non-circular modules gets a lighter value binding that skips getter overhead.

On the ecosystem side, Rspack 2.1 adds `import.meta.glob` support (matching Vite and Turbopack), source phase imports for WebAssembly, and automatic persistent cache cleanup. The broader Rust toolchain — Rslint (400+ built-in rules, ESLint plugin compatibility), Rstest (test runner with `--changed`/`--related` filtering), Rslib (fast isolated declarations), and Rsdoctor (AI-assisted CI analysis) — continues to mature.

Takeaways
— Rust-native React Compiler via built-in SWC loader benchmarks 7-13x faster than Babel-based approach.
— General production build performance improved ~16% over Rspack 2.0; HMR improved ~5%.
— TypeScript 7 (Go port) support via ts-checker-rspack-plugin cuts type-checking time ~60%.
— New CircularCheckRspackPlugin uses a graph algorithm for faster cycle detection in large projects.
— Branch-aware dependency pruning: Rspack can inline boolean constants and prune entire dynamic import branches.
— pureFunctions optimization is now enabled by default in production mode.
— export const in non-circular modules uses a lighter value binding that skips getter overhead.
— import.meta.glob support added, matching Vite and Turbopack syntax.
— Source phase imports for WebAssembly allow manual control over Wasm instantiation.
— Automatic persistent cache cleanup via maxAge (default 7 days) and maxVersions (default 3).
— Rslint now has 400+ built-in rules and can run community ESLint plugins directly.
— Rstest 0.10 adds --changed/--related test filtering and memory-aware worker scheduling.
— Rslib adds fast isolated declarations using SWC, 4x faster than TypeScript 6.
— TanStack Start officially supports Rsbuild for RSC-based applications.
Conclusions

The 13x speedup on `rspack dev` with the Rust React Compiler is the kind of number that makes teams reconsider their entire build toolchain — a 10-second cold start dropping to under a second changes workflow habits.

Branch-aware dependency pruning is a genuinely novel optimization: most bundlers can tree-shake unused exports, but pruning entire dynamic import branches based on inlined constants is a step toward compile-time dead code elimination that feels more like a native compiler.

The decision to keep webpack-prefixed magic comments alongside the new rspack prefix shows Rspack is serious about gradual migration, not forcing a break.

Rslint's ability to run ESLint plugins directly is a pragmatic hedge — it acknowledges that no Rust-native linter can match ESLint's plugin ecosystem overnight, so compatibility buys time.

The Rspack ecosystem (Rslib, Rstest, Rslint, Rsdoctor) is becoming a coherent Rust-native frontend toolchain, not just a bundler. This is a bet that developers will prefer a unified Rust stack over mixing tools with different runtimes.

Automatic cache cleanup with defaults of 7 days and 3 versions is a small but thoughtful quality-of-life fix — anyone who has had a node_modules/.cache directory balloon to gigabytes will appreciate it.

Concepts & terms
React Compiler
A build-time tool from the React team that automatically adds memoization (useMemo, useCallback, React.memo) to components and hooks, reducing manual optimization work.
SWC (Speedy Web Compiler)
A Rust-based platform for compiling and bundling JavaScript/TypeScript, often used as a faster alternative to Babel.
Tree Shaking
A build optimization that removes unused code (dead code) from the final bundle, reducing file size.
Branch-Aware Dependency Pruning
A technique where the bundler statically evaluates conditional branches (e.g., if statements) and removes dependencies from branches that are determined to be unreachable at compile time.
Source Phase Imports
A TC39 proposal for importing WebAssembly modules as compiled WebAssembly.Module objects rather than automatically instantiating them, giving developers control over instantiation.
Isolated Declarations
A TypeScript feature that allows generating declaration files (.d.ts) without full type checking, by analyzing each file in isolation. This is much faster than traditional declaration generation.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗