-
-
Notifications
You must be signed in to change notification settings - Fork 372
Description
Describe the bug
We are using Module Federation in a monorepo setup with rslib and rsbuild. We are successfully sharing and consuming modules in a shared scope. However, we have encountered a critical issue with sharing singleton dependencies when their version numbers contain a postfix (e.g., 2.2.2-release.99).
When a shared library has a version with a postfix, Module Federation does not treat it as a shared singleton. Instead, each remote application loads its own separate instance of the dependency, defeating the purpose of sharing and potentially causing runtime errors (e.g., multiple instances of React, broken context providers).
This behavior is inconsistent. If we remove the postfix and use a standard semantic version (e.g., 2.2.2), the sharing mechanism works perfectly as expected.
Shared
// Remote config (sharing the module)
shared: {
'my-shared-library': {
singleton: true,
requiredVersion: '2.2.2-release.99', // Version with postfix
},
},
Consume
shared: {
'my-shared-library': {
requiredVersion: '*', // Willing to accept any version
},
},
Reproduction
Share module: requiredVersion: '2.2.2-release.99', // Version with postfix, Consume: requiredVersion: '*',
Used Package Manager
pnpm
System Info
System:
OS: macOS 15.6.1
CPU: (12) arm64 Apple M3 Pro
Memory: 111.97 MB / 18.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 18.20.7 - ~/.nvm/versions/node/v18.20.7/bin/node
npm: 10.8.2 - ~/.nvm/versions/node/v18.20.7/bin/npm
Browsers:
Chrome: 139.0.7258.128
Safari: 18.6
Validations
- Read the docs.
- Read the common issues list.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Module federation issue and not a framework-specific issue.
- The provided reproduction is a minimal reproducible example of the bug.