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

Micro Frontends and Monorepos: Smart Idea or Co...

Micro Frontends and Monorepos: Smart Idea or Contradiction?

Avatar for Manfred Steyer

Manfred Steyer

March 10, 2021
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

  1. @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 Option 1: One App per Domain Monorepo
  2. @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 Option 2: One Monorepo per Domain Publish shared libs seperately via npm Repository n Repository 2 Repository 1
  3. @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!
  4. @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')
  5. @ManfredSteyer How to Get the Microfrontend's URL? Shell (Host) Microfrontend

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

    [ "@angular/core", "…" ] shared: [ "@angular/core", "…" ]
  7. @ManfredSteyer Solution 2a Deploy MFE1 Change Shared Lib v1.2 Deploy

    MFE2 Change Shared Lib v1.1 Share highest compatible version: v1.2
  8. @ManfredSteyer Solution 2b Deploy MFE1 Change Shared Lib v2.1 Deploy

    MFE2 Change Shared Lib v1.1 Conflict? Prevent with E2E tests!
  9. @ManfredSteyer Configuring // Required Version in app's webpack.config.js shared: {

    […] sharedMappings.getDescriptor('auth-lib', '^1.1'), } // Assign version number in lib's package.json "version": "1.2"
  10. @ManfredSteyer When can we have it? Webpack 5 and Module

    Federation: final Angular CLI 11: Experimental Opt-in for webpack 5 Angular CLI 12: Official webpack 5 integration