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

Federated Angular: Streight Forward Micro Frontends @BASTA 2021

Federated Angular: Streight Forward Micro Frontends @BASTA 2021

15934fa2aa7b2ce21f091e9b7cffa856?s=128

Manfred Steyer
PRO

September 22, 2021
Tweet

Transcript

  1. @ManfredSteyer ManfredSteyer Federated Angular: Streight Forward Micro Frontends Manfred Steyer,

    ANGULARarchitects.io
  2. @ManfredSteyer

  3. @ManfredSteyer Booking App Booking App Check-in App Check-in App Boarding

    App Boarding App Luggage App Luggage App Micro Frontends
  4. @ManfredSteyer Micro Frontends

  5. @ManfredSteyer

  6. @ManfredSteyer Contents #1: Module Federation #2 Version Mismatch #3: Federated

    Angular #4: Dynamic Module Federation #5: Possible Roadmap
  7. @ManfredSteyer Manfred Steyer

  8. @ManfredSteyer

  9. @ManfredSteyer

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

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

    [ "@angular/core", "…" ] shared: [ "@angular/core", "…" ]
  14. @ManfredSteyer

  15. @ManfredSteyer Default Behavior Selecting the highest compatible version 10.0 10.1

  16. @ManfredSteyer Default Behavior Conflict: No highest compatible version 11.0 10.1

  17. @ManfredSteyer Example • Shell: my-lib: ^10.0 • MFE1: my-lib: ^10.1

    • MFE2: my-lib: ^9.0 • MFE3: my-lib: ^9.1 Result: • Shell and MFE1 share ^10.1 • MFE2 and MFE3 share ^9.1
  18. @ManfredSteyer Configuring Singletons shared: { "my-lib": { singleton: true }

    } 11.0 10.1
  19. @ManfredSteyer Configuring Singletons shared: { "my-lib": { singleton: true, strictVersion:

    true // Error instead of warning! } } 11.0 10.1
  20. @ManfredSteyer Relaxing Version Requirements shared: { "my-lib": { requiredVersion: ">=1.0.1

    <11.1.1" } }
  21. @ManfredSteyer

  22. @ManfredSteyer ?

  23. @ManfredSteyer Custom Builder

  24. @ManfredSteyer

  25. @ManfredSteyer 1) ng add @angular-architects/module-federation 2) Adjust generated configuration 3)

    ng serve
  26. @ManfredSteyer

  27. @ManfredSteyer

  28. @ManfredSteyer Dynamic Module Federation Shell (Host) Microfrontend (Remote) remotes: {

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

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

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

    } exposes: { Cmp: './my.cmp.ts' } loadRemoteModule({ remoteEntry: 'http://…', remoteName: 'mfe1', exposedModule: './Cmp' }) Helper Function using the Webpack API
  32. @ManfredSteyer

  33. @ManfredSteyer

  34. @ManfredSteyer Well … Webpack 5: final @angular-architects/module-federation: final CLI 11:

    Experimental webpack 5 support CLI 12: Official webpack 5 support (May 2021)
  35. @ManfredSteyer Free eBook ANGULARarchitects.io/book Updated for Module Federation and Alternatives

  36. @ManfredSteyer Conclusion Module Federation Loading Separately Deployed Code Version Mismatches

    Federated Angular Dynamic Federation
  37. @ManfredSteyer

  38. @ManfredSteyer d Slides & Examples Remote Company Workshops and Consulting

    http://angulararchitects.io