Skip to content

Singletons bundled in two instances due to relative/absolute import path usage #5042

Description

@MatissJanis

Describe the bug

This is a tricky edge-case that becomes apparent when enabling Module Federation for large monorepos (>18m LOC). Attached is a simplified reproduction showcasing the problem.

A module-level React context is shared as a singleton, yet ends up as two instances across host and remote compilations. Module Federation negotiates sharing by request specifier, not resolved file identity — relative imports never match the canonical share key.

Related:

Reproduction

https://github.com/MatissJanis/module-federation-singleton-import-issue/tree/master

Used Package Manager

npm

System Info

System:
    OS: macOS 26.5.2
    CPU: (16) arm64 Apple M4 Max
    Memory: 4.05 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.14.1 - /Users/matissjanis.aboltins/.volta/tools/image/node/24.14.1/bin/node
    Yarn: 1.22.22 - /Users/matissjanis.aboltins/.yarn/switch/bin/yarn
    npm: 11.11.0 - /Users/matissjanis.aboltins/.volta/tools/image/node/24.14.1/bin/npm
    pnpm: 10.30.3 - /Users/matissjanis.aboltins/.volta/tools/image/node/24.14.1/bin/pnpm
    bun: 1.3.6 - /Users/matissjanis.aboltins/.bun/bin/bun
    Watchman: 2026.05.25.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 152.0.7977.82
    Safari: 26.5.2

Validations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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