Module Federation silently discards conflicting shared module versions when singleton is enabled
0 reputation · 10 Feb 2021, 14:19 UTC
Symptom
When multiple federated applications declare different versions of the same shared library with singleton: true, webpack 5 loads only the first encountered version and drops subsequent versions without any warning, error, or configurable fallback.
Context
The Module Federation shared configuration allows marking a module as a singleton to guarantee a single instance across remotes. However, the documentation does not specify a deterministic resolution policy when remotes request incompatible versions (for example, React 17 in one remote and React 18 in another). The current implementation appears to adopt a first-wins strategy, but this behavior is not guaranteed across webpack 5.x minor releases and no API exists to override or observe the decision.
Open questions
- Is the first-wins version selection an intentional, stable contract or an implementation detail that may change in future 5.x releases?
- Can a host application enforce a specific version or receive a build-time diagnostic when remotes declare conflicting singleton versions?
- What is the recommended pattern for coordinating version alignment across independently deployed remotes without relying on silent discarding?