FynMesh

Legacy RequireJS micro frontends on federated React

RequireJS micro frontends get their shared libraries from a common web package (CWP). This demo brings Module Federation to them progressively, with no rebuild of the widgets. The guide explains the setup.

The setup: widgets and the CWP

In a RequireJS micro frontend, each widget is built as an AMD bundle. Shared libraries like React and the UI kit are built into a common web package (CWP). Widgets consume the CWP through webpack externals, so every bundle asks for its libraries with define(["react", "react-dom", "ui-kit"], ...).

The problem

A large enterprise builds up many widgets from many teams over time. They all depend on the same CWP. Updating a library version or adding a variant means every team must move together, which is near impossible. Module Federation solves this, but legacy widgets cannot use it. They also cannot all migrate in one shot.

The fix: federation, one piece at a time

The CWP becomes a FynApp. It installs React and the UI kit from npm at pinned versions, and serves them from federation under the AMD ids the widgets already ask for. A kernel add-on routes RequireJS to it. Each RequireJS context stays on the legacy CWP or moves to the federated one, with no rebuild. New FynApps run on the same page and share the CWP's React when their range matches.

Before Team A, B, C bundleswebpack AMD define("react", "ui-kit") → Legacy CWPReact 18 and ui-kit, one copy for all
Federated Team A, B, C bundlessame files, not rebuilt → AMD add-onreads the CWP's amd-meta.js → CWP FynAppCWP 3: React 18.3.1, CWP 4: React 19.2.8, ui-kit 1.4.0 ← New FynAppsshare it, or bring another major

Try it

  1. Pick the federated CWP release, then pick Legacy CWP or Federated CWP for each set. Each set is its own RequireJS context with the same widget bundles, which were built against React 18. The legacy CWP is the old setup: UMD React 18 files and legacy-components/dist/ui-kit.js. CWP 3 and CWP 4 serve React 18 or React 19 and ui-kit from federation, as the Files fetched table shows.
  2. Load Team C in a set. RequireJS fetches only widget-c.js and reuses the React that set already loaded.
  3. Check the React instances table. Each row is one copy of React, the apps that use it, and how many times its file was fetched. Two federated sets share one copy. Two legacy sets get one copy each.
The federated CWP release. A page runs one, and every federated set uses it.

Set 1: unchanged webpack AMD bundles

Team C is not loaded yet.

Set 2: unchanged webpack AMD bundles

Team C is not loaded yet.

FynApps on the same page

Two ordinary FynApps that import esm-react through federation. They know nothing about RequireJS or the legacy widgets.

Loads after the legacy widgets.
Loads after the legacy widgets.

React instances on this page

Reactloaded fromused byfiles fetched

Files fetched

atsetkindfile

Dependency graph

Set 1

Set 2

AMD add-on metrics

amd.* entries from kernel telemetry. They are the input for generating preload meta later.

entrysetidroutedepsmsurl