fix: framework-agnostic remote exports, deferred loaded-first, and unified SSR gates#742
Conversation
Await real remote modules for SSR and version-first; defer loaded-first on the client only. Centralize ssrEntryLoader and dev SSR bootstrap in getSsrCapabilities. Co-authored-by: Cursor <[email protected]>
Bring in getRemoteFromId for scoped/overlapping remote names and React lazy-safe proxies from main, while keeping framework-agnostic deferred exports for loaded-first and Nuxt dev entry.mount init injection. Co-authored-by: Cursor <[email protected]>
Emit separate client and server remote virtual modules when environments.ssr is active, with unified typeof-window fallback for single-environment setups. Include shareStrategy in remote wrapper cache keys. Skip duplicate SvelteKit host-init injection when HTML is patched twice. Co-authored-by: Cursor <[email protected]>
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a599a737ad
βΉοΈ 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".
commit: |
Use a thenable that starts loadRemote only when awaited so dynamic import() waits for the real module without eager fetch on static import. Co-authored-by: Cursor <[email protected]>
Extend loaded-first client deferral to production builds (SSR still awaits the real module). Cache remote virtual modules by consumer so client and server wrappers are not overwritten. Introduce RemoteInitMode for clarity. Co-authored-by: Cursor <[email protected]>
|
@gioboa Do I need to change additional things or is this PR alright? |
gioboa
left a comment
There was a problem hiding this comment.
Unfortunately this PR is adding top level awaits and this is problematic with Nuxt and other frameworks. Can you replace TLAs with a chain of promises? We are already doing that in the codebase.
Resolve virtualShared_preBuild.ts: keep lazy workspace singleton exports (promise chains, no TLA) alongside upstream loadShare materialization helpers. Co-authored-by: Cursor <[email protected]>
Resolve conflicts in index.ts, virtualRemotes.ts, and tests while keeping framework-agnostic remote wrappers and SSR capability gates. Co-authored-by: Cursor <[email protected]>
4294cda to
e047da7
Compare

Proxywith real module resolution (__mfUnwrapRemoteDefault+ top-levelawait) for build,version-firstdev, and SSR.shareStrategy: 'loaded-first'via a minimal framework-agnostic proxy (__mfCreateDeferredRemoteProxy); SSR still awaits the real remote module.getSsrCapabilities()sossrEntryLoaderinjection and dev SSR bootstrap stay aligned (Vite 8+ dev; build/preview on all supported Vite majors).*.exposes.jsover HTTP in dev for SSR fetch chains (builds on fix(ssr): load federated remotes in general Vite SSR setupsΒ #723).Motivation
The previous React-only proxy fixed
React.lazy/ hydration quirks but was wrong for SSR (a proxy is not a real module) and blocked other frameworks. A single always-awaitpath also regressedloaded-first, which must not callloadRemoteuntil a remote export is actually read on the client.This PR keeps one await-based path for SSR and
version-first, and only defers on the browser whenshareStrategy: 'loaded-first'.Examples branch (manual verification)
Validated against the SSR examples on: https://github.com/tonoizer/module-federation-vite-examples/tree/feat/ssr-vue-react-demos
(
vue-ssr,react-ssr,tanstack,nuxtβ build, preview, dev, Playwright; defaultversion-first, noshareStrategyrequired in demos)