Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/tidy-routes-recover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@tanstack/router-core': patch
'@tanstack/router-plugin': patch
'@tanstack/react-start-rsc': patch
---

Recover missing Webpack and Rspack route chunks through the existing reload-once path. Keep route hot updates scoped to their owning router and avoid patching another router's same-ID route on first import.

Let Vite replace RSC stylesheets during HMR without accumulating persistent React preinit links.
22 changes: 6 additions & 16 deletions e2e/react-start/hmr/tests/app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import path from 'node:path'
import { expect } from '@playwright/test'
import {
createHmrFileEditor,
replaceAll,
test,
} from '@tanstack/router-e2e-utils'
import path from 'node:path'

import type { Page } from '@playwright/test'

Expand Down Expand Up @@ -577,15 +577,13 @@ test.describe('react-start hmr', () => {

test.beforeEach(async ({ page }) => {
await capturePromise
const pendingRouteKeys = Array.from(routeKeysPendingRestoreCheck)
const restoredRouteKeys = await restoreRouteFiles(pendingRouteKeys)
const routeKeysToCheck = new Set(routeKeysPendingRestoreCheck)
routeKeysPendingRestoreCheck.clear()
const restoredRouteKeys = await restoreRouteFiles()
for (const routeFileKey of restoredRouteKeys) {
routeKeysPendingRestoreCheck.add(routeFileKey)
routeKeysToCheck.add(routeFileKey)
}

const routeKeysToCheck = Array.from(routeKeysPendingRestoreCheck)
routeKeysPendingRestoreCheck.clear()

for (const routeFileKey of routeKeysToCheck) {
await waitForRestoredRouteFile(page, routeFileKey)
}
Expand Down Expand Up @@ -943,7 +941,6 @@ test.describe('react-start hmr', () => {
await waitForRouteModuleUpdate(page, '/child', 'Child Updated Again')
},
)
await waitForHydrationSafeReload(page, '/child', 'Child Updated Again')

// Now navigate to /child — should see the LATEST value
await page.getByTestId('child-link').click()
Expand All @@ -962,6 +959,7 @@ test.describe('react-start hmr', () => {

// Set up local state in the index route
await page.getByTestId('increment').click()
await expect(page.getByTestId('count')).toHaveText('Count: 1')
await page.getByTestId('increment').click()
await page.getByTestId('message').fill('preserve me')

Expand Down Expand Up @@ -1155,8 +1153,6 @@ test.describe('react-start hmr', () => {
),
async () => {},
)
await page.waitForTimeout(300)

await reloadPageAndWaitForText(
page,
'/',
Expand Down Expand Up @@ -1211,8 +1207,6 @@ test.describe('react-start hmr', () => {
),
async () => {},
)
await page.waitForTimeout(300)

await reloadPageAndWaitForText(
page,
'/',
Expand Down Expand Up @@ -1254,8 +1248,6 @@ test.describe('react-start hmr', () => {
),
async () => {},
)
await page.waitForTimeout(300)

await reloadPageAndWaitForText(
page,
'/',
Expand Down Expand Up @@ -1297,8 +1289,6 @@ test.describe('react-start hmr', () => {
),
async () => {},
)
await page.waitForTimeout(300)

await reloadPageAndWaitForText(
page,
'/',
Expand Down
4 changes: 4 additions & 0 deletions e2e/react-start/issue-8049/src/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
ClientOnly,
HeadContent,
Link,
Scripts,
Expand Down Expand Up @@ -30,6 +31,9 @@ function RootDocument({ children }: { children: ReactNode }) {
</nav>
{children}
</div>
<ClientOnly>
<span data-testid="hydrated" hidden />
</ClientOnly>
<Scripts />
</body>
</html>
Expand Down
2 changes: 1 addition & 1 deletion e2e/react-start/issue-8049/tests/issue-8049.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('#8049: revisiting loaded split routes transitions without pending or blank
})
await page.goto('/')
await expect(page.getByText('Home Page')).toBeVisible()
await page.waitForTimeout(1_000)
await expect(page.getByTestId('hydrated')).toBeAttached()

await page.getByRole('link', { name: 'Test' }).click()
await expect(page.getByText('Test Page')).toBeVisible()
Expand Down
7 changes: 7 additions & 0 deletions e2e/react-start/rsc-hmr/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
dist
dist-vite-*
dist-rsbuild-*
test-results
playwright-report
port*.txt
63 changes: 63 additions & 0 deletions e2e/react-start/rsc-hmr/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"name": "tanstack-react-start-e2e-rsc-hmr",
"private": true,
"sideEffects": [
"**/*.css"
],
"type": "module",
"scripts": {
"dev": "pnpm dev:vite --port 3000",
"dev:e2e": "pnpm dev:vite",
"dev:vite": "vite dev",
"dev:rsbuild": "rsbuild dev",
"build": "pnpm build:vite",
"build:vite": "vite build && tsc --noEmit",
"build:rsbuild": "rsbuild build && tsc --noEmit",
"test:e2e": "MODE=dev playwright test --project=chromium"
},
"dependencies": {
"@tanstack/react-router": "workspace:*",
"@tanstack/react-start": "workspace:*",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@playwright/test": "^1.61.0",
"@rsbuild/core": "^2.1.0",
"@rsbuild/plugin-react": "^2.0.0",
"@tanstack/router-e2e-utils": "workspace:^",
"@types/node": "^22.10.2",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^6.0.1",
"@vitejs/plugin-rsc": "^0.5.30",
"react-server-dom-rspack": "^0.0.2",
"typescript": "npm:@typescript/typescript6@^6.0.2",
"vite": "^8.0.14"
},
"nx": {
"targets": {
"test:e2e": {
"parallelism": false
},
"test:e2e--vite-ssr": {
"parallelism": false
},
"test:e2e--rsbuild-ssr": {
"parallelism": false
}
},
"metadata": {
"playwrightModes": [
{
"toolchain": "vite",
"mode": "ssr"
},
{
"toolchain": "rsbuild",
"mode": "ssr"
}
]
}
}
}
50 changes: 50 additions & 0 deletions e2e/react-start/rsc-hmr/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { defineConfig, devices } from '@playwright/test'
import { getTestServerPort } from '@tanstack/router-e2e-utils'
import packageJson from './package.json' with { type: 'json' }

const toolchain = process.env.E2E_TOOLCHAIN ?? 'vite'
const e2ePortKey =
process.env.E2E_PORT_KEY ?? `${packageJson.name}-${toolchain}`
const distDir = process.env.E2E_DIST_DIR ?? 'dist'
const viteBundledDev = process.env.E2E_VITE_BUNDLED_DEV === 'true'
const PORT = await getTestServerPort(e2ePortKey)
const baseURL = `http://localhost:${PORT}`
const devCommand =
toolchain === 'rsbuild' ? 'pnpm dev:rsbuild' : 'pnpm dev:vite'

export default defineConfig({
testDir: './tests',
workers: 1,
reporter: [['line']],

globalSetup: './tests/setup/global.setup.ts',
globalTeardown: './tests/setup/global.teardown.ts',

use: {
baseURL,
},

webServer: {
command: `${devCommand} --port ${PORT}`,
url: baseURL,
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
env: {
VITE_NODE_ENV: 'test',
PORT: String(PORT),
E2E_TOOLCHAIN: toolchain,
E2E_DIST_DIR: distDir,
E2E_PORT_KEY: e2ePortKey,
E2E_VITE_BUNDLED_DEV: String(viteBundledDev),
},
},

projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
},
],
})
24 changes: 24 additions & 0 deletions e2e/react-start/rsc-hmr/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from '@rsbuild/core'
import { pluginReact } from '@rsbuild/plugin-react'
import { tanstackStart } from '@tanstack/react-start/plugin/rsbuild'

const outDir = process.env.E2E_DIST_DIR ?? 'dist'

export default defineConfig({
plugins: [
pluginReact(),
tanstackStart({
rsc: {
enabled: true,
},
}),
],
output: {
distPath: {
root: outDir,
},
},
server: {
port: 3000,
},
})
Loading
Loading