This is a demo app based on https://github.com/module-federation/module-federation-examples/tree/master/advanced-api/dynamic-remotes, to reproduce the issue module-federation/core#2541.
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/runtimepackage)
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.