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

Micro Frontends with Module Federation in Angular 12

Micro Frontends with Module Federation in Angular 12

15934fa2aa7b2ce21f091e9b7cffa856?s=128

Manfred Steyer
PRO

May 12, 2021
Tweet

Transcript

  1. @ManfredSteyer ManfredSteyer Micro Frontends with Module Federation in Angular 12

    Manfred Steyer, ANGULARarchitects.io
  2. @ManfredSteyer Contents #1: Module Federation 101 #2: What's new for

    MF & Angular 12 #3: Future Features
  3. @ManfredSteyer Manfred Steyer

  4. @ManfredSteyer

  5. @ManfredSteyer Micro Frontends

  6. @ManfredSteyer

  7. @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!
  8. @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')
  9. @ManfredSteyer How to Get the Microfrontend's URL? Shell (Host) Microfrontend

    (Remote) RemoteEntry.js <script src="…"></script>
  10. @ManfredSteyer How to Share Libs? Shell (Host) Microfrontend (Remote) shared:

    [ "@angular/core", "…" ] shared: [ "@angular/core", "…" ]
  11. @ManfredSteyer 1) ng add @angular-architects/module-federation 2) Adjust generated configuration 3)

    ng serve
  12. @ManfredSteyer

  13. @ManfredSteyer

  14. @ManfredSteyer Webpack 5 is Backed Into CLI 12 No need

    for forcing the CLI into webpack 5 anymore: "resolutions": { "webpack": "^5.0.0" }, Feel free to use yarn or npm
  15. @ManfredSteyer Better Monorepo Support Share like npm package

  16. @ManfredSteyer Big Thanks to Webpack's Tobias Koppers

  17. @ManfredSteyer Better Monorepo Support Migrate from Angular 11? Have a

    look on how we generate the webpack.config.js in Version 12
  18. @ManfredSteyer npm run run:all

  19. @ManfredSteyer Booking Booking Boarding Boarding Shared Shared Feature Feature Feature

    Feature Feature Feature Feature Feature Feature Feature … … … … … … … … … … … … … … … … … … Booking App Booking App Boarding App Boarding App Btw: Also Works Perfectly w/ Multiple Repos Repository n Repository 2 Repository 1
  20. @ManfredSteyer Tutorial is Updated https://www.npmjs.com/package/@angular-architects/module-federation

  21. @ManfredSteyer Make sure you use Version ^12 for Angular 12!

  22. @ManfredSteyer

  23. @ManfredSteyer

  24. @ManfredSteyer Evolution, not Revolution! Keep Track with upcoming Angular CLI

    versions Small Features to automate repetitive tasks
  25. @ManfredSteyer Free eBook ANGULARarchitects.io/book Updated for Module Federation and Alternatives

  26. @ManfredSteyer Conclusion Loading Separately Deployed Code Better Monorepo Support Multi

    Repos supported too! run:all More to come!
  27. @ManfredSteyer d Slides & Examples Remote Company Workshops and Consulting

    http://angulararchitects.io