Middle+
What features are there when working with micro frontends on Module Federation?
sobes.tech AI
Answer from AI
Module Federation is a Webpack 5 technology that allows micro-frontends to dynamically load and share modules with each other at runtime.
Features of working with micro-frontends on Module Federation:
- Dynamic loading: Modules from other applications are loaded on demand, reducing the size of the initial bundle.
- Shared runtime: Allows multiple micro-frontends to share dependencies (e.g., React), avoiding duplication.
- Versioning and compatibility: Careful management of shared library versions is necessary to prevent conflicts.
- Isolation: Each micro-frontend can have its own technology stack but interact through shared interfaces.
- Configuration: Requires setting up
ModuleFederationPluginin Webpack with specified exposed and consumed modules.
Example configuration:
new ModuleFederationPlugin({
name: 'app1',
filename: 'remoteEntry.js',
exposes: {
'./Button': './src/Button',
},
remotes: {
app2: 'app2@http://localhost:3002/remoteEntry.js',
},
shared: ['react', 'react-dom'],
})
- Problems: Need to consider style loading, state management, and routing between micro-frontends.
Ultimately, Module Federation enables the creation of scalable and independent micro-frontends with the ability to share code and dependencies.