Context
The agency, talent and casting apps share one component library through Module Federation. Each app fetches the library's manifest at runtime and loads only the components it uses. A library deploy reaches every app on its users' next page load, with no version pin and no staged rollout. With two other leads, I set the structure of both library generations, and I look after both in production.
Constraints
- Two library generations are live at once: the older one built on React 18, the newer one on React 19.
- React, React DOM and Emotion are strict singletons. A version mismatch is a white screen, not a warning.
- Each app deploys on its own; nothing coordinates a library release with the apps that load it.
- Test, staging and prod each map to their own branch, in every repo.
Decisions
Open each one for the trade-off behind it.
What I built
- Cache rules for both library hosts: manifest, stats and index never cached.
- A branch precheck chained into every deploy command, live on prod in 4 repos.
- A leaner chunk build: shared JSX and compiler runtimes, and one theme chunk instead of a copy per component.
- The loaded-first share strategy that lets local apps run against the deployed library.
Result
The live manifest now answers cache-control: no-cache, so a library deploy no longer leaves apps asking for chunks that are gone. The median icon chunk dropped from 6,624 to 2,604 bytes, with one React instance across the share scope. Two things are still open: every component is still its own request, about 150 on the busiest page measured, and hashed chunks are cached for an hour instead of marked immutable.
What I'd do differently
Ship the cache rules with the first deploy. I had them written in July and left them uncommitted; they shipped after the ChunkLoadError reached production in August. A fix isn't done until it's a pull request.