Stop building Monoliths. Stop building Distributed Monoliths.
Micro-Frontends were supposed to save us. Instead, early implementations (Iframe-based, or build-time npm package aggregation) gave us version mismatches, 10MB bundles (React loaded 5 times), and CSS conflicts.
Micro-Frontends 2.0 changes everything. With Module Federation 2.0 and Rspack, we can share dependencies intelligently at runtime, allowing separate teams to deploy independently while maintaining a cohesive, high-performance application.
02. Module Federation 2.0
Federation allows a JavaScript application to dynamically load code from another application—at runtime.
Unlike npm packages, which are baked in at build time, Federated Modules are "Live." If the Checkout Team deploys a fix to the CartWidget, the Main App gets that fix instantly on the next refresh, without rebuilding.
MFE 1.0 (Iframe Hell)
Complete isolation. Zero sharing. Terrible performance. Hard to deep link. Accessibility nightmares.
MFE 2.0 (Federation)
Runtime imports. Singleton React instance. Shared Context. It feels like a Monolith to the user, but deploys like Microservices to the dev.
name: 'shop_app',
filename: 'remoteEntry.js',
exposes: {
'./CartWidget': './src/components/CartWidget',
},
// SINGLETON: Ensures only one copy of React is loaded
shared: { react: { singleton: true }, 'react-dom': { singleton: true } }
});
03. Compiler Synergy
Most people don't know this: The React Compiler aims for stable references.
When App A imports a Component from App B via Federation, it is technically an "External Component."
The Compiler is smart enough to treat these Federeated Modules as stable dependency roots. If the props passed to the remote component haven't changed, the Host Application will NOT re-render the wrapper, preserving the efficient update cycle even across network boundaries.
06. Federated Component Simulator
Below simulates a "Host Application" loading a "Remote Cart Widget" from a different server URL. Notice how the state (cart count) is maintained inside the remote widget.