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

More Than Micro Frontends: 3 Further Use Cases for Module Federation @DWX 2022

More Than Micro Frontends: 3 Further Use Cases for Module Federation @DWX 2022

Manfred Steyer

July 05, 2022
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

  1. @ManfredSteyer ManfredSteyer More Than Micro Frontends: 3 Further Use Cases

    for Module Federation Manfred Steyer, ANGULARarchitects.io
  2. @ManfredSteyer Idea const Component = await import('http://other-app/xyz') Does not work

    with webpack/ Angular CLI Does not work with webpack/ Angular CLI
  3. @ManfredSteyer Webpack 5 Module Federation 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 How to Get the Microfrontend's URL? Shell (Host) Microfrontend

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

    [ "@angular/core", "…" ] shared: [ "@angular/core", "…" ]
  6. @ManfredSteyer Dynamic Module Federation Shell (Host) Microfrontend (Remote) remotes: {

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

    } exposes: { Cmp: './my.cmp.ts' } loadRemoteModule({ type: 'module', remoteEntry: 'http://…', exposedModule: './Cmp' })
  8. @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
  9. @ManfredSteyer Setting Micro Frontend Shell 10 Micro Frontends á 20

    Features Separately buildable 200 Features in total!
  10. @ManfredSteyer Angular CLI npm install -g @angular/cli ng new workspace

    cd workspace ng generate app my-app ng generate lib my-lib ng serve my-app ng build my-app
  11. @ManfredSteyer Nx npm install -g @angular/cli npm init nx-workspace workspace

    cd workspace ng generate app my-app ng generate lib my-lib ng serve my-app ng build my-app