Skip to content

window.__FEDERATION__.__SHARE__ has incorrect loaded value for some shared dependency #3987

@romain-trotard

Description

@romain-trotard

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:

React not marked as loaded

BUT

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

Without react-dom 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
react as shared dependency
  • I have react and lodash as a shared dependencies
react and lodash as shared dependencies
  • I have react and react-is as shared dependencies
react and react-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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions