Hi, I am Trishul
🤖
👨💻
@trishulgoel
Monolithic application is designed to be self-contained; components of the program are interconnected and interdependent
All the code in a single place
Increased inter-team dependency
Slow development to deploy cycle
Increasing size of repo everyday
Standalone system
Independent Repository
Independent CI Pipelines
Independent Deployments
Remote 1
HOST
Remote 2
Remote 3
HEADER
FOOTER
Home Page
Product Listing
Page
Product Details
Page
Payments
and
Checkout
Cart
MicroFrontend
Appshell / Host
Shared business Logic
Login
Tracking
System config
Routing
Same tech stack
Share as params
Different tech stack
Custom DOM events
Node modules
IFrames
Remote 1
Remote 2
Remote 3
HOST
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-shared-component',
templateUrl: './sharedModule.component.html',
styleUrls: ['./sharedModule.component.css']
})
export class SharedComponent implements OnInit {
constructor() {}
ngOnInit(): void {}
}
new ModuleFederationPlugin({
name: "remote",
filename: "remoteEntry.js",
exposes: {
'./SharedModule': './src/app/shared/sharedModule.component.ts',
},
shared: {
"@angular/core": { singleton: true, strictVersion: true },
"@angular/common": { singleton: true, strictVersion: true },
"@angular/router": { singleton: true, strictVersion: true },
}
}),
new ModuleFederationPlugin({
remotes: {
"remote": "remote@http://localhost:4300/remoteEntry.js",
},
shared: {
"@angular/core": { singleton: true, strictVersion: true },
"@angular/common": { singleton: true, strictVersion: true },
"@angular/router": { singleton: true, strictVersion: true },
}
}),
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { SharedComponent } from 'remote/SharedModule';
const routes: Routes = [
{
path: 'remote',
component: SharedComponent,
data: { from: ' Host' }
},
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
Templating engine
Tenpureto
Moving components to design system
Sharing logic between Micro Frontends
Building an efficient developer experience
Decoupling code from Appshell
@trishulgoel
https://webpack.js.org/concepts/module-federation/
https://github.com/module-federation/module-federation-examples