Rspack 2.1 Boosts Build Speed Up to 13× with Rust‑Based React Compiler

Rspack 2.1 has been released, delivering a Rust‑implemented React Compiler that runs 7‑13× faster than the previous Babel version, overall production builds that are about 16% quicker, HMR improvements of roughly 5%, and a host of new features such as import.meta.glob support, createRequire parsing, magic comments, source‑phase imports, automatic cache cleanup, plus ecosystem updates for TanStack RSC, Rsbuild, Rslib, Rstest, Rslint, Rspress, Rsdoctor and rspack‑merge.

ByteDance Web Infra
ByteDance Web Infra
ByteDance Web Infra
Rspack 2.1 Boosts Build Speed Up to 13× with Rust‑Based React Compiler

Performance Boosts

React Compiler (Rust) replaces the Babel‑based implementation and achieves a 7‑13× speed increase. In our benchmark:

rspack dev: 0.7 s vs 10.6 s (13.5× faster)

rspack build: 1.2 s vs 9.3 s (7.4× faster)

Enable it via the built‑in SWC loader:

export default {
  module: {
    rules: [{
      test: /\.(?:js|jsx|ts|tsx)$/,
      use: {
        loader: 'builtin:swc-loader',
        options: {
          jsc: { transform: { react: { runtime: 'automatic' } },
          reactCompiler: true,
        },
      },
    }],
  },
};

See the Rspack React Compiler guide for full configuration.

General Build Performance

Rspack 2.1 improves the core build pipeline, delivering roughly a 16% reduction in production build time and about a 5% gain in HMR speed compared with Rspack 2.0.

Rspack 1.7.11 – prod 3.12 s, cache 2.09 s, HMR 129 ms Rspack 2.0.0 – prod 2.66 s, cache 1.36 s, HMR 113 ms Rspack 2.1.0 – prod 2.22 s, cache 1.20 s, HMR

107 ms

TypeScript 7 Support

The ts-checker-rspack-plugin now works with TypeScript 7 (TypeScript Go). Enabling it cuts overall type‑checking time by about 60%.

pnpm add typescript@rc -D
import { TsCheckerRspackPlugin } from 'ts-checker-rspack-plugin';
export default {
  plugins: [new TsCheckerRspackPlugin()],
};

Faster Circular‑Dependency Checks

Rspack 2.1 introduces CircularCheckRspackPlugin, replacing the older CircularDependencyRspackPlugin. The new plugin uses a graph‑based algorithm that avoids repeated traversals, resulting in lower detection overhead on large projects. Its API aligns with the familiar webpack circular-dependency-plugin syntax.

To migrate, replace the old plugin with the new one and optionally use ignoreWarnings to silence specific warnings.

New Features

import.meta.glob Support

Rspack now supports import.meta.glob, allowing developers to collect modules by glob pattern and load them on demand:

const pages = import.meta.glob('./pages/**/*.js');
for (const path in pages) {
  const mod = await pages[path]('path');
}

Improved Built‑in CSS Handling

The built‑in CSS engine adds the css/global module type, enabling CSS Modules to work in a “default‑global, on‑demand :local ” mode alongside css/module and css/auto. Additional CSS syntax and behavior are now supported via module.generator and module.parser options.

createRequire Parsing

ESM now recognizes module.createRequire() and treats the resulting require as a statically analyzable dependency. Enable it with module.parser.javascript.createRequire: true:

export default {
  module: {
    parser: { javascript: { createRequire: true } },
  },
};

The option also supports multiple import forms, custom specifiers, and requires static‑analyzable arguments such as import.meta.url or absolute file URLs.

Magic Comments with rspack Prefix

Rspack adds a rspack prefix for magic comments while retaining compatibility with existing webpack prefixes:

import(/* rspackChunkName: "dashboard" */ './dashboard');

Source Phase Imports

Enabling experiments.sourceImport: true allows static or dynamic import of WebAssembly modules as .wasm files, returning a compiled WebAssembly.Module that can be instantiated later, reducing repeated compilation costs.

import source wasmModule from './module.wasm';
const instance = await WebAssembly.instantiate(wasmModule, {/* imports */});

Additionally, module.rules[].phase lets you match rules based on the import phase (e.g., evaluation, import defer, source).

Automatic Persistent‑Cache Cleanup

Rspack now automatically removes stale cache versions using cache.maxAge (default 7 days) and cache.maxVersions (default 3). Setting either to Infinity disables the corresponding cleanup.

export default {
  cache: {
    type: 'persistent',
    maxAge: 7 * 24 * 60 * 60,
    maxVersions: 3,
  },
};

Product Optimizations

pureFunctions Stabilization

The experimental pureFunctions flag is now enabled by default in production mode, allowing tree‑shaking of calls to functions annotated with /*#__NO_SIDE_EFFECTS__*/ or configured via module.parser.javascript.pureFunctions. Disable it with experiments.pureFunctions: false if needed.

Branch‑Aware Dependency Pruning

When a boolean constant is inlined, Rspack now associates the condition with its branch’s imports. Unused branch dependencies are marked inactive and removed, reducing dead code in the final bundle.

Export‑Const Value‑Binding Optimization

For non‑cyclic modules, Rspack emits const exports as read‑only values instead of getter functions, cutting runtime overhead. Cyclic or mutable exports still use getters to preserve semantics.

Ecosystem Updates

TanStack RSC Support : TanStack Start now works with Rsbuild, exposing RSC capabilities.

Rsbuild 2.1 released alongside Rspack 2.1 (see the Rsbuild blog).

Rslib : Enables fast isolated declaration generation ( dts.isolated: true), cutting type‑declaration generation time to 2.3 s compared with 9.7 s for TypeScript 6.

Rstest 0.10 : Adds --changed / --related test filtering, worker‑thread pool, persistent cache, memory‑aware scheduling, silent‑pass output, and a --trace performance analysis flag.

Rslint : Ships with over 400 built‑in rules (ESLint core, @typescript-eslint, react, jsx‑a11y, jest, promise, etc.) and can run community ESLint plugins with full --fix support.

Rspress : New AI‑powered skills such as rspress-docs-generator and rspress-custom-theme for rapid documentation site creation.

Rsdoctor : Adds AI analysis in GitHub Actions to pinpoint build size regressions and performance bottlenecks.

rspack‑merge : A lightweight npm package for merging Rspack configurations, supporting rule‑level merges with zero runtime dependencies.

References

React Compiler: https://react.dev/learn/react-compiler/introduction

React Compiler Rust port: https://github.com/facebook/react/pull/36173

Rspack React Compiler guide: http://rspack.rs/zh/guide/tech/react#react-compiler

Benchmark data: https://github.com/LingyuCoder/rspack-react-10k-benchmark

ts‑checker‑rspack‑plugin: https://github.com/rstackjs/ts-checker-rspack-plugin

CircularCheckRspackPlugin: http://rspack.rs/zh/plugins/rspack/circular-check-rspack-plugin

import.meta.glob docs: http://rspack.rs/zh/api/runtime-api/module-variables#importmetaglob

module.createRequire: https://nodejs.org/api/module.html#modulecreaterequirefilename

magic comments: http://rspack.rs/zh/api/runtime-api/module-methods#magic-comments

Source Phase Imports proposal: https://github.com/tc39/proposal-source-phase-imports

Cache options: http://rspack.rs/zh/config/cache#maxage, #maxversions

pureFunctions: http://rspack.rs/zh/config/experiments#experimentspurefunctions

Rslib isolated declarations: https://rslib.rs/zh/config/lib/dts#dtsisolated

Rstest blog: https://rstest.rs/zh/blog/announcing-0-10

Rslint rules: https://rslint.rs/rules/

rspack‑merge repo: https://github.com/rstackjs/rspack-merge

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

RustRspackbuild performanceReact Compilerfrontend bundlerimport.meta.glob
ByteDance Web Infra
Written by

ByteDance Web Infra

ByteDance Web Infra team, focused on delivering excellent technical solutions, building an open tech ecosystem, and advancing front-end technology within the company and the industry | The best way to predict the future is to create it

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.