Slide 1

Slide 1 text

@ManfredSteyer ManfredSteyer The Microfrontend Revolution Module Federation with Angular Manfred Steyer, ANGULARarchitects.io

Slide 2

Slide 2 text

@ManfredSteyer Do you remember her? Bonnie Barstow, PhD

Slide 3

Slide 3 text

@ManfredSteyer Software Engineering is a Team Sport

Slide 4

Slide 4 text

@ManfredSteyer Coordination b/w Teams

Slide 5

Slide 5 text

@ManfredSteyer Monolith Flight System

Slide 6

Slide 6 text

@ManfredSteyer Booking Service Check-in Service Boarding Service Luggage Service Microservices Sub-Domains (DDD)

Slide 7

Slide 7 text

@ManfredSteyer Booking App Check-in App Boarding App Luggage App Microfrontends

Slide 8

Slide 8 text

@ManfredSteyer

Slide 9

Slide 9 text

@ManfredSteyer

Slide 10

Slide 10 text

@ManfredSteyer Contents #1: Consequences of Microfrontends #2: Module Federation #3: Dynamic Module Federation #4: Version Mismatch #5: Possible Roadmap

Slide 11

Slide 11 text

@ManfredSteyer Manfred Steyer

Slide 12

Slide 12 text

@ManfredSteyer

Slide 13

Slide 13 text

@ManfredSteyer Booking App Check-in App Boarding App Luggage App Autonomous Teams

Slide 14

Slide 14 text

@ManfredSteyer Autonomous Teams Separate Development Separate Deployment Own architecture decisions Own technology descisions

Slide 15

Slide 15 text

@ManfredSteyer

Slide 16

Slide 16 text

@ManfredSteyer

Slide 17

Slide 17 text

@ManfredSteyer Challenges UI Composition UI Consistency Bundle Size/ Sharing Dependencies Version Conflicts between Microfrontends …

Slide 18

Slide 18 text

@ManfredSteyer Module Federation Solves Some of Them! UI Composition UI Consistency Bundle Size/ Sharing Dependencies Version Conflicts between Microfrontends …

Slide 19

Slide 19 text

@ManfredSteyer

Slide 20

Slide 20 text

@ManfredSteyer

Slide 21

Slide 21 text

@ManfredSteyer

Slide 22

Slide 22 text

@ManfredSteyer Idea const Component = await import('http://other-app/xyz') Does not work with webpack/ Angular CLI Even lazy parts must be known at compile time!

Slide 23

Slide 23 text

@ManfredSteyer Webpack 5 Module Federation Shell (Host) Microfrontend (Remote) // Maps Urls in // webpack config remotes: { mfe1: "mfe1" } // Expose files in // webpack config exposes: { Cmp: './my.cmp.ts' } import('mfe1/Cmp')

Slide 24

Slide 24 text

@ManfredSteyer How to Get the Microfrontend's URL? Shell (Host) Microfrontend (Remote) RemoteEntrypoint.js

Slide 25

Slide 25 text

@ManfredSteyer How to Share Libs? Shell (Host) Microfrontend (Remote) shared: [ "@angular/core", "…" ] shared: [ "@angular/core", "…" ]

Slide 26

Slide 26 text

@ManfredSteyer

Slide 27

Slide 27 text

@ManfredSteyer

Slide 28

Slide 28 text

@ManfredSteyer Dynamic Module Federation Shell (Host) Microfrontend (Remote) remotes: { mfe1: "mfe1" } exposes: { Cmp: './my.cmp.ts' } import('mfe1/Cmp')

Slide 29

Slide 29 text

@ManfredSteyer Dynamic Module Federation Shell (Host) Microfrontend (Remote) remotes: { } exposes: { Cmp: './my.cmp.ts' } import('mfe1/Cmp')

Slide 30

Slide 30 text

@ManfredSteyer Dynamic Module Federation Shell (Host) Microfrontend (Remote) remotes: { } exposes: { Cmp: './my.cmp.ts' } loadRemoteModule({ remoteEntry: 'http://…', remoteName: 'mfe1', exposedModule: './Cmp' })

Slide 31

Slide 31 text

@ManfredSteyer Dynamic Module Federation Shell (Host) Microfrontend (Remote) remotes: { } exposes: { Cmp: './my.cmp.ts' } loadRemoteModule({ remoteEntry: 'http://…', remoteName: 'mfe1', exposedModule: './Cmp' }) Helper Function using the Webpack API

Slide 32

Slide 32 text

@ManfredSteyer

Slide 33

Slide 33 text

@ManfredSteyer

Slide 34

Slide 34 text

@ManfredSteyer Dealing with Version Mismatch SemVer by Default: Highest compatiable version Fallback: Use own version Relaxing: Configure a range of accepted versions Singleton: Warning or error

Slide 35

Slide 35 text

@ManfredSteyer Configuring Singletons shared: { "my-lib": { singleton: true, strictVersion: true // Error instead of warning! } }

Slide 36

Slide 36 text

@ManfredSteyer Relaxing Version Requirements shared: { "my-lib": { requiredVersion: ">=1.0.1 <11.1.1" } }

Slide 37

Slide 37 text

@ManfredSteyer

Slide 38

Slide 38 text

@ManfredSteyer Well … Webpack 5 is currently beta Shown examples: PoC w/ custom webpack conf + patched CLI lib CLI: Not before version 11 (fall 2020) Squeeze federation config into CLI's webpack config Custom Builder (e. g. ngx-build-plus)

Slide 39

Slide 39 text

@ManfredSteyer Free eBook ANGULARarchitects.io/book Updated for Module Federation and Alternatives

Slide 40

Slide 40 text

@ManfredSteyer Conclusion Main Purpose of µFrontends: Scaling Teams Decoupling Federation: Import From Other App Sharing Libs Take Care of Conflicts

Slide 41

Slide 41 text

@ManfredSteyer Be like Bonnie and think first! Evaluate whether you need µFrontends No: Majestic Monolith Yes: Consider Module Federation

Slide 42

Slide 42 text

@ManfredSteyer d Slides & Examples Remote Company Workshops and Consulting http://angulararchitects.io