Skip to content
Source
Sign inSign up
TanStack/router

test(rsc): HMR e2e for a route component co-located with a server fn (canary for #7618 / vitejs/vite-plugin-react#1248) #7621

Closedsreetamdas(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/7621/headopened

Showing 5 changed files with 97 additions and 1 deletion (loading 1).

x
0 of 5 viewed, 5 left
41 additions and 0 deletionse2e/react-start/rsc/src/routes/rsc-hmr-serverfn.tsxAdded
View file
@@ -0,0 +1,41 @@
+import { createFileRoute } from '@tanstack/react-router'
+import { createServerFn } from '@tanstack/react-start'
+import { renderServerComponent } from '@tanstack/react-start/rsc'
+import { useState } from 'react'
+​
+// This route deliberately keeps BOTH a `createServerFn` loader and the route
+// component in the same file. That combination is the regression under test:
+// the server-fn extraction (`?tss-serverfn-split`) must not strip the route
+// component's client Fast Refresh boundary (`?tsr-split=component`).
+const getHmrServerComponent = createServerFn({ method: 'GET' }).handler(
+ async () => {
+ return renderServerComponent(
+ <div data-testid="rsc-hmr-server-content">server-rendered content</div>,
+ )
+ },
+)
+​
+export const Route = createFileRoute('/rsc-hmr-serverfn')({
+ loader: () => getHmrServerComponent(),
+ component: RscHmrServerFnComponent,
+})
+​
+function RscHmrServerFnComponent() {
+ const ServerComponent = Route.useLoaderData()
+ const [count, setCount] = useState(0)
+​
+ return (