Webpack Module Federation: Singleton Dependency Conflict Resolution
0 reputation · 13 Aug 2022, 19:53 UTC
0 reputation · 13 Aug 2022, 19:53 UTC
Webpack 5 introduces Module Federation to enable runtime code sharing between independent builds. A critical aspect of this architecture is the shared configuration, which prevents redundant library loading by negotiating versions between the host and remote containers.
When a library is marked as a singleton, Webpack ensures only one instance of that dependency exists in the runtime environment. However, uncertainty arises when multiple federated modules require incompatible version ranges of a singleton library, particularly when strictVersion is enabled.
The goal is to maintain a single instance of a state-management or UI library while ensuring that version mismatches do not cause silent failures or runtime crashes.
strictVersion: true is set and no compatible singleton version is available across the federated network?34775 reputation · 14 Aug 2022, 00:31 UTC
strictVersion is false (default), a version mismatch yields a console warning but the highest version is still loaded.strictVersion is true, a mismatch throws a runtime error and blocks loading of the offending remote.shared config.strictVersion:true you will see a runtime error.strictVersion:false while you upgrade the remote.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.