ADR 008: Rsbuild/Rspack as Bundler
Status: Accepted Date: 2025-03-15
Context
We need a bundler for building React (^19.2.4) + TypeScript (^5.9.3) micro frontends with Module Federation v2 support. Build speed is important for developer experience (5-10 MFEs, frequent builds). The bundler must support Module Federation v2's plugin system natively.
Decision
Use Rsbuild (@rsbuild/core@^1.7.3, with @rsbuild/plugin-react@^1.4.1) built on Rspack as the build tool and bundler for all micro frontends and the shell app.
Consequences
Positive
- Rspack is written in Rust: 5-10x faster than webpack for typical React projects
- Native Module Federation v2 support:
@module-federation/enhancedplugin designed for Rspack - Rsbuild provides a higher-level API on top of Rspack (similar to Create React App or Vite, but with Rspack underneath)
- Largely webpack-compatible: can migrate existing webpack configs with minimal changes
- Built-in support for TypeScript, CSS Modules, PostCSS, asset handling
- Hot Module Replacement works well for local development
- Growing ecosystem and active development by ByteDance
- Supports code splitting, tree shaking, and all modern bundler features
Negative
- Newer and less mature than webpack (smaller community, fewer Stack Overflow answers)
- Some webpack plugins may not be compatible (though most popular ones work)
- Rsbuild abstracts Rspack config: occasionally need to drop down to raw Rspack config for advanced use cases
- Documentation is improving but not as comprehensive as webpack's
- Plugin API surface area is smaller than webpack's
Note on Rsbuild 2.0
Rsbuild 2.0 is currently in development, built on top of Rspack 2.0. Key anticipated changes include:
- Rspack 2.0 foundation: Rspack 2.0 aims to improve tree shaking, module concatenation, and overall build performance. Rsbuild 2.0 will inherit these improvements automatically.
- Potential breaking changes: Plugin APIs and configuration schema may change between Rsbuild 1.x and 2.0. Review the migration guide when it becomes available before upgrading.
- Migration path: The Rsbuild team has committed to providing codemods and a migration guide for the 1.x-to-2.0 transition. Monitor the Rsbuild changelog for pre-release announcements.
- Recommendation: Stay on
@rsbuild/core@^1.7.3for production workloads until Rsbuild 2.0 reaches a stable release. Evaluate 2.0 release candidates in a non-critical MFE first before rolling out across all packages.
Alternatives Considered
webpack 5
Battle-tested, huge ecosystem, Module Federation v1 native. But: slow build times (10-30s+ for large MFEs), complex configuration, diminishing community investment as alternatives mature. MF v2 works with webpack but is designed for Rspack.
Vite
Excellent DX, fast dev server (native ESM). But: Module Federation support via @originjs/vite-plugin-federation is community-maintained and less mature. Rollup-based production builds don't natively support MF v2 manifest protocol. Would need significant workarounds.
esbuild
Extremely fast but no native Module Federation support. Would require building MF functionality from scratch. No plugin system comparable to webpack/Rspack.
Turbopack
Next.js-focused, not yet stable for general React projects. No Module Federation support. Tightly coupled to the Next.js ecosystem.