Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Angular-basierte Micro Frontends mit Module Federation @API Summit
Manfred Steyer
PRO
June 20, 2022
Programming
0
150
Angular-basierte Micro Frontends mit Module Federation @API Summit
Manfred Steyer
PRO
June 20, 2022
Tweet
Share
More Decks by Manfred Steyer
See All by Manfred Steyer
More Than Micro Frontends: 3 Further Use Cases for Module Federation @DWX 2022
manfredsteyer
PRO
0
360
Better Angular Architectures: Architectures with Standalone Components @DWX2022
manfredsteyer
PRO
1
390
Angular‘s Future without NgModules: Architectures with Standalone Components @enterJS
manfredsteyer
PRO
0
300
Beyond Micro Frontends: Frontend Moduliths for the Enterprise @enterjs2022
manfredsteyer
PRO
0
350
Beyond Micro Frontends: Frontend Moduliths for the Enterprise @wad2022
manfredsteyer
PRO
0
170
Sustainable SPAs with Strategic Design: A Wonderful Friendship?
manfredsteyer
PRO
0
150
Micro Frontends with Module Federation: Beyond the Basics @codecrafts2022
manfredsteyer
PRO
0
280
Rethinking Auth for SPAs and Micro Frontends: Easy and Secure With Gateways
manfredsteyer
PRO
0
200
Micro Frontends with Module Federation: Beyond the Basics @jax2022
manfredsteyer
PRO
1
370
Other Decks in Programming
See All in Programming
ふんわり理解するcontext
rukiadia
1
180
How to start contributing to Kubernetes Projects
ydfu
0
130
料理の注文メニューの3D化への挑戦
hideg
0
280
動画合成アーキテクチャを実装してみて
satorunooshie
0
540
10歳の minne から、これから長く続くプロダクトを作るすべての人へ
tsumichan
9
3.6k
回帰分析ではlm()ではなくestimatr::lm_robust()を使おう / TokyoR100
dropout009
0
4.5k
Atomic Design とテストの○○な話
takfjp
2
800
OSS貢献を気軽にしたい Let's Go Talk #1
yuyaabo
2
230
FullStack eXchange, July 2022
brucel
0
200
Isar勉強会
hoddy3190
0
400
段階的な技術的負債の解消方法.pdf
ko2ic
2
900
僕が便利だと感じる Snow Monkey の特徴/20220723_Gifu_WordPress_Meetup
oleindesign
0
110
Featured
See All Featured
Intergalactic Javascript Robots from Outer Space
tanoku
260
25k
Debugging Ruby Performance
tmm1
65
10k
Thoughts on Productivity
jonyablonski
44
2.4k
Done Done
chrislema
174
14k
It's Worth the Effort
3n
172
26k
Statistics for Hackers
jakevdp
782
210k
Bootstrapping a Software Product
garrettdimon
296
110k
Web Components: a chance to create the future
zenorocha
303
40k
No one is an island. Learnings from fostering a developers community.
thoeni
9
1.3k
Keith and Marios Guide to Fast Websites
keithpitt
404
21k
WebSockets: Embracing the real-time Web
robhawkes
57
5.5k
Writing Fast Ruby
sferik
612
57k
Transcript
@BASTAcon & @ManfredSteyer Angular-basierte Micro Frontends mit Module Federation
@ManfredSteyer Goal Learn how to build Frontend Moduliths and Micro
Frontends
@ManfredSteyer Contents • Frontend Moduliths • Nx Monorepos • Strategic
Design and DDD • Micro Frontends • Module Federation • Web Components
@ManfredSteyer Manfred Steyer
@ManfredSteyer
@ManfredSteyer Monorepo Structure
@ManfredSteyer Advantages Everyone uses the latest versions No version conflicts
No burden with distributing libs
@ManfredSteyer Two Flavors • Like Workspaces/Solutions in different IDEs Project
Monorepo • E. g. used at Google or Facebook Company-wide Monorepo
@ManfredSteyer Moving back and forth Npm Registry
@ManfredSteyer Tooling & Generator https://nrwl.io/nx Smart, Fast and Extensible Build
System
@ManfredSteyer Visualize Module Structure
@ManfredSteyer Creating a Workspace npm install -g @angular/cli ng new
workspace cd workspace ng generate app my-app ng generate lib my-lib ng serve --project my-app ng build --project my-app
@ManfredSteyer Creating a Workspace npm install -g @angular/cli npm init
nx-workspace workspace cd workspace ng generate app my-app ng generate lib my-lib ng serve --project my-app ng build --project my-app
@ManfredSteyer DEMO
@ManfredSteyer DDD in a nutshell
@ManfredSteyer Methodology for bridging the gap b/w requirements and architecture/
design
@ManfredSteyer
@ManfredSteyer
@ManfredSteyer Domain Driven Design Strategic Design Tactical Design Decomposing a
System Design Patterns & Practices
@ManfredSteyer Domain Driven Design Strategic Design Tactical Design Decomposing a
System Design Patterns & Practices
@ManfredSteyer
@ManfredSteyer Example Flight System
@ManfredSteyer Booking Check-in Boarding Luggage Example Sub-Domains
@ManfredSteyer Booking Boarding Shared Feature Feature Feature Feature Feature UI
UI UI UI UI UI UI UI UI Domain Domain Domain Domain Domain Domain Util Util Util Util Util Util Enterprise Monorepo Patterns, Nrwl 2018: https://tinyurl.com/y2jjxld7 @ManfredSteyer Shared Kernel (if really needed) & other libs Smart Comp. Dumb Comp.
@ManfredSteyer Booking Boarding Shared Feature API Feature Feature Feature Feature
UI UI UI UI UI UI UI UI UI Domain Domain Domain Domain Domain Domain Util Util Util Util Util Util @ManfredSteyer
@ManfredSteyer DEMO
@ManfredSteyer
@ManfredSteyer Finegrained Libraries • Unit of recompilation • Unit of
retesting • Access restrictions • Information Hiding • Easy: Just ng g lib … • Future replacement for NgModules?
@ManfredSteyer Micro Frontends? Short outlook
@ManfredSteyer Booking App Check-in App Boarding App Luggage App Microfrontends
@ManfredSteyer
@ManfredSteyer Booking Boarding Shared Feature Feature Feature Feature Feature …
… … … … … … … … @ManfredSteyer Flight App Deployment Monolith
@ManfredSteyer Booking Boarding Shared Feature Feature Feature Feature Feature …
… … … … … … … … Booking App Boarding App Microfrontends
@ManfredSteyer Booking Boarding Shared Feature Feature Feature Feature Feature …
… … … … … … … … Booking App Boarding App Option 1: One App per Domain Monorepo
@ManfredSteyer Booking Boarding Shared Feature Feature Feature Feature Feature …
… … … … … … … … Booking App Boarding App Option 2: One Monorepo per Domain Publish shared libs seperately via npm Repository n Repository 2 Repository 1
@ManfredSteyer Benefits Autonomous Teams Separate Development Separate Deployment Own architecture
decisions Own technology descisions
@ManfredSteyer Integration via Hyperlinks
@ManfredSteyer UI Composition w/ Hyperlinks µApp SPA µApp SPA µApp
SPA
@ManfredSteyer
@ManfredSteyer
@ManfredSteyer Integration via Shell
@ManfredSteyer µService Providing a (SPA based) Shell µApp µApp µApp
Shell
@ManfredSteyer
@ManfredSteyer Idea const Component = import('http://other-app/xyz') Does not work with
webpack/ Angular CLI Even lazy parts must be known at compile time!
@ManfredSteyer Webpack 5 Module Federation Shell (Host) Microfrontend (Remote) //
Maps Urls in // webpack config remotes: { mfe1: "http://..." } // Expose files in // webpack config exposes: { Cmp: './my.cmp.ts' } import('mfe1/Cmp')
@ManfredSteyer How to Get the Microfrontend's URL? Shell (Host) Microfrontend
(Remote) RemoteEntrypoint.js <script src="…"></script>
@ManfredSteyer How to Share Libs? Shell (Host) Microfrontend (Remote) shared:
[ "@angular/core", "…" ] shared: [ "@angular/core", "…" ]
@ManfredSteyer
@ManfredSteyer Default Behavior Selecting the highest compatible version 10.0 10.1
@ManfredSteyer Default Behavior Conflict: No highest compatible version 11.0 10.1
@ManfredSteyer Configuring Singletons shared: { "my-lib": { singleton: true }
} 11.0 10.1
@ManfredSteyer Configuring Singletons shared: { "my-lib": { singleton: true, strictVersion:
true // Error instead of warning! } } 11.0 10.1
@ManfredSteyer Relaxing Version Requirements shared: { "my-lib": { requiredVersion: ">=1.0.1
<11.1.1" } }
@ManfredSteyer
@ManfredSteyer
@ManfredSteyer 1) npm i @angular-architects/module-federation -D 2) ng g @angular-architects/module-federation:init
3) Adjust generated configuration 4) ng serve
@ManfredSteyer
@ManfredSteyer
@ManfredSteyer Wrap them into Web Components Angular App (MFE) React
App (MFE)
@ManfredSteyer
@ManfredSteyer const Component = await import('other-app/cmp');
@ManfredSteyer const main = await import('other-app/main'); main.bootstrap();
@ManfredSteyer const main = await import('other-app/main'); main.bootstrap(); const rootElm =
document.createElement('app-root') document.body.appendChild(rootElm);
@ManfredSteyer await import('other-app/main'); // Self-Bootstrapping const rootElm = document.createElement('app-root') document.body.appendChild(rootElm);
@ManfredSteyer await import('other-app/main'); const rootElm = document.createElement('app-root') document.body.appendChild(rootElm); WrapperComponent
@ManfredSteyer
@ManfredSteyer https://red-ocean-0fe4c4610.azurestaticapps.net
@ManfredSteyer Challanges • Bundle Size • Multiple Routers • Bootstrapping
Several Angular Instances • Share Platform-Object when same version is reused • Share ngZone
@ManfredSteyer
@ManfredSteyer DEMO
@ManfredSteyer Choosing a Solution
@ManfredSteyer Some General Advice Shared state, navigation b/w apps Hyperlinks
Legacy Apps or *very very* strong isolation? iframes Separate Deployment/ mix Technologies? Load Bundles on Demand Monolith little much yes no yes no Module Federation