Module Federation Examples
This repository is to showcase examples of how Webpack 5's new Module Federation can be used.
If you need support, consider looking at my sponsor profile https://github.com/sponsors/ScriptedAlchemy | For companies that require consultations, contact me on twitter or email (on github profile) |
---|---|
Youtube Screencasts | https://www.youtube.com/playlist?list=PLWSiF9YHHK-DqsFHGYbeAMwbd9xcZbEWJ |
Info site | https://module-federation.github.io/ |
Official Docs | https://webpack.js.org/concepts/module-federation |
Original Webpack Issue | https://github.com/webpack/webpack/issues/10352 |
Medium post | https://link.medium.com/xzFgBBtAx6 |
JSNation Presentation | https://github.com/sokra/slides/blob/master/content/ModuleFederationWebpack5.md |
Post about Dynamic Remotes | https://h3manth.com/posts/dynamic-remotes-webpack-module-federation/ |
Check out our book
Consultations
1 Hour group consultation | $100 |
---|---|
30 Min 1:1 consultation | $60 |
15 Min 1:1 consultation | $30 |
Bespoke API modifications and hands on code | $300-$500/hr |
Examples
Legend:
β οΈ : In Progress/Incomplete- π: Depends on proprietary code that isn't free.
- Advanced API β showcasing advanced API use, also seen in other examples
- Basic Host-Remote β App 1 consumes remote components from App2.
- Create React App β Module Federation using CRA.
- HMR Remotes β Hot Reloading Remotes inside Hosts.
- Startup Code β Advanced implementation that attaches initialization code to the remote container itself. Useful for dynamically setting publicPath in the remote.
- Bi-Directional Hosts β App1 consumes App2 components; App2 consumes App1 components.
- Self-Healing β Fallback to remote apps vendors if a dependency fails to load.
- Server-Side Rendering β App1 and App2 with SSR.
- Server-Side Rendering (simplified) β Less complex boilerplate.
- Multi UI Framework Federation β Multiple Apps in different technologies federated.
- Dynamic System Host β Swap between remotes at runtime.
- Redux Reducer Injection β Dynamically inject reducers to host store at runtime.
- Shared Routes β Compose federated routes for a seamless user experience.
- Nested Components β Nested remote components.
- Share Context Provider β App1 and App2 with shared Context Provider.
- Federation Dashboard Example β Single example implementing Module Federation Dashboard
- π Streaming Federated Code β App1 and federated-middleware deploy to s3. App1 then stream's federated code directly from S3
- Non-UI Module
- Routing β An example of sharing router context. Also worth looking at - Routing 2
- Version Discrepancy β Federated apps depending on different versions of a dependency without side-effects.
- TypeScript β Simple host/remote example using TypeScript.
- Angular Universal β Remote and Host app with SSR, lazy modules and components.
- NextJS Sidecar Build β Sidecar build to enable module-federation alongside Next codebases
- NextJS β Operation, with nextjs-mf.
- NextJS SSR β Powered by software streams, with nextjs-ssr (currently in closed beta testing)
- Building A Plugin-based Workflow Designer With Angular and Module Federation β External Example
- Vue.js β Simple host/remote (render function / sfc) example using Vue 3.0.
- Vue2 SSR β This example demonstrates module as a service
Notes
To run from a git checkout locally, remove all of the proprietary example directories and then run yarn
at the repo root.
You can then run yarn && yarn start
from any of the non-proprietary examples.
Module federation will work with any type of file that youre able to import, that webpack underestands how to process. It is not a JS only, or react only feature. Images, CSS, JSON, WASM, and anything else can be federated.
Companies using Module Federation
- Netflix
- Microsoft
- Lululemon
- Housing.com
- VMware
- Talkdesk
- Cricket Wireless
- Bytedance
- Rivian (in the cars themselves)
- Realtor.com
- FICO
- Digital Ocean
- Alibaba
- Tencent
- Wayfair
- RingCentral
- Indeed
- Telia
- Amazon
- Sony
- MGM
- Lowes
- Home Depot
- Epic Games
- ExpediaGroup
- Verizon
- and many more I cant remember