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

Microfrontends: Necessities - Implementations -...

Rainer Hahnekamp
December 17, 2024
68

Microfrontends: Necessities - Implementations - Challenges

Microfrontends are a hot topic, promising an architecture where multiple teams can work independently on a single application, making their own technical choices while remaining isolated from each other. Sounds ideal, right?

But it’s worth considering the trade-offs. While Microfrontends offer unique benefits, they also introduce overhead and can come with unexpected challenges. In this talk, I’ll provide an honest overview of the technical possibilities, along with the pros and cons of each approach. You’ll learn about iFrame integration, Web Components, Native & Module Federation, and see these techniques in action.

For some, Microfrontends are a no-go; for others, they’re an option or even an absolute necessity. By the end of my talk, you should know which group you belong to.

Rainer Hahnekamp

December 17, 2024
Tweet

Transcript

  1. About Me... https://www.youtube.com/ @RainerHahnekamp https://www.ng-news.com https://github.com/softarc-consulting/sheriff • Rainer Hahnekamp ANGULARarchitects.io

    NgRx Team (Trusted Collaborator) • Developer / Trainer / Speaker @RainerHahnekamp Workshops NgRx • Testing • Spring • Quality
  2. RainerHahnekamp Web Components • Supported by Angular Elements • Custom

    Elements + HTML Templates + Shadow DOM • Squeeze a whole app into a tag
  3. RainerHahnekamp Web Components • Bundle Size • Multiple Angular Instances

    • Issues with Router • Multiple Zones ◦ Go zoneless! • Perfect fit for UI Components • High Isolation / Little Inter-Communication • Tricks to share dependencies ◦ One zone.js ◦ WebPack Externals
  4. RainerHahnekamp Application Code Feature (Lazy Loaded) Application 1 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Application Code Feature (Lazy Loaded) Application 2 3rd Party Libs 3rd Party Libs 3rd Party Libs Module Federation
  5. RainerHahnekamp Application Code Feature (Lazy Loaded) Application 1 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Application Code Feature (Lazy Loaded) Application 2 3rd Party Libs 3rd Party Libs 3rd Party Libs Module Federation
  6. RainerHahnekamp Application Code Feature (Lazy Loaded) Application 1 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Application Code Feature (Lazy Loaded) Application 2 3rd Party Libs 3rd Party Libs 3rd Party Libs Module Federation
  7. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 1 (Remote 1)

    3rd Party Libs 3rd Party Libs 3rd Party Libs Application Code Feature (Lazy Loaded) MF 2 (Remote 2) 3rd Party Libs 3rd Party Libs 3rd Party Libs Module Federation
  8. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs
  9. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs
  10. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs JS JS JS JS
  11. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS JS JS JS Build Time Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs JS JS JS JS
  12. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS JS JS JS Build Time Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Application Code Shell (Host) Runtime JS JS JS JS JS JS JS https://host2 https://host3 https://host1
  13. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS JS JS JS Build Time Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Runtime JS JS JS JS
  14. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS JS JS JS Build Time Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Application Code Shell (Host) Runtime JS JS JS JS JS JS JS
  15. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS JS JS JS Build Time Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Application Code Shell (Host) Runtime JS JS JS JS JS JS JS JS
  16. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS JS JS JS Build Time Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Application Code Shell (Host) Runtime JS JS JS JS JS JS JS JS JS
  17. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS JS JS JS Build Time Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Application Code Shell (Host) Runtime JS JS JS JS JS JS JS JS JS ? ?
  18. RainerHahnekamp Shared Libraries & Constraints • Libraries can & should

    be shared ◦ Multiple Libraries (different or same version) as Edge Case • "Compiled Angular" doesn't follow semantic versioning ◦ Divering (even on Patch-Level) is risky ◦ Runtime protection built-in
  19. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS JS JS JS Build Time Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Application Code Shell (Host) Runtime JS JS JS JS JS JS JS JS JS
  20. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS JS JS JS Build Time Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Application Code Shell (Host) Runtime JS JS JS JS JS JS JS JS JS
  21. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS JS JS JS Build Time Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Application Code Shell (Host) Runtime JS JS JS JS JS JS JS JS JS
  22. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS JS JS JS Build Time Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Application Code Shell (Host) Runtime JS JS JS JS JS JS JS JS JS
  23. RainerHahnekamp Application Code Feature (Lazy Loaded) MF 2 3rd Party

    Libs 3rd Party Libs 3rd Party Libs Module Federation Application Code Feature (Lazy Loaded) MF 1 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS JS JS JS Build Time Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Application Code Shell (Host) Runtime JS JS JS JS JS JS JS JS JS Module Federation Logic
  24. RainerHahnekamp Module Federation ✅ No Issues because of multiple Angular

    applications • Same Zone.js, Router, Store, HttpClient, UserService... ✅ Small Bundle Size • No Treeshaking for shared libraries ⛔ Compromise • Full Autonomy except Versioning • Return of the Monorepo? ⛔ Bound to Bundler • WebPack, Rspack
  25. RainerHahnekamp Application Code Feature (Lazy Loaded) 3rd Party Libs 3rd

    Party Libs 3rd Party Libs Build Time JS JS JS JS Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Runtime Module & Native Federation Module Federation
  26. RainerHahnekamp Application Code Feature (Lazy Loaded) 3rd Party Libs 3rd

    Party Libs 3rd Party Libs Build Time JS JS JS JS Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Runtime Module & Native Federation Module Federation
  27. RainerHahnekamp Application Code Feature (Lazy Loaded) 3rd Party Libs 3rd

    Party Libs 3rd Party Libs Build Time JS JS JS JS Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Runtime Module & Native Federation Module Federation
  28. RainerHahnekamp Application Code Feature (Lazy Loaded) 3rd Party Libs 3rd

    Party Libs 3rd Party Libs Build Time JS JS JS JS Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Runtime Module & Native Federation Module Federation
  29. RainerHahnekamp Application Code Feature (Lazy Loaded) 3rd Party Libs 3rd

    Party Libs 3rd Party Libs Application Code Feature (Lazy Loaded) 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Runtime JS JS JS JS Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Module & Native Federation Module Federation Native Federation
  30. RainerHahnekamp Application Code Feature (Lazy Loaded) 3rd Party Libs 3rd

    Party Libs 3rd Party Libs Application Code Feature (Lazy Loaded) 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Runtime JS JS JS JS Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Module & Native Federation Module Federation Native Federation
  31. RainerHahnekamp Application Code Feature (Lazy Loaded) 3rd Party Libs 3rd

    Party Libs 3rd Party Libs Application Code Feature (Lazy Loaded) 3rd Party Libs 3rd Party Libs 3rd Party Libs Build Time JS JS JS JS Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Runtime JS JS JS JS Application Code Shell (Host) 3rd Party Libs 3rd Party Libs 3rd Party Libs Module & Native Federation Module Federation Native Federation
  32. RainerHahnekamp Native Federation vs. Module Federation ✅ Decoupled from Bundler

    during Runtime • Multiple & Different Bundlers during Build Time (Adapter is necessary) • CDN as Supplier • Web Standards ✅ Module Federation embeddable ⛔ Requires ESM
  33. RainerHahnekamp • Hyperlink • SingleSPA • Custom Solutions ◦ e.g.

    Google Cloud • Hybrids ◦ Module Federation & Native Federation & Web Components • Web Fragments Alternative Implementations