Runtime

Module Federation

Each team builds and deploys its own bundle. The shell loads those bundles at runtime and can share common dependencies, such as React, as a single copy.

How it works

team-a remoteTeam A
team-b remoteTeam B
react (singleton)Shared
shell · in the browserShell
Dashed lines: loaded at runtime · runtime fetch
  1. Shell loads. The browser loads the shell, which knows where each remote's entry file lives.
  2. Fetch the remote entry. When a slot is needed, the shell requests team A's remote entry and the chunks it points to.
  3. Share dependencies. Shared modules come from a common share scope. With a singleton, everyone uses one copy and a version mismatch prints a warning.
  4. Mount. Team A's module renders into its slot. Team B loads the same way, from its own deployment.

Try it

Demo D

Shared dependency conflict

Team A and Team B both use React, and both start on 18.3, so the browser downloads one shared copy and both apps render. Move Team B to React 19.0 and the two versions no longer share a major version. With no singleton, each app brings its own copy: everything works, but users download a second React, about 45 KB more, and a component from one copy can't render inside the other copy's tree or read its context. Force a singleton instead and only the higher version, 19.0, is loaded, so Team A, built for 18.3, runs on a React it wasn't built for and may break. In Module Federation a singleton version mismatch only prints a warning, and with strictVersion it is a runtime error. Native Federation uses the shared copy silently, and with strictVersion gives that team its own copy instead, so the forced singleton no longer holds. The sizes are illustrative.

Dependency sharing is a real cost.Either teams coordinate versions, or users download duplicates, or a forced singleton breaks someone at runtime. Pick one on purpose.

Pros

  • Teams deploy their remotes independently; the shell picks up new versions at runtime.
  • Shared dependencies can be loaded once instead of once per team.
  • Remote modules load on demand, when a slot needs them.

Cons

  • Version mismatches in shared dependencies show up at runtime, not at build time.
  • More moving parts: remote URLs per environment and fallbacks for remotes that fail to load.
  • Extra network requests when a remote first loads.

Best when

  • Several teams on the same framework.
  • Teams regularly blocked by a shared release.
  • CI/CD and monitoring mature enough to own runtime failures.

Avoid when

  • One or two teams.
  • Strict performance budgets without a plan for preloading.
  • Domain boundaries that are still unclear.

In code

webpack.config.js · shell/src/bootstrap.js
// webpack.config.js, in plugins: the shell declares where team A's build lives
new ModuleFederationPlugin({
  name: "shell",
  remotes: {
    teamA: "teamA@https://team-a.example.com/remoteEntry.js",
  },
  shared: { react: { singleton: true } },
});

// shell/src/bootstrap.js, at runtime: load team A's exposed module and mount it
async function mountTeamA() {
  const { mount } = await import("teamA/App");
  mount(document.querySelector("#team-a"));
}

Tooling and ecosystem

Module Federation is built into webpack 5 as ModuleFederationPlugin. The Module Federation project maintains Module Federation 2.0, which adds a federation runtime, a manifest (mf-manifest.json), dynamic type hints, a runtime plugin system and Chrome DevTools support; its introduction lists Rspack and webpack as supported build tools. The project also documents a Vite integration, @module-federation/vite (1.23 as of November 2026). Its Next.js plugin, @module-federation/nextjs-mf, has been in maintenance mode since November 2024: the core team does no new development on it and expects to stop tracking it in the second half of 2026 (module-federation/core#3153).

In webpack’s shared configuration, singleton: true keeps one copy of a library such as React and prints a warning when the chosen version doesn’t satisfy a consumer’s requiredVersion; adding strictVersion: true turns that warning into a runtime error.