Skip to content

Commit ce61fa2

Browse files
fix(start): explicitly re-export public API to survive SSR cold-start cycle (#7466)
1 parent e2896b5 commit ce61fa2

4 files changed

Lines changed: 52 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@tanstack/react-start': patch
3+
'@tanstack/solid-start': patch
4+
'@tanstack/vue-start': patch
5+
---
6+
7+
Explicitly re-export public API names from `@tanstack/start-client-core` (`createServerFn`, `createMiddleware`, `createStart`, `createCsrfMiddleware`, `createIsomorphicFn`, `createClientOnlyFn`, `createServerOnlyFn`) alongside the existing `export *`. The explicit named re-exports are registered at link time (via Vite SSR's `defineExport` at `fileStartIndex`), so the namespace has these getters before any import body runs — survives the cold-start SSR cycle through user middleware where `export *` would otherwise produce a partial facade (`createMiddleware is not a function`). Workaround for vitejs/vite#22491 / #22493.

packages/react-start/src/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
export { useServerFn } from './useServerFn'
22
export * from '@tanstack/start-client-core'
3-
export { createServerFn } from '@tanstack/start-client-core'
3+
// Explicit re-exports shadow `export *` above so these public-API names are
4+
// registered on the namespace at link time (via Vite SSR's `defineExport`
5+
// at fileStartIndex), surviving the cold-start SSR cycle through user
6+
// middleware. See vitejs/vite#22491 / #22493. Trim list to genuine public
7+
// API only; internals fall through `export *` and are safe because they
8+
// aren't imported at top level in the cycle path.
9+
export {
10+
createClientOnlyFn,
11+
createCsrfMiddleware,
12+
createIsomorphicFn,
13+
createMiddleware,
14+
createServerFn,
15+
createServerOnlyFn,
16+
createStart,
17+
} from '@tanstack/start-client-core'
418
export { Hydrate } from '@tanstack/react-start-client'
519
export type {
620
HydrateOptions,

packages/solid-start/src/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
export { useServerFn } from './useServerFn'
22
export * from '@tanstack/start-client-core'
3+
// Explicit re-exports shadow `export *` above so these public-API names are
4+
// registered on the namespace at link time (via Vite SSR's `defineExport`
5+
// at fileStartIndex), surviving the cold-start SSR cycle through user
6+
// middleware. See vitejs/vite#22491 / #22493. Trim list to genuine public
7+
// API only; internals fall through `export *` and are safe because they
8+
// aren't imported at top level in the cycle path.
9+
export {
10+
createClientOnlyFn,
11+
createCsrfMiddleware,
12+
createIsomorphicFn,
13+
createMiddleware,
14+
createServerFn,
15+
createServerOnlyFn,
16+
createStart,
17+
} from '@tanstack/start-client-core'
318
export { Hydrate } from '@tanstack/solid-start-client'
419
export type {
520
HydrateOptions,

packages/vue-start/src/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
export { useServerFn } from './useServerFn'
22
export * from '@tanstack/start-client-core'
3+
// Explicit re-exports shadow `export *` above so these public-API names are
4+
// registered on the namespace at link time (via Vite SSR's `defineExport`
5+
// at fileStartIndex), surviving the cold-start SSR cycle through user
6+
// middleware. See vitejs/vite#22491 / #22493. Trim list to genuine public
7+
// API only; internals fall through `export *` and are safe because they
8+
// aren't imported at top level in the cycle path.
9+
export {
10+
createClientOnlyFn,
11+
createCsrfMiddleware,
12+
createIsomorphicFn,
13+
createMiddleware,
14+
createServerFn,
15+
createServerOnlyFn,
16+
createStart,
17+
} from '@tanstack/start-client-core'

0 commit comments

Comments
 (0)