Describe the bug
This is a tricky edge-case that becomes apparent when enabling Module Federation for large monorepos (>18m LOC). Attached is a simplified reproduction showcasing the problem.
A module-level React context is shared as a singleton, yet ends up as two instances across host and remote compilations. Module Federation negotiates sharing by request specifier, not resolved file identity — relative imports never match the canonical share key.
Related:
Reproduction
https://github.com/MatissJanis/module-federation-singleton-import-issue/tree/master
Used Package Manager
npm
System Info
System:
OS: macOS 26.5.2
CPU: (16) arm64 Apple M4 Max
Memory: 4.05 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.14.1 - /Users/matissjanis.aboltins/.volta/tools/image/node/24.14.1/bin/node
Yarn: 1.22.22 - /Users/matissjanis.aboltins/.yarn/switch/bin/yarn
npm: 11.11.0 - /Users/matissjanis.aboltins/.volta/tools/image/node/24.14.1/bin/npm
pnpm: 10.30.3 - /Users/matissjanis.aboltins/.volta/tools/image/node/24.14.1/bin/pnpm
bun: 1.3.6 - /Users/matissjanis.aboltins/.bun/bin/bun
Watchman: 2026.05.25.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 152.0.7977.82
Safari: 26.5.2
Validations
Describe the bug
This is a tricky edge-case that becomes apparent when enabling Module Federation for large monorepos (>18m LOC). Attached is a simplified reproduction showcasing the problem.
Related:
Reproduction
https://github.com/MatissJanis/module-federation-singleton-import-issue/tree/master
Used Package Manager
npm
System Info
System: OS: macOS 26.5.2 CPU: (16) arm64 Apple M4 Max Memory: 4.05 GB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 24.14.1 - /Users/matissjanis.aboltins/.volta/tools/image/node/24.14.1/bin/node Yarn: 1.22.22 - /Users/matissjanis.aboltins/.yarn/switch/bin/yarn npm: 11.11.0 - /Users/matissjanis.aboltins/.volta/tools/image/node/24.14.1/bin/npm pnpm: 10.30.3 - /Users/matissjanis.aboltins/.volta/tools/image/node/24.14.1/bin/pnpm bun: 1.3.6 - /Users/matissjanis.aboltins/.bun/bin/bun Watchman: 2026.05.25.00 - /opt/homebrew/bin/watchman Browsers: Chrome: 152.0.7977.82 Safari: 26.5.2Validations