Skip to content

fix: handle side-effect only modules in normalizeRuntimeShare#718

Merged
gioboa merged 2 commits into
module-federation:mainfrom
simonihmig:fix-normalize-runtime-share
May 18, 2026
Merged

fix: handle side-effect only modules in normalizeRuntimeShare#718
gioboa merged 2 commits into
module-federation:mainfrom
simonihmig:fix-normalize-runtime-share

Conversation

@simonihmig
Copy link
Copy Markdown
Contributor

This is fixing an issue if your shared deps cover a module without exports (only side-effects). Ran into this when sharing lit/ which covers lit/polyfill-support. The browser seems to expose this with an (empty) special module namespace object as default. The __mfNormalizeRuntimeShare function would then return this one instead of the original module object. In the const exportModule = normalizedModule === mod ? {...mod} : normalizedModule; statement, normalizedModule would not be equal to mod, so it would try to defineProperty on that namespace object, which fails as that is a exotic esm object that you cannot mutate.

This can be reproduced when adding lit/ in the lit example app here.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 18, 2026

Open in StackBlitz

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

commit: 61743fc

Copy link
Copy Markdown
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

Tests With Different Frameworks

Screenshot 2026-05-18 at 12 04 19

@gioboa gioboa merged commit 5f86506 into module-federation:main May 18, 2026
19 checks passed
Copy link
Copy Markdown
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

Thanks for your amazing help @simonihmig

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.

2 participants