One runtime for 30+ micro-frontends, via Import Maps
Share framework and platform code at runtime instead of bundling it thirty times.
Context
More than thirty micro-frontends render inside one product, built and released by different teams.
Each one needs React and a handful of shared platform libraries. Bundling them into every frontend would mean shipping the same code thirty times.
{ "imports": {
"react": "/runtime/react.js",
"@platform/ui": "/runtime/ui.js"
} }Options considered
| Option | For | Against |
|---|---|---|
| Bundle shared code into every app (rejected) | Simple, and fully independent. | The same framework is downloaded again and again, and versions drift apart. |
| Compose everything at build time (rejected) | One optimised bundle. | Teams can no longer release on their own. |
| Import Maps, one shared runtime (chosen) | A web standard. Shared code is downloaded once and teams still release independently. | Needs a clear contract for which versions are shared. |
Decision
All micro-frontends load shared dependencies, such as React, from one platform runtime, resolved through Import Maps.
Consequences
Better
- Shared code is downloaded once.
- Bundle size stayed flat as new frontends were added.
- Teams keep releasing on their own schedule.
Harder
- Upgrading a shared library has to be coordinated.
- The runtime is now critical infrastructure.