Slide 1

Slide 1 text

@ManfredSteyer s Microfrontends mit Angular Ihr 6+1-Punkte-Plan angulararchitects.io ManfredSteyer

Slide 2

Slide 2 text

@ManfredSteyer Do you remember them?

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 Maintainability 10 to 20+ yrs

Slide 6

Slide 6 text

@ManfredSteyer There are milk products lasting longer than some JavaScript frameworks

Slide 7

Slide 7 text

@ManfredSteyer Idea System

Slide 8

Slide 8 text

@ManfredSteyer Idea µService µService µService

Slide 9

Slide 9 text

@ManfredSteyer Idea µFrontends µFrontends µFrontends

Slide 10

Slide 10 text

@ManfredSteyer Contents: 6+1 Steps #1 Composition #2 Routing #3 Compiling #4 Loading #5 Communication #6 Sharing +1: Security

Slide 11

Slide 11 text

@ManfredSteyer About me… Manfred Steyer, ANGULARarchitects.io Angular Trainings and Consultancy Frankfurt, Munich, Vienna In-House: everywhere https://ANGULARarchitects.at/workshops Google Developer Expert for Angular Trusted Collaborator in the Angular Team Manfred Steyer

Slide 12

Slide 12 text

@ManfredSteyer #0: Make sure you need them!

Slide 13

Slide 13 text

@ManfredSteyer Main Reasons for Microfrontends Decoupling b/w teams Autarkic teams Varying technology/ architecture Separate Deployment

Slide 14

Slide 14 text

@ManfredSteyer Prerequisite: Cutting into Sub Domains Flight Management System

Slide 15

Slide 15 text

@ManfredSteyer Booking Check-in Luggage Boarding Prerequisite: Cutting into Sub Domains Sub-Domains

Slide 16

Slide 16 text

@ManfredSteyer #1: Composition

Slide 17

Slide 17 text

@ManfredSteyer Hyperlinks µFrontend SPA µFrontend SPA µFrontend SPA

Slide 18

Slide 18 text

@ManfredSteyer

Slide 19

Slide 19 text

@ManfredSteyer

Slide 20

Slide 20 text

@ManfredSteyer ✓ Simple  Loosing State  Load a new Application

Slide 21

Slide 21 text

@ManfredSteyer µService Providing a (SPA based) Shell µFrontend µFrontend µFrontend Shell ▪ iframes ▪ Serverside Shell? ▪ Bootstrapping several SPAs

Slide 22

Slide 22 text

@ManfredSteyer µService Providing a (SPA based) Shell µFrontend µFrontend µFrontend Shell ✓ Usability  SPA-Frameworks are not intented for this style  We need our own "Meta-Framework"

Slide 23

Slide 23 text

@ManfredSteyer DEMO

Slide 24

Slide 24 text

@ManfredSteyer #2: Routing

Slide 25

Slide 25 text

@ManfredSteyer Routing /client-a/this/that /client-b/this/that /client-c/this/that :

Slide 26

Slide 26 text

@ManfredSteyer Routing /client-a/this/that /client-b/this/that /client-c/this/that :

Slide 27

Slide 27 text

@ManfredSteyer DEMO

Slide 28

Slide 28 text

@ManfredSteyer #3: Compiling

Slide 29

Slide 29 text

@ManfredSteyer DEMO

Slide 30

Slide 30 text

@ManfredSteyer Bundles Microfrontend 1 Microfrontend 2 Libraries: Angular, Bootstrap, … Libraries: Angular, Bootstrap, …

Slide 31

Slide 31 text

@ManfredSteyer Sharing Libs Microfrontend 1 Microfrontend 2 Libraries: Angular, Bootstrap, … UMD Drawbacks: Complexity, no isolation ngx-build-plus

Slide 32

Slide 32 text

@ManfredSteyer DEMO

Slide 33

Slide 33 text

@ManfredSteyer #4: Loading

Slide 34

Slide 34 text

@ManfredSteyer Loading MicroApps

Slide 35

Slide 35 text

@ManfredSteyer Lazy Loading const script = document.createElement('script'); script.src = 'client-a/main.js'; document.body.appendChild(script); const clientA = document.createElement('client-a'); clientA['visible'] = true; document.body.appendChild(clientA);

Slide 36

Slide 36 text

@ManfredSteyer DEMO

Slide 37

Slide 37 text

@ManfredSteyer #5: Communication

Slide 38

Slide 38 text

@ManfredSteyer Communication via Backend µFrontend µFrontend µFrontend Backend HTTP, Web Sockets, SSE, …

Slide 39

Slide 39 text

@ManfredSteyer Communication via URL client-a/this/that?customerId=17 client-b/this/that?customerId=17 client-c/this/that?customerId=17

Slide 40

Slide 40 text

@ManfredSteyer Communication via Service Bus in Shell Service Bus in Shell µFrontend µFrontend µFrontend

Slide 41

Slide 41 text

@ManfredSteyer Communication via Service Bus in Shell self._serviceBus = new Subject<…>(); self._serviceBus.subscribe(…); self._serviceBus.next(myMessage);

Slide 42

Slide 42 text

@ManfredSteyer DEMO

Slide 43

Slide 43 text

@ManfredSteyer #6: Sharing

Slide 44

Slide 44 text

@ManfredSteyer Possibilities Separate Ways VanillaJS Framework Specific Components Web Components

Slide 45

Slide 45 text

@ManfredSteyer Idea First, evaluate whether "Seperate Ways" works Start with framework specific components (easy) Share them via npm or a monorepo Make sure you can expose them as Web Components later (e. g. w/ Angular Elements)

Slide 46

Slide 46 text

@ManfredSteyer DEMO

Slide 47

Slide 47 text

@ManfredSteyer +1: Security

Slide 48

Slide 48 text

@ManfredSteyer Possibilities HTTP-only Cookie • Same origin Token (e. g. JWT) • Request in Shell and share via Service Bus or Session Storage • Consider OAuth 2 and OpenId Connect • Avoid Local Storage • Avoid sharing via URL

Slide 49

Slide 49 text

@ManfredSteyer Blog ANGULARarchitects.io/blog

Slide 50

Slide 50 text

@ManfredSteyer Conclusion Decoupling b/w Teams Domain Cut? No real framework support Hyperlinks? Own Metaframework

Slide 51

Slide 51 text

@ManfredSteyer Be like Murry - think; not strike: Microfrontends are not a silver bullet!

Slide 52

Slide 52 text

@ManfredSteyer Contact and Downloads [web] ANGULARarchitects.io [twitter] ManfredSteyer d Slides & Examples Frankfurt, Munich, Vienna In-House: everywhere http://softwarearchitekt.at/workshops