Skip to content

runtime-core: loadShare fails after dynamic registerShared() #4952

Description

@dmchoi77

Describe the bug

ModuleFederation.registerShared() registers a shared provider in shareScopeMap, but does not update instance.options.shared.

This leaves the runtime in an inconsistent state: the provider exists in shareScopeMap, but the shared configuration is missing from instance.options.shared.

When loadShare() is called after dynamic registration, it cannot reliably resolve the newly registered shared module and may throw:

targetShared.get is not a function

The issue can be reproduced with @module-federation/runtime-core@2.8.1 using the reproduction repository below.

I intend to submit a fix for this issue in PR #4950.

Reproduction

https://github.com/dmchoi77/runtime-core-register-shared-repro

Used Package Manager

pnpm

System Info

OS: macOS
Node.js: v22.22.0
pnpm: 10.28.0
Package: @module-federation/runtime-core@2.8.1

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