The Rsbuild team worked closely with the Module Federation development team, and provides first-class support for the Module Federation.
Module Federation is an architectural pattern for the decentralization of JavaScript applications (similar to microservices on the server-side). It allows you to share code and resources among multiple JavaScript applications (or micro-frontends). This can help you:
There are currently two main versions of Module Federation, you can choose one to use:
This is a basic version supported by Rspack, providing features such as module export, module loading, dependency sharing.
You can use it through Rsbuild's moduleFederation.options, no need to install any plugins.
This is the enhanced version of Module Federation. It provides additional features based on Module Federation v1.5, such as dynamic type hinting, manifest, federation runtime, runtime plugin system, etc. These features make Module Federation more suitable for supporting micro-front-end architecture of large web applications.
You need to install the additional @module-federation/enhanced
plugin to use Module Federation v2.0.
Please refer to the Module Federation v2.0 documentation for details usage.
Rsbuild has provided some example projects of Module Federation, you can refer to: