Middle
Tell me, what is Module Federation and what does it include?
sobes.tech AI
Answer from AI
Module Federation is a technology introduced in Webpack 5 that allows multiple independent frontend applications (microfrontends) to dynamically load and use modules from each other at runtime.
Key features and components of Module Federation:
- Dynamic import of modules from other builds without the need for prior integration.
- Shared dependencies — prevents duplication of libraries, such as React, across applications.
- Isolation and independence of builds — each application can be developed and deployed separately.
Includes:
- Host — the application that loads modules from other applications.
- Remote — the application that provides its modules for use by others.
Example configuration in Webpack:
new ModuleFederationPlugin({
name: 'app1',
remotes: {
app2: 'app2@http://localhost:3002/remoteEntry.js',
},
shared: ['react', 'react-dom'],
})
Thus, Module Federation facilitates the creation of scalable microfrontend architectures with shared code and dependencies.