feat: strengthen SSR federation (dev parity, shared strategy, resilience)#4
Merged
Conversation
…nce) - Gate server federation on a new `ssr` module option (default true) and the app's ssr setting, instead of hard-disabling it in dev. Dev-mode MF SSR activates automatically on Vite 8+ (Nuxt's next minor); on Vite 7 it falls back to client-only remotes with an informative log, since the ssrEntryLoader ModuleRunner path requires Vite 8 and hangs on older versions. - Inject a shared-strategy runtime plugin (loaded-first) into both the client and server federation configs so an already-loaded shared module (e.g. the host's Vue) is reused across remotes. - Restructure config assembly into a patchMFConfig step with per-target runtime-plugin injection and dedupe. - Warn at build time when a remote manifest's shared dependency versions diverge from the host's installed versions, since the Vite server side has no share-scope version negotiation. - Degrade gracefully when a remote fails to load during SSR: render nothing on the server and let the client render it after hydration instead of failing the whole server render. - Fix missing CORS headers on the root-level remoteEntry.js copy that the rebased manifest points browsers at (pre-existing bug surfaced by browser-level verification).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Strengthens the module's SSR federation so remote components are truly server-rendered wherever the toolchain allows it, and degrade predictably where it doesn't.
Changes
ssrmodule option (defaulttrue) replaces the hard!nuxt.options.devgate. Server federation is now controlled by the option and the app'sssrsetting, not by dev vs prod.@module-federation/vitessrEntryLoaderdev path (ModuleRunner over/__mf_runner__) requires Vite 8+, and on Vite 7 it deadlocks the SSR render (verified empirically). On Vite 7 (current Nuxt) dev falls back to client-only remotes with an info log; when Nuxt ships Vite 8 next minor, dev upgrades to real MF SSR automatically.shared-strategyruntime plugin (new@module-federation/nuxt/shared-strategyexport) forcingloaded-firston all shared deps, injected into both the client and server federation configs, so an already-loaded shared module (e.g. the host's Vue instance) is reused across remotes instead of re-negotiated.patchMFConfig(config, isServer)with runtime-plugin injection/dedupe. Configs stay lazy inside the Vite plugin factories because exposed components are collected by Nuxt hooks after module setup.remoteEntry.jscopy that the rebased manifest points browsers at (pre-existing bug onmain; client-side federation failed withRUNTIME-015in the browser while all curl-level checks passed).Verification
Playwright (Chromium) against the example apps:
Widget/Countermarkup present in the raw SSR HTML, both components visible after hydration, no hydration mismatch warnings, no console errors, buttons interactive.Plus
tsc --noEmit, package build, and full builds of both example apps.Caveat
The dev-mode true-MF-SSR path is implemented but can't be exercised until Nuxt ships Vite 8 — it should be re-verified in dev when that lands.