-
-
Notifications
You must be signed in to change notification settings - Fork 349
Description
Describe the bug
I am using the Advanced API Dynamic Remotes example: https://github.com/module-federation/module-federation-examples/tree/master/advanced-api/dynamic-remotes, and trying out the Webpack version (pnpm legacy:start
).
I wanted to try loading the apps when:
- Remotes use Module Federation v1 (from Webpack)
- Host also uses Module Federation v1 (from Webpack) at build time to defined
shared
(but notremotes
) - Host loads Remotes at runtime (using
@module-federation/runtime
package)
I have created the minimum required to reproduce it at https://github.com/markmssd/module-federation-runtime-shared. You can try it with pnpm start:legacy
. The only difference between this reproducible and the official example is that in the Webpack configs, I am using the Webpack MF plugin from require('webpack').container.ModuleFederationPlugin
, and uninstalled @module-federation/enhanced
completely.
It seems like it doesn't load the shared dependencies properly. First, when we start the app, and log __FEDERATION__
in the developer console, it shows no shared dependencies.

Then, if we load App3, it crashes with

which is usually an error when multiple instances of React are used.
Note what loading App2 works just fine, not sure why. The only difference with it is that it also shares moment
, so not sure, I would have expected it to crash too 🤔
I've also noticed that if I define the shared dependencies on runtime too in App1 (and I can then remove MF plugin completely from its Webpack), then it works properly. I guess this is expected, obviously.
My question is, shouldn't the shared dependencies defined with MF v1 (using require('webpack').container.ModuleFederationPlugin
in Webpack) be detected by the Runtime MF in the host as well?
I'd be happy to open a PR with some guidance if this is indeed a bug and not expected. Let me know!
Reproduction
https://github.com/markmssd/module-federation-runtime-shared
Used Package Manager
pnpm
System Info
The command fails, but I am on `MacOS M1`, `Chrome v125`
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.