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

5 Steps to Your Frankenstein Micro Frontends

5 Steps to Your Frankenstein Micro Frontends

Manfred Steyer

February 10, 2022
Tweet

More Decks by Manfred Steyer

Other Decks in Programming

Transcript

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

    App Boarding App Luggage App Luggage App Micro Frontends
  2. @ManfredSteyer Booking App Booking App Check-in App Check-in App Boarding

    App Boarding App Luggage App Luggage App One Reason: Migrating Step by Step (1) (1) (2+) (2+)
  3. @ManfredSteyer Booking App Booking App Check-in App Check-in App Boarding

    App Boarding App Luggage App Luggage App Onother Reason: Merger
  4. @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')
  5. @ManfredSteyer How to Share Libs? Shell (Host) Microfrontend (Remote) shared:

    [ "@angular/core", "…" ] shared: [ "@angular/core", "…" ]
  6. @ManfredSteyer // webpack.config.js in Micro Frontend plugins: [ new ModuleFederationPlugin({

    name: "react", filename: "remoteEntry.js", exposes: { './web-components': './app.js', }, shared: ["react", "react-dom"] }), ]
  7. @ManfredSteyer // Routing Config in Shell { //path: 'react', matcher:

    startsWith('react'), component: WebComponentWrapper, data: { type: 'script', remoteEntry: 'https://[…]/remoteEntry.js', remoteName: 'react', exposedModule: './web-components', elementName: 'react-element' } as WebComponentWrapperOptions },
  8. @ManfredSteyer // Path Matcher in both, Shell and Micro Frontends

    { //path: 'react', matcher: startsWith('react'), component: WebComponentWrapper, data: { type: 'script', remoteEntry: 'https://[…]/remoteEntry.js', remoteName: 'react', exposedModule: './web-components', elementName: 'react-element' } as WebComponentWrapperOptions },
  9. @ManfredSteyer // Path Matcher in both, Shell and Micro Frontends

    { //path: 'react', matcher: startsWith('react'), component: WebComponentWrapper, data: { type: 'script', remoteEntry: 'https://[…]/remoteEntry.js', remoteName: 'react', exposedModule: './web-components', elementName: 'react-element' } as WebComponentWrapperOptions },
  10. @ManfredSteyer You Need a Good Reason! Module Federation: Sharing Code

    Web Components: Hiding Frameworks and Versions