Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Micro Frontends with Module Federation: Beyond ...

Micro Frontends with Module Federation: Beyond the Basics

Manfred Steyer

May 03, 2023
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

  1. @ManfredSteyer #1 Version Mismatches #2 Mono vs. Multirepo #3 Dynamic

    Federation #4 Multiple Frameworks/ Versions
  2. @ManfredSteyer #1 Version Mismatches #2 Mono vs. Multirepo #3 Dynamic

    Federation #4 Multiple Frameworks/ Versions #0 Module Federation 101
  3. @ManfredSteyer Shell (Host) Microfrontend (Remote) // Maps Urls in //

    webpack config remotes: { mfe1: "http://..." } // Expose files in // webpack config exposes: { './Cmp': './my.cmp.ts' } import('mfe1/Cmp')
  4. @ManfredSteyer Make sure, your Angular-based code sees exactly the same

    Angular version at runtime it was built with! (Don't use ^ or ~ in your package.json)
  5. @ManfredSteyer Booking Boarding Shared Feature Feature Feature Feature Feature …

    … … … … … … … … Booking App Boarding App Publish shared libs seperately via npm Repository n Repository 2 Repository 1 Version Mismatches? Strict Borders
  6. @ManfredSteyer Booking Boarding Shared Feature Feature Feature Feature Feature …

    … … … … … … … … Booking App Boarding App
  7. @ManfredSteyer Dynamic Module Federation Shell (Host) Microfrontend (Remote) remotes: {

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

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

    } exposes: { Cmp: './my.cmp.ts' } loadRemoteModule({ type: 'module', remoteEntry: 'http://…', exposedModule: './Cmp' }) Helper Function using the Webpack API
  10. @ManfredSteyer const main = await import('other-app/main'); main.bootstrap(); const rootElm =

    document.createElement('app-root') document.body.appendChild(rootElm);
  11. @ManfredSteyer Conclusion Baked-in Strategies for Version Mismatches Monorepo vs. Multirepo:

    Self-restriction vs. (Costly) Freedom Webpack Runtime API: Dynamic Federation Frankenstein: Bootstrapping Several SPAs