Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: use share scope in loadShare cache key to prevent cross-scope collisions#822

Merged
gioboa merged 3 commits into
module-federation:mainfrom
RalphK66:fix/scope-aware-cache-key-v2
Jun 16, 2026
Merged

fix: use share scope in loadShare cache key to prevent cross-scope collisions#822
gioboa merged 3 commits into
module-federation:mainfrom
RalphK66:fix/scope-aware-cache-key-v2

Conversation

@RalphK66

Copy link
Copy Markdown
Contributor

Closes #821

…llisions

When multiple share scopes exist on the same page (e.g., react-18 and
react-19 for cross-major React isolation via bridge components), the
loadShare flat cache key ignores the scope. Whichever scope populates
the cache first wins — all subsequent lookups return the wrong version.

Prefix cache keys with `shareItem.scope:` (defaults to "default:") so
scoped singletons like react-18:react and react-19:react don't collide.
Also emit a runtime helper (__mfGetSharedCacheKey) for the three inline
cache-key sites in virtualRemoteEntry that can't call the build-time
getSharedCacheKey().

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@RalphK66 RalphK66 changed the title fix: use share scope in loadShare cache key to prevent cross-scope co… fix: use share scope in loadShare cache key to prevent cross-scope collisions Jun 15, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 16, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@module-federation/vite@822

commit: cc769b5

@gioboa gioboa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests With Different Frameworks

Image

@gioboa gioboa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @RalphK66 that's a nice fix 🎉

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: loadShare cache key ignores share scope — breaks multi-scope setups

3 participants