Modern enterprise applications are growing in size and complexity. As teams scale and features evolve independently, a single monolithic frontend becomes difficult to maintain and deploy.
Micro Frontends (MFEs) offer a scalable solution by breaking large applications into smaller, independently deployable units each owned by separate teams.
With Webpack 5 Module Federation, Angular now provides a native and efficient way to implement Micro Frontends without complex runtime integrations.
This article explains how Module Federation works in Angular, its benefits, and a step-by-step implementation guide for integrating multiple micro frontends within a single shell application.
1. Understanding Micro Frontends
A Micro Frontend Architecture divides a large web application into multiple independent applications — or micro apps — that can:
Be developed and deployed separately
Use different versions of Angular or other frameworks
Communicate seamlessly within a unified user experience
Each micro frontend (MFE) handles a specific domain, such as:
ordersinventorycustomers
These are then composed dynamically by a Shell (Host) application.
2. What is Module Federation?
Module Federation (introduced in Webpack 5) allows multiple applications to share code and load remote modules dynamically at runtime.
Key Concepts
Host – The main application that loads other micro frontends.
Remote – A standalone micro frontend that exposes certain modules/components.
Shared Libraries – Dependencies (like Angular, RxJS, or common UI libraries) that can be shared between host and remotes to prevent duplication.
3. Setting Up the Environment
Prerequisites
Node.js (>= 18)
Angular CLI (>= 17)
Webpack 5 (comes by default with Angular 12+)
@angular-architects/module-federationplugin
Step 1: Install the Module Federation Plugin
npm install @angular-architects/module-federation --save-dev
4. Creating the Applications
Step 2: Generate the Shell and Micro Frontends
ng new mfe-shell --routing --style=scss
ng new mfe-orders --routing --style=scss
ng new mfe-inventory --routing --style=scss
Each app runs independently at first.
5. Configuring Module Federation
Step 3: Configure the Host (Shell)
Navigate to the shell app and run:
ng add @angular-architects/module-federation --project mfe-shell --type host
This creates a webpack.config.js with placeholders to load remote apps.
Example configuration:
// mfe-shell/webpack.config.js
const { ModuleFederationPlugin } = require('webpack').container;
const mf = require('@angular-architects/module-federation/webpack');
module.exports = {
output: {
uniqueName: "mfeShell",
publicPath: "auto",
},
plugins: [
new ModuleFederationPlugin({
remotes: {
"mfeOrders": "mfeOrders@http://localhost:4201/remoteEntry.js",
"mfeInventory": "mfeInventory@http://localhost:4202/remoteEntry.js",
},
shared: mf.share({
"@angular/core": { singleton: true, strictVersion: true },
"@angular/common": { singleton: true, strictVersion: true },
"@angular/router": { singleton: true, strictVersion: true },
}),
}),
],
};

Join the conversation! Your thoughts help the community grow.