HN
Today

The Rust React Compiler is now native in Vite

The React Compiler, now re-engineered in Rust, is natively integrating with Vite, promising a dramatic acceleration in build times for JavaScript applications. Developers are celebrating this shift away from Babel, embracing a more performant and consistent Rust-powered toolchain. This move highlights a broader trend of Rust permeating the JavaScript ecosystem, leading to faster development cycles and reduced CI costs.

89
Score
17
Comments
#5
Highest Rank
10h
on Front Page
First Seen
Sep 4, 7:00 PM
Last Seen
Sep 5, 4:00 AM
Rank Over Time
57911141620182020

The Lowdown

The article heralds the native integration of the Rust-based React Compiler into Vite, marking a significant performance and consistency upgrade for React developers. It details how this transition simplifies build pipelines and resolves long-standing compatibility issues, making the development experience smoother and more efficient.

  • Official Rust Compiler Support: The oxc-transform-react package now officially supports the Rust React Compiler, paving the way for wider adoption.
  • Vite Integration: @vitejs/plugin-react v6.1.0 offers experimental native React Compiler support via a simple { compiler: true } configuration.
  • Flexible Plugin Option: For users not leveraging @vitejs/plugin-react (e.g., React Router in framework mode), the @acusti/vite-plugin-react-compiler provides an alternative.
  • Stunning Performance Gains: The author observed a 17.6x speedup in the compiler portion of their 1,036-file React Router codebase (14.3s to 0.81s) and an overall build speedup of 2.4x (22.1s to 9.3s).
  • Enhanced Compatibility: The Rust compiler addresses previous limitations, supporting conditional logic in try/catch blocks, reassigning destructured component props in nested closures, and computed object property keys.
  • Toolchain Consistency: This integration ensures the linter and build process utilize the same React Compiler version, eliminating inconsistencies and preventing unoptimized components from reaching production.
  • Simplified Migration: Detailed instructions are provided for migrating existing Vite React builds and React Router framework mode setups, highlighting the removal of cumbersome Babel dependencies.

Ultimately, this shift represents a leap forward for React development, promising a future of faster builds, fewer compilation headaches, and a more robust, consistent toolchain.

The Gossip

Blazing Build Speeds & Babel's Bane

Commenters enthusiastically share their experiences with the new Rust-based React Compiler, confirming the drastic build speed improvements reported in the article. Many express relief and satisfaction at being able to ditch Babel from their compilation pipelines, noting significant reductions in `npm run dev` times and full build durations. This sentiment underscores a widespread frustration with previous JavaScript tooling performance.

Rust's Relentless Reign & the Rewrite Rhetoric

The ongoing phenomenon of 'rewrite it in Rust' is debated. Some ponder what the Rust community will advocate for if most software eventually adopts Rust, while others dismiss it as a meme or a joke. There's also discussion about the deeper motivations for rewriting in Rust, beyond just performance, including secure system design and the language's overall elegance.

Compiler Conundrums & Cross-Framework Compatibility

Users raise practical questions about the new compiler's compatibility and behavior across different frameworks and tools. Queries arise regarding its interaction with various React hooks, and why different frameworks like Next.js might still require Babel plugins despite their internal use of Rust-based tools like SWC. This highlights the complexity of integrating new compilation technology into a diverse ecosystem.