-
-
Notifications
You must be signed in to change notification settings - Fork 372
Description
Describe the bug
The repository demonstrates a critical issue with pure runtime Module Federation:
Summary:
when using @module-federation/runtime on the host and plugin-built remoteEntries, the host's share scope is not initialized, leading to multiple React instances and hook errors. The same configuration works as expected when using the build plugin on the host, suggesting an issue in how the runtime API participates (or doesn't) in share scope initialization.
- The hostbuildtime application (using Module Federation at build time) shows correct initialization of webpack share scopes, and shared dependencies like React work as expected.
- The hostruntime application attempts to use createInstance from the Module Federation runtime to load remotes (app2, app3) at runtime, but the webpack share scope is empty. This causes React sharing to fail, resulting in an "invalid hook call" error when loading and rendering remote components.
I have tried providing shared dependencies directly under the shared option of createInstance, and also using mf.registerShared, but the problem persists. The share scope object (webpack_share_scopes) remains empty, and singletons like React are not correctly shared.
Brief Reproduction:
- Clone the repo and install dependencies: npm install
- Start all applications: npm run start
- Access the following apps in your browser:
- hostbuildtime: http://localhost:3000/ — works as expected
- hostruntime: http://localhost:3001/ — produces React sharing error on loading a remote widget
- app2: http://localhost:3002/
- app3: http://localhost:3003/


Reproduction
https://github.com/GururajChadaga/mf-dynamic-remotes-pure-runtime
Used Package Manager
npm
System Info
System:
OS: macOS 15.6.1
CPU: (10) arm64 Apple M4
Memory: 272.31 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.17.0 - /usr/local/bin/node
Yarn: 1.22.22 - ~/myorg/myorg/node_modules/.bin/yarn
npm: 11.4.2 - /usr/local/bin/npm
pnpm: 10.12.4 - /usr/local/bin/pnpm
Browsers:
Chrome: 140.0.7339.133
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.