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
20 changes: 20 additions & 0 deletions e2e/react-start/custom-manifest-base/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
node_modules
package-lock.json
yarn.lock

.DS_Store
.cache
.env
.vercel
.output

/build/
/api/
/server/build
/public/build
# Sentry Config File
.env.sentry-build-plugin
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
4 changes: 4 additions & 0 deletions e2e/react-start/custom-manifest-base/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/build
**/public
pnpm-lock.yaml
routeTree.gen.ts
51 changes: 51 additions & 0 deletions e2e/react-start/custom-manifest-base/express-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import express from 'express'
import { toNodeHandler } from 'srvx/node'
import cors from 'cors'

const DEVELOPMENT = process.env.NODE_ENV === 'development'
const PORT = Number.parseInt(process.env.PORT || '3000')

const app = express()

const cdn = express()

if (DEVELOPMENT) {
const viteDevServer = await import('vite').then((vite) =>
vite.createServer({
server: { middlewareMode: true },
}),
)
app.use(viteDevServer.middlewares)
app.use(async (req, res, next) => {
try {
const { default: serverEntry } =
await viteDevServer.ssrLoadModule('./src/server.ts')
const handler = toNodeHandler(serverEntry.fetch)
await handler(req, res)
} catch (error) {
if (typeof error === 'object' && error instanceof Error) {
viteDevServer.ssrFixStacktrace(error)
}
next(error)
}
})
} else {
const { default: handler } = await import('./dist/server/server.js')
const nodeHandler = toNodeHandler(handler.fetch)
cdn.use(cors())
cdn.use('', express.static('dist/client'))
app.use(async (req, res, next) => {
try {
await nodeHandler(req, res)
} catch (error) {
next(error)
}
})
}

cdn.listen(3001, () => {
console.log(`CDN is running on http://localhost:3001`)
})
app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`)
})
41 changes: 41 additions & 0 deletions e2e/react-start/custom-manifest-base/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "tanstack-react-start-e2e-custom-manifest-base",
"private": true,
"sideEffects": false,
"type": "module",
"scripts": {
"dev": "cross-env NODE_ENV=development tsx express-server.ts",
"build": "vite build && tsc --noEmit",
"start": "tsx express-server.ts",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Use cross-platform command for file deletion.

The rm -rf command in the test:e2e script is Unix-specific and will fail on Windows. Consider using a cross-platform alternative.

Apply this diff to use a cross-platform solution:

-    "test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
+    "test:e2e": "rimraf port*.txt && playwright test --project=chromium"

And add rimraf to devDependencies:

     "postcss": "^8.5.1",
+    "rimraf": "^6.0.1",
     "srvx": "^0.8.6",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
"test:e2e": "rimraf port*.txt && playwright test --project=chromium"
🤖 Prompt for AI Agents
In e2e/react-start/custom-manifest-base/package.json around line 10, the
"test:e2e" script uses Unix-specific "rm -rf" which fails on Windows; replace
the removal with a cross-platform tool by changing the script to use "rimraf"
(e.g. "rimraf port*.txt && playwright test --project=chromium") and add "rimraf"
to devDependencies (install as a dev dependency or add an entry in package.json
devDependencies).

},
"dependencies": {
"@tanstack/react-router": "workspace:^",
"@tanstack/react-router-devtools": "workspace:^",
"@tanstack/react-start": "workspace:^",
"cors": "^2.8.5",
"express": "^4.21.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1"
},
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
"@types/cors": "^2.8.19",
"@types/express": "^5.0.3",
"@types/node": "^22.10.2",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "^10.4.20",
"cross-env": "^10.0.0",
"postcss": "^8.5.1",
"srvx": "^0.8.6",
"tailwindcss": "^3.4.17",
"tsx": "^4.20.3",
"typescript": "^5.7.2",
"vite": "^7.1.7",
"vite-tsconfig-paths": "^5.1.4"
}
}
42 changes: 42 additions & 0 deletions e2e/react-start/custom-manifest-base/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { defineConfig, devices } from '@playwright/test'
import {
getDummyServerPort,
getTestServerPort,
} from '@tanstack/router-e2e-utils'
import packageJson from './package.json' with { type: 'json' }

const PORT = await getTestServerPort(packageJson.name)
const EXTERNAL_PORT = await getDummyServerPort(packageJson.name)
const baseURL = `http://localhost:${PORT}/custom/basepath`

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
workers: 1,

reporter: [['line']],

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

use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL,
},

webServer: {
command: `VITE_NODE_ENV="test" VITE_EXTERNAL_PORT=${EXTERNAL_PORT} pnpm build && VITE_NODE_ENV="test" VITE_EXTERNAL_PORT=${EXTERNAL_PORT} VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`,
url: baseURL,
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
},

projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
})
6 changes: 6 additions & 0 deletions e2e/react-start/custom-manifest-base/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions e2e/react-start/custom-manifest-base/public/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
console.log('SCRIPT_1 loaded')
window.SCRIPT_1 = true
2 changes: 2 additions & 0 deletions e2e/react-start/custom-manifest-base/public/script2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
console.log('SCRIPT_2 loaded')
window.SCRIPT_2 = true
19 changes: 19 additions & 0 deletions e2e/react-start/custom-manifest-base/public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as React from 'react'

export function CustomMessage({ message }: { message: string }) {
return (
<div className="py-2">
<div className="italic">This is a custom message:</div>
<p>{message}</p>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {
ErrorComponent,
Link,
rootRouteId,
useMatch,
useRouter,
} from '@tanstack/react-router'
import type { ErrorComponentProps } from '@tanstack/react-router'

export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
const router = useRouter()
const isRoot = useMatch({
strict: false,
select: (state) => state.id === rootRouteId,
})

console.error(error)

return (
<div className="min-w-0 flex-1 p-4 flex flex-col items-center justify-center gap-6">
<ErrorComponent error={error} />
<div className="flex gap-2 items-center flex-wrap">
<button
onClick={() => {
router.invalidate()
}}
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
>
Try Again
</button>
{isRoot ? (
<Link
to="/"
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
>
Home
</Link>
) : (
<Link
to="/"
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
onClick={(e) => {
e.preventDefault()
window.history.back()
}}
>
Go Back
</Link>
)}
</div>
</div>
)
}
25 changes: 25 additions & 0 deletions e2e/react-start/custom-manifest-base/src/components/NotFound.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Link } from '@tanstack/react-router'

export function NotFound({ children }: { children?: any }) {
return (
<div className="space-y-2 p-2" data-testid="default-not-found-component">
<div className="text-gray-600 dark:text-gray-400">
{children || <p>The page you are looking for does not exist.</p>}
</div>
<p className="flex items-center gap-2 flex-wrap">
<button
onClick={() => window.history.back()}
className="bg-emerald-500 text-white px-2 py-1 rounded uppercase font-black text-sm"
>
Go back
</button>
<Link
to="/"
className="bg-cyan-600 text-white px-2 py-1 rounded uppercase font-black text-sm"
>
Start Over
</Link>
</p>
</div>
)
}
Loading