Repository navigation
TanStack Start compatibility and support #498
Description
Describe the bug
Context
I'm integrating @module-federation/vite with TanStack Start. I've created a minimal reproduction repository demonstrating the issue:
Repository: https://github.com/alexandre-marchina/tanstack-start-with-module-federation
The Problem
When using Module Federation with TanStack Start, the application crashes during SSR:
TypeError: Cannot destructure property 'Activity' of 'exportModule' as it is undefined.
at eval (.vite/deps_ssr/host__loadShare__react__loadShare__*.js)
I noticed that PR #474 added SSR support for Vinext using framework detection. Perhaps some of the fixes that were added could be reused in other scenarios?
But I may be missing something here since I'm not very familiar with this topic
Reproduction
The repository contains two host configurations:
ts-host/- MF config withhostInitInjectLocation: "entry"(crashes)ts-host-with-CSR-remotes/- With additional custom workarounds (works)
Steps:
- Start remotes (
ts-remote-bff,ts-remote-simple) - Start
ts-host→ crashes on first SSR request - Compare with
ts-host-with-CSR-remotes→ works
Questions
-
Is TanStack Start within scope for this plugin?
-
Are there configuration options I might be missing that would address this?
- I've reviewed
hostInitInjectLocation,target, andsharedoptions
- I've reviewed
Environment
@module-federation/vite: 1.13.0vite: 8.0.0@tanstack/react-start: 1.166.16- Node.js: 24.x
Version
1.13.0
Reproduction
https://github.com/alexandre-marchina/tanstack-start-with-module-federation
Relevant log output
TypeError: Cannot destructure property 'Activity' of 'exportModule' as it is undefined.
at eval (.vite/deps_ssr/host__loadShare__react__loadShare__*.js)Validations
- Read the docs.
- Read the common issues list.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- The provided reproduction is a minimal reproducible example of the bug.
Activity
gioboa commentedon Mar 18, 2026
Thanks for your help, I can use the reproduction repo to support TanStack Start too. Btw here I have the pipeline to tests the updates. I created a TanStack example too.
gioboa commentedon Mar 26, 2026
Blocked by TanStack/router#7032
So I'm closing this issue for now. Looking forward to seeing this working.
gioboa commentedon May 3, 2026
Here is a basic example https://github.com/rr-jimmy-multani/rr-tanstack-poc
You can use it to verify and improve the mfe/vite library.
gioboa commentedon May 15, 2026
Full SSR rendering support example
jsg2021 commentedon Jun 17, 2026
@gioboa How did you get past tanstack start's compiler not able to access the host shared virtual modules?
gioboa commentedon Jun 17, 2026
Hi @jsg2021
What are the differences between your and the example above?
jsg2021 commentedon Jun 17, 2026
@gioboa good question. I've basically grabbed the federation / nitro config sections from your example and added them to my app, minus remotes... I was just hoping to start with a booting app and work my way towards pulling in remotes and exposing components. But I think I need the compiler changes from TanStack/router#6783
gioboa commentedon Jun 18, 2026
Can you share a basic example that shows the issue?
jsg2021 commentedon Jun 18, 2026
In an attempt to create an example...
I just tried to create a new project with tanstack's create command, then applied these changes (same changes from my internal app) and it works here :/ I'm going to dig further. I'm not sure whats different.
jsg2021 commentedon Jul 14, 2026
Found why the test repo works and my main one does not. I have server functions that reference shared libraries.
Snippet from claude:
The
server-fn:clientplugin transforms any module whose source contains server-fn markers (createServerFn,.handler,.validator, …). To classify each call expression,StartCompilercrawls the import graph —resolveImportKind→resolveIdCached(source)→getModuleInfo— following import bindings module-to-module (compiler.js:869-893).When that crawl reaches one of your shared singletons (
react,react-dom,@tanstack/react-router), the@module-federation/viteplugin has rewritten the import target into an internal virtual module —virtual:mf:__mfe_internal__hub__loadShare__react__loadShare__.js. The compiler'sloadModule(in dev:environment.transformRequest(id + '?server-fn-module-lookup'); start-compiler-plugin/plugin.js:151) never populates the compiler'smoduleCachefor that MF virtual id, sogetModuleInfothrows.gioboa commentedon Jul 14, 2026
Please open an issue for that, thanks
jsg2021 commentedon Jul 14, 2026
while my instinct is for this to fix, the problem actually is a missing entry in tan-stack start's moduleCache which is not 'vite'.
this is probably the proper solution:
TanStack/router#6783
gioboa commentedon Jul 14, 2026
Can you share with me a reproduction repo to show the problem?
jsg2021 commentedon Jul 14, 2026
https://github.com/jsg2021/vite-mf-repro