close
logologo
Guide
Config
Plugin
API
Community
Version
Changelog
Rsbuild 0.x Doc
English
简体中文
Guide
Config
Plugin
API
Community
Changelog
Rsbuild 0.x Doc
English
简体中文
logologo

Getting Started

Introduction
Quick start
Features
Glossary

Framework

React
Vue
Preact
Svelte
Solid

Basic

CLI
Dev server
Output files
Static assets
HTML
JSON
Wasm
TypeScript
Web Workers
Deploy static site
Upgrade Rsbuild

Configuration

Configure Rspack
Configure Rsbuild
Configure SWC

Styling

CSS
CSS Modules
CSS-in-JS
Tailwind CSS v4
Tailwind CSS v3
UnoCSS

Advanced

Path aliases
Environment variables
Hot module replacement
Browserslist
Browser compatibility
Module Federation
Multi-environment builds
Server-side rendering (SSR)
Testing

Optimization

Code splitting
Bundle size optimization
Improve build performance
Inline static assets

Migration

Migrating from Rsbuild 0.x
webpack
Create React App
Vue CLI
Vite
Vite plugin
Modern.js Builder

Debug

Debug mode
Build profiling
Use Rsdoctor

FAQ

General FAQ
Features FAQ
Exceptions FAQ
HMR FAQ
📝 Edit this page on GitHub
Previous PageBrowser compatibility
Next PageMulti-environment builds

#Module Federation

Module Federation is an architectural pattern for JavaScript application decomposition (similar to microservices on the server-side), allowing you to share code and resources between multiple JavaScript applications (or micro-frontends).

The Rspack team works closely with the Module Federation development team and provides first-class support for Module Federation.

#Use cases

Module Federation has several typical use cases, including:

  • Allowing independent applications (called "micro-frontends" in micro-frontend architecture) to share modules without recompiling the entire application.
  • Enabling different teams to work on different parts of the same application without needing to recompile the entire application.
  • Providing dynamic code loading and sharing between applications at runtime.

Module Federation can help you:

  • Reduce code duplication
  • Improve code maintainability
  • Reduce the overall size of applications
  • Improve application performance

#How to use

Module Federation (MF) currently has multiple major versions, and you can choose one based on your needs.

Here are the characteristics of several versions:

VersionDescriptionFeaturesUse Cases
MF v2.0Enhanced version of Module Federation, implemented based on Module Federation v1.5- Provides additional out-of-the-box features such as dynamic TS type hints, Chrome DevTools, preloading, etc.
- Better suited for micro-frontend architecture supporting large-scale web applications
- Includes all features of Module Federation 1.5
Projects that need to use advanced capabilities of MF 2.0
MF v1.5Version built into Rspack- Supports module export, module loading, dependency sharing capabilities of Module Federation v1.0
- Added runtime plugin functionality, enabling users to extend the behavior and functionality of module federation
Projects that don't need to use the extra capabilities of MF 2.0

#Module Federation v2.0

Module Federation 2.0 provides additional out-of-the-box features based on Module Federation, such as dynamic TS type hints, Chrome devtools, Runtime plugins, and preloading, making Module Federation better suited for micro-frontend architecture supporting large-scale web applications. Module Federation v2.0 is implemented based on v1.5.

You need to install the additional @module-federation/rsbuild-plugin plugin to use Module Federation v2.0.

rsbuild.config.ts
import { pluginModuleFederation } from '@module-federation/rsbuild-plugin';

export default defineConfig({
  plugins: {
    pluginModuleFederation({
      name: 'remote',
     // other options
    }),
  },
});

Please refer to the Module Federation v2.0 official documentation for detailed usage.

#Module Federation v1.5

This is the version built into Rspack. In addition to supporting Module Federation v1.0's capabilities such as module export, module loading, and dependency sharing, it also adds runtime plugin functionality, allowing users to extend the behavior and functionality of module federation.

You can use it through Rsbuild's moduleFederation.options, no need to install any plugins.

rsbuild.config.ts
export default defineConfig({
  moduleFederation: {
    options: {
      name: 'remote',
      // other options
    },
  },
});

#Example repositories

Rsbuild has provided some example projects of Module Federation, you can refer to:

  • Module Federation v2.0 Example
  • Module Federation v1.5 Example