Skip to content

Production build emits invalid ssr_exports reference in bundled SSR chunk (TanStack Start, any preset) #4533

Description

@ayaasartan

Summary

Building a TanStack Start app for production with any recent nitro beta produces a bundled SSR chunk that references an export (ssr_exports) which is never declared or imported in that module, causing a SyntaxError the moment the module is loaded at runtime.

Environment

  • nitro: reproduced on 3.0.260311-beta, 3.0.260603-beta, and 3.0.260610-beta (the three most recent date-stamped betas at time of writing)
  • vite: 8.2.1
  • @tanstack/react-start: 1.168.46
  • @tanstack/start-client-core: 1.170.24
  • Node: 22.22.2
  • Reproduced with both the default (node-server) preset and the vercel preset — not preset-specific.

Steps to reproduce

  1. A standard TanStack Start app using createServerFn (any number of server functions is enough — this is not specific to CSRF middleware; removing createCsrfMiddleware from src/start.ts does not avoid the bug).
  2. npm run build
  3. Inspect .output/server/_ssr/ssr.mjs (or the equivalent chunk under .vercel/output/functions/__server.func/_ssr/ when building with NITRO_PRESET=vercel).

Actual result

The generated chunk contains an export statement like:

export { getResponseHeaders as a, ssr_exports as c, createServerEntry, server_default as default, getCookies as i, createCsrfMiddleware as l, TSS_SERVER_FUNCTION as n, setCookie$1 as o, getServerFnById as r, setResponseHeader as s, createServerFn as t, createMiddleware as u };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions