Skip to content
Source
Sign inSign up
TanStack/router

fix: correct compiler plugin order, only handle createMiddleware in a … #6163

Mergedschiller-manuel(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/6163/headmerged by schiller-manuel(GitHub profile, opens in a new tab)

Showing 31 changed files with 73 additions and 58 deletions (loading 27).

x
0 of 31 viewed, 31 left
e2e/react-start/server-functions/src/routeTree.gen.tsModified
View file
63 additions and 0 deletionse2e/react-start/server-functions/src/routes/server-fn-in-client-only-fn.tsxAdded
View file
@@ -0,0 +1,63 @@
+import { createFileRoute } from '@tanstack/react-router'
+import { createClientOnlyFn, createServerFn } from '@tanstack/react-start'
+import { useState } from 'react'
+​
+// Server function that should be callable from client-only function
+const serverFn = createServerFn().handler(() => {
+ return 'server function executed successfully'
+})
+​
+// Client-only function that calls the server function
+// This scenario currently fails due to compilation order issues:
+// 1. createClientOnlyFn is processed first, removing the serverFn reference on server
+// 2. Dead code elimination removes the serverFn entirely
+// 3. The server function is never registered, causing runtime errors
+const clientOnlyFnThatCallsServerFn = createClientOnlyFn(async () => {
+ const result = await serverFn()
+ return 'client-only fn received: ' + result
+})
+​
+export const Route = createFileRoute('/server-fn-in-client-only-fn')({
+ component: RouteComponent,
+})