Skip to content

fix: publish SSR federation artifacts in multi-environment builds#859

Merged
gioboa merged 4 commits into
module-federation:mainfrom
tonoizer:codex/fix-multi-env-ssr-federation
Jun 26, 2026
Merged

fix: publish SSR federation artifacts in multi-environment builds#859
gioboa merged 4 commits into
module-federation:mainfrom
tonoizer:codex/fix-multi-env-ssr-federation

Conversation

@tonoizer

@tonoizer tonoizer commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Fix SSR federation artifacts in multi-environment builds

What changed

  • Skip browser manifest emission from the ssr environment so it cannot overwrite the client manifest.
  • From the SSR environment's writeBundle hook, publish only the SSR remote entry's reachable chunk graph to the client-served output directory.
  • Use a Node-version guard for SSR runtime initialization and entry loading, which remains correct when a DOM shim defines window on the server.

Why

In environment-split SSR builds, the SSR manifest can replace the public manifest even though it references SSR-only chunks. The advertised SSR entry can also be emitted only into an unserved SSR output directory. Both cases can make browser or server remote loading fall back to incompatible code. Publishing from writeBundle works when frameworks such as Nitro orchestrate Vite environments themselves, and walking both output metadata and emitted source keeps the publication graph complete without copying unrelated server output.

Validation

  • pnpm typecheck
  • pnpm test (580 tests)
  • pnpm test:integration (34 tests)
  • pnpm e2e (19 Playwright tests)

@tonoizer tonoizer force-pushed the codex/fix-multi-env-ssr-federation branch from e8e6583 to 7b8c1ae Compare June 26, 2026 11:41
@pkg-pr-new

pkg-pr-new Bot commented Jun 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 917a3ea

@tonoizer tonoizer force-pushed the codex/fix-multi-env-ssr-federation branch from 7b8c1ae to d0e8d0d Compare June 26, 2026 13:53
@tonoizer tonoizer changed the title [codex] Fix SSR federation artifacts in multi-environment builds fix: publish SSR federation artifacts in multi-environment builds Jun 26, 2026
@tonoizer tonoizer marked this pull request as ready for review June 26, 2026 14:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0e8d0d17c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/plugins/pluginSSRRemoteEntry.ts Outdated

@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.

It looks great to me @tonoizer
that's a small suggestion to fix.

Comment thread src/plugins/pluginSSRRemoteEntry.ts Outdated

@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 @tonoizer for this great refinement 👍

@gioboa gioboa merged commit 907c08d into module-federation:main Jun 26, 2026
19 checks passed
@tonoizer

Copy link
Copy Markdown
Contributor Author

No problem was my pleasure to help

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