pnpm workspace for testing Rsbuild Module Federation with TanStack Start SSR.
apps/host: CSR Rsbuild React host on port3000apps/remote-ssr: SSR TanStack Start remote on port3001apps/remote-csr: CSR Rsbuild React remote on port3002packages/tanstack-start: local@module-federation/tanstack-startRsbuild helper package
pnpm install
pnpm devpnpm dev runs all three app servers through Turbo:
- host:
http://localhost:3000 - SSR remote:
http://localhost:3001 - CSR remote:
http://localhost:3002 - CSR remote manifest:
http://localhost:3002/mf-manifest.json - SSR remote container:
http://localhost:3001/serverRemoteEntry.cjs
The host consumes:
csr_remote@http://localhost:3002/mf-manifest.jsonand imports:
import('csr_remote/FederatedBadge')The host view intentionally shows both remote render paths:
- SSR:
http://localhost:3001/ssr-remotedisplayed inside the host. - CSR:
csr_remote/FederatedBadgeloaded through Module Federation.
pnpm typecheck
pnpm test
pnpm build
pnpm previewThe SSR remote uses @module-federation/tanstack-start to install both Module
Federation compilers:
- web target for the browser manifest and
remoteEntry.js - node target for the SSR container and
serverRemoteEntry.cjs
The helper also patches the TanStack Start SSR compiler output to CommonJS chunk names so the node federation runtime can load exposed modules during SSR.
SSR remote exposure:
pluginTanStackStartModuleFederation({
federation: {
name: 'ssr_remote',
exposes: {
'./SsrRemotePanel': './src/components/SsrRemotePanel.tsx',
},
shared: {
react: { singleton: true },
'react-dom': { singleton: true },
},
},
})CSR remote exposure:
pluginModuleFederation({
name: 'csr_remote',
exposes: {
'./FederatedBadge': './src/FederatedBadge.tsx',
},
})Host remote:
pluginModuleFederation({
name: 'tanstack_host',
remotes: {
csr_remote: 'csr_remote@http://localhost:3002/mf-manifest.json',
},
shared: {
react: { singleton: true },
'react-dom': { singleton: true },
},
})pnpm build
pnpm previewThe SSR remote preview server serves the TanStack Start SSR app from
apps/remote-ssr/dist/server/index.cjs and static client/federation assets from
apps/remote-ssr/dist/client.