Framework InternalsBaseline · Widely

Micro-Frontend Isolation: Shadow DOM, Iframes & Module Graphs

Mental Model

Micro-frontends trade isolation strength against memory and UX friction. Shadow DOM scopes CSS inside one browsing context, ES Modules import maps deduplicate shared runtimes, and <iframe> enforces full origin and JS heap boundaries.

Interactive Simulator

Micro-Frontend Isolation Boundaries

Compare shared module graphs, Shadow DOM scoping, and iframe process isolation.

Host Shell
Shared Module Map
Billing Remote
Step 1 / 3: 1. Shared ES Module Graph

Import map resolves 'react' to a single cached module URL across both host and remote.

import React from 'react';
// 1 shared module instance
Internal State / Memory
cssIsolated
false
jsHeapShared
true
duplicateFrameworks
0

Under the Hood

Each isolation primitive enforces a different boundary inside the browser's renderer process.

  1. Module Federation & Import Maps: Shares a single window, document, and JS heap; a central dependency resolver negotiates singleton versions (e.g., react@19) so remotes do not download duplicate 45 KB runtimes.
  2. Shadow DOM + Proxy Sandbox: attachShadow({ mode: 'open' }) blocks outer CSS selectors from bleeding inward, while a Proxy(window) sandbox intercepts global property writes per sub-app.
  3. Cross-Origin <iframe>: Allocates an isolated browsing context (and often a separate OS site-isolation process via COOP/COEP), communicating strictly over postMessage() structured clones.
HTML
<script type="importmap">
  {
    "imports": {
      "react": "https://cdn.example.com/react@19/index.js",
      "@billing/widget": "https://billing.example.com/widget.js"
    }
  }
</script>
<billing-shell></billing-shell>

Problem Genealogy

  • 2016 (Iframes & Portal Shells): Guaranteed fault and CSS isolation, but broke URL deep-linking, accessibility focus, and modal overlays at iframe viewport edges.
  • 2020 (Webpack Module Federation): Shared singletons dynamically across independently deployed builds, risking runtime crashes when teams drifted on incompatible peer dependencies.
  • 2024 (Import Maps + Shadow DOM): Native browser module resolution paired with declarative Shadow DOM eliminated bundler-specific runtime loaders.

Production Pitfalls

Production Pitfall
  • Dual-Framework Heap Bloat: Loading both React 18 and React 19 remotes without singleton version negotiation duplicates event delegation listeners on document and doubles baseline JS memory.
  • Portal Escape Through Shadow Boundaries: Rendering a modal via document.body.appendChild breaks out of the Shadow DOM root and loses all scoped component styles.
When Not to Use
  • When not to use micro-frontends: Never split an application owned by fewer than 3 independent teams into runtime micro-frontends; cross-team version skew, duplicate shared chunks, and postMessage serialization latency cost more than a modular monorepo.

Connections & Logical Next Steps

Framework InternalsMicro-Frontend Isolation: Shadow DOM, Iframes & Module Graphs
What This Unlocks
Leaf concept