Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Angular and Micro Apps: Maintainable Client Architectures @IJS in Munich, October 2018

Angular and Micro Apps: Maintainable Client Architectures @IJS in Munich, October 2018

Contains:
- npm Packages
- Monorepo
- Micro Apps w/ Hyperlinks
- Micro Apps w/ Shell

# Library Example
https://github.com/manfredsteyer/logger_lib_sample

# Monorepo Example
https://github.com/manfredsteyer/monorepo-demo

# Micro Apps Example
https://github.com/manfredsteyer/Angular_MicroApps_Different_Technologies

# More Blog-Articles & Angular Trainings
https://www.softwarearchitekt.at

15934fa2aa7b2ce21f091e9b7cffa856?s=128

Manfred Steyer
PRO

October 16, 2018
Tweet

Transcript

  1. @ManfredSteyer Angular and Micro Apps: Maintainable Client Architectures Manfred Steyer

    SOFTWAREarchitekt.at ManfredSteyer
  2. @ManfredSteyer About me… • Manfred Steyer • SOFTWAREarchitekt.at • Angular

    Trainings and Consultancy • Google Developer Expert (GDE) Page ▪ 2 Manfred Steyer Public: Vienna, München, Zürich In-House: everywhere http://softwarearchitekt.at/workshops
  3. @ManfredSteyer Ever started a project from the scratch? Kick-off After

    some weeks After some years
  4. @ManfredSteyer Idea System

  5. @ManfredSteyer Idea µService µService µService

  6. @ManfredSteyer Idea µApps µApps µApps

  7. @ManfredSteyer Folie▪ 7 Pro Contra

  8. @ManfredSteyer Contents 1) Deployment Monolith 2) Hyperlinks 3) Shell 4)

    How to choose?
  9. @ManfredSteyer Deployment Monolith

  10. @ManfredSteyer Idea µService µService µService Client Fragment Client Fragment Client

    Fragment ✓ Easy (Tooling) ✓ One optimized Bundle ✓ Consistent  No separate deployment  Mixing Technologies: Difficult npm Packages ?
  11. @ManfredSteyer Create npm-Packages with CLI >= 6 ng new lib-project

    cd lib-project ng generate library flight-booking-lib ng generate application playground-app ng serve --project playground-app ng build --project flight-booking-lib
  12. @ManfredSteyer Project Structure

  13. @ManfredSteyer Publish Library cd dist/flight-booking-lib npm publish --registry http://localhost:4873 Alternative:

    .npmrc file in project root
  14. @ManfredSteyer Advantages • Distribution • Versioning • Decoupling between lib

    authors and app authors
  15. @ManfredSteyer Disadvantages • Distribution • Versioning • Decoupling between lib

    authors and app authors ;-)
  16. @ManfredSteyer Disadvantages Distribution • Annoying within project • Prevents gritting

    further libs Versioning • Old versions • Conflicts • How to force devs to use latest version? Decoupling • What if lib authors == app authors?
  17. @ManfredSteyer Monorepo

  18. @ManfredSteyer Workspace

  19. @ManfredSteyer Advantages Everyone uses the latest versions No version conflicts

    No burden with distributing libs Creating new libs: Adding folder Experience: Successfully used at Google, Facebook, …
  20. @ManfredSteyer Moving back and forth Npm Registry

  21. @ManfredSteyer Tooling & Generator https://nrwl.io/nx

  22. @ManfredSteyer Visualize Module Structure

  23. @ManfredSteyer DEMO

  24. @ManfredSteyer Advantages Sub Project Sub Project Sub Project Sub Project

    Sub Project Sub Project Sub Project Sub Project
  25. @ManfredSteyer Disadvantages Sub Project Sub Project Sub Project Sub Project

    Sub Project Sub Project Sub Project Sub Project
  26. @ManfredSteyer Disadvantages Sub Project Sub Project Sub Project Sub Project

    Sub Project Sub Project Sub Project Sub Project Team A Team B Contract
  27. @ManfredSteyer Disadvantages One Architecture One Technology Stack Hard to change

    No self- contained teams One size fits all?
  28. @ManfredSteyer Hyperlinks

  29. @ManfredSteyer UI Composition w/ Hyperlinks µApp SPA µApp SPA µApp

    SPA
  30. @ManfredSteyer

  31. @ManfredSteyer

  32. @ManfredSteyer ✓ Simple  Loosing State  Load a new

    Application
  33. @ManfredSteyer 3) Shell

  34. @ManfredSteyer µService Providing a (SPA based) Shell µApp µApp µApp

    Shell ▪ iframes ▪ Bootstrapping several SPAs ▪ Wrap them into Web Components?
  35. @ManfredSteyer Angular Elements

  36. @ManfredSteyer MicroApp with Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { }
  37. @ManfredSteyer MicroApp with Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { }
  38. @ManfredSteyer MicroApp with Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { constructor(private injector: Injector) { } ngDoBootstrap() { } }
  39. @ManfredSteyer MicroApp with Angular Elements @NgModule({ imports: [BrowserModule], declarations: [MicroAppComponent],

    bootstrap: [], entryComponents: [MicroAppComponent] }) export class AppModule { constructor(private injector: Injector) { } ngDoBootstrap() { const MicroAppElement = createCustomElement( MicroAppComponent, { injector: this.injector }); customElements.define('micro-app', MicroAppElement); } }
  40. @ManfredSteyer Loading MicroApps <script src="micro-app.bundle.js"></script> <micro-app></micro-app>

  41. @ManfredSteyer DEMO

  42. @ManfredSteyer 4) Choosing a Solution

  43. @ManfredSteyer Some General Advice Shared state, navigation b/w apps Hyperlinks

    Legacy Apps or *very very* strong isolation? iframes Separate Deployment/ mix Technologies? Web Components Monolith w/ Libs and Monorepo little much yes no yes no Not a good fit for public web sites
  44. @ManfredSteyer Architecture within Micro-Apps Packages Web Components Monorepo Inner Sourcing

  45. @ManfredSteyer Blog > SOFTWAREarchitekt.at • A Software Architect's Approach Towards

    Using Angular (And SPAs In General) For Microservices Aka Microfrontends • A Lightweight And Solid Approach Towards Micro Frontends (Micro Service Clients) With Angular And/Or Other Frameworks • Micro Apps With Web Components Using Angular Elements
  46. @ManfredSteyer Conclusion Monorepo Hyper Links Shell You need to evaluate

  47. @ManfredSteyer Beware the Frankenstein- Monster!!

  48. @ManfredSteyer Contact and Downloads [mail] manfred.steyer@SOFTWAREarchitekt.at [web] SOFTWAREarchitekt.at [twitter] ManfredSteyer

    d http://softwarearchitekt.at/workshops Slides & Examples