-
-
Notifications
You must be signed in to change notification settings - Fork 358
Open
Description
Describe the bug
Hello :)
Module federation tracks shared dependencies with the global object window.__FEDERATION__.__SHARE__
. There can be issues with the loaded
property, which tracks which dependency is loaded.
It happens for the react
dependency with the following configuration:
shared: {
react: {
singleton: true,
eager: true,
requiredVersion: '^18.3.1',
},
'react-dom': {
singleton: true,
eager: true,
requiredVersion: '^18.3.1',
},
},
At runtime we can see that react
is not marked as loaded:

BUT
If I remove react-dom
from the shared dependencies, it works:

Expected vs actual behavior
react
should be marked as loaded: true
even when having react-dom
as a shared dependency.
When it works
The configuration works when:
- I have only
react
as a shared dependency

- I have
react
andlodash
as a shared dependencies

- I have
react
andreact-is
as shared dependencies

Reproduction steps
- Clone my repository:
git clone [email protected]:romain-trotard/core.git
- Go in the cloned repository:
cd core
- Checkout the branch
reproduction-useIn
:git checkout reproduction-loaded
- Install dependencies:
pnpm i
- Build everything:
pnpm build
- Run:
pnpm -w run nx run react_ts_remote:serve:webpack
- Go to: http://127.0.0.1:3005/
- In the devtool log:
window.__FEDERATION__.__SHARE__['react_ts_remote:0.0.0'].default
- You can see that
react
is not marked as loaded
Similar issue
Thanks for the fix of this issue #3864
Reproduction
https://github.com/romain-trotard/core/tree/reproduction-loaded
Used Package Manager
pnpm
System Info
System:
OS: macOS 15.6
CPU: (10) arm64 Apple M1 Pro
Memory: 560.20 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - ~/.volta/tools/image/node/22.14.0/bin/node
Yarn: 1.22.22 - ~/.volta/tools/image/yarn/1.22.22/bin/yarn
npm: 10.9.2 - ~/.volta/tools/image/node/22.14.0/bin/npm
pnpm: 10.12.4 - ~/.volta/bin/pnpm
Browsers:
Chrome: 138.0.7204.184
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.
marzelc
Metadata
Metadata
Assignees
Labels
No labels