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).
The Rspack team worked closely with the Module Federation development team, and provides first-class support for the Module Federation.
Module Federation has some typical use cases, including:
Module Federation can help you:
There are currently two main versions of Module Federation, you can choose one to use:
This version is natively supported in Rspack. In addition to supporting module export, module loading, and dependency sharing capabilities of Module Federation v1.0, 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.
This is the enhanced version of Module Federation. Based on Module Federation v1.5, it provides some additional features out of the box, such as dynamic type hints and manifest, 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: