Skip to content
Merged
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/vue-start/custom-basepath/.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/vue-start/custom-basepath/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/build
**/public
pnpm-lock.yaml
routeTree.gen.ts
44 changes: 44 additions & 0 deletions e2e/vue-start/custom-basepath/express-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import express from 'express'
import { toNodeHandler } from 'srvx/node'

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

const app = 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)
app.use('/custom/basepath', express.static('dist/client'))
app.use(async (req, res, next) => {
try {
await nodeHandler(req, res)
} catch (error) {
next(error)
}
})
}

app.listen(PORT, () => {
console.log(`Server is running on http://localhost:${PORT}`)
})
38 changes: 38 additions & 0 deletions e2e/vue-start/custom-basepath/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "tanstack-vue-start-e2e-custom-basepath",
"private": true,
"sideEffects": false,
"type": "module",
"scripts": {
"dev": "cross-env NODE_ENV=development tsx express-server.ts",
"build": "vite build && tsc --noEmit",
"preview": "vite preview",
"start": "tsx express-server.ts",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
"@tanstack/vue-router": "workspace:^",
"@tanstack/vue-router-devtools": "workspace:^",
"@tanstack/vue-start": "workspace:^",
Comment on lines +14 to +16
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 | 🔴 Critical

Use workspace:* protocol for internal dependencies.

The coding guidelines require using workspace:* instead of workspace:^ for internal monorepo dependencies.

As per coding guidelines, apply this diff:

   "dependencies": {
-    "@tanstack/vue-router": "workspace:^",
-    "@tanstack/vue-router-devtools": "workspace:^",
-    "@tanstack/vue-start": "workspace:^",
+    "@tanstack/vue-router": "workspace:*",
+    "@tanstack/vue-router-devtools": "workspace:*",
+    "@tanstack/vue-start": "workspace:*",
     "express": "^4.21.2",
     "redaxios": "^0.5.1",
     "vue": "^3.5.25"
   },
   "devDependencies": {
     "@playwright/test": "^1.50.1",
     "@tailwindcss/postcss": "^4.1.15",
-    "@tanstack/router-e2e-utils": "workspace:^",
+    "@tanstack/router-e2e-utils": "workspace:*",
     "@types/express": "^5.0.3",

Also applies to: 24-24

🤖 Prompt for AI Agents
In e2e/vue-start/custom-basepath/package.json around lines 14-16 (and also line
24), internal monorepo dependencies use the workspace:^ protocol; update these
entries to use workspace:* instead (replace "workspace:^" with "workspace:*" for
"@tanstack/vue-router", "@tanstack/vue-router-devtools", "@tanstack/vue-start"
and the dependency on line 24) to conform to the coding guidelines.

"express": "^4.21.2",
"redaxios": "^0.5.1",
"vue": "^3.5.25"
},
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tailwindcss/postcss": "^4.1.15",
"@tanstack/router-e2e-utils": "workspace:^",
"@types/express": "^5.0.3",
"@types/node": "^22.10.2",
"cross-env": "^10.0.0",
"postcss": "^8.5.1",
"srvx": "^0.9.8",
"tailwindcss": "^4.1.17",
"tsx": "^4.20.3",
"typescript": "^5.7.2",
"vite": "^7.1.7",
"@vitejs/plugin-vue": "^6.0.3",
"@vitejs/plugin-vue-jsx": "^5.1.2",
"vite-tsconfig-paths": "^5.1.4"
}
}
42 changes: 42 additions & 0 deletions e2e/vue-start/custom-basepath/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'] },
},
],
})
5 changes: 5 additions & 0 deletions e2e/vue-start/custom-basepath/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
plugins: {
'@tailwindcss/postcss': {},
},
}
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.
Binary file added e2e/vue-start/custom-basepath/public/favicon.png
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/vue-start/custom-basepath/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/vue-start/custom-basepath/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/vue-start/custom-basepath/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,8 @@
export function CustomMessage({ message }: { message: string }) {
return (
<div class="py-2">
<div class="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/vue-router'
import type { ErrorComponentProps } from '@tanstack/vue-router'

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

console.error(error)

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

export function NotFound({ children }: { children?: any }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Replace any type with proper type annotation.

The children parameter uses any, which violates TypeScript strict mode best practices. Use a more specific type like JSX.Element | string | undefined or unknown if the type is truly unconstrained.

As per coding guidelines, TypeScript strict mode with extensive type safety should be used for all code.

Apply this diff:

-export function NotFound({ children }: { children?: any }) {
+export function NotFound({ children }: { children?: JSX.Element | string }) {
📝 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
export function NotFound({ children }: { children?: any }) {
export function NotFound({ children }: { children?: JSX.Element | string }) {
🤖 Prompt for AI Agents
In e2e/vue-start/custom-basepath/src/components/NotFound.tsx around line 3, the
component uses the unsafe `any` type for `children`; replace it with a stricter
annotation such as `JSX.Element | string | undefined` (or another appropriate
union like `JSX.Element | string | null | undefined`) in the function signature
so the parameter is strongly typed; update the signature to use that union type
and run TypeScript to ensure no other typing adjustments are needed.

return (
<div class="space-y-2 p-2" data-testid="default-not-found-component">
<div class="text-gray-600 dark:text-gray-400">
{children || <p>The page you are looking for does not exist.</p>}
</div>
<p class="flex items-center gap-2 flex-wrap">
<button
onClick={() => window.history.back()}
class="bg-emerald-500 text-white px-2 py-1 rounded-sm uppercase font-black text-sm"
>
Go back
</button>
<Link
to="/"
class="bg-cyan-600 text-white px-2 py-1 rounded-sm uppercase font-black text-sm"
>
Start Over
</Link>
</p>
</div>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ErrorComponent, ErrorComponentProps } from '@tanstack/vue-router'

export function PostErrorComponent({ error }: ErrorComponentProps) {
return <ErrorComponent error={error} />
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ErrorComponent } from '@tanstack/vue-router'
import type { ErrorComponentProps } from '@tanstack/vue-router'

export function UserErrorComponent({ error }: ErrorComponentProps) {
return <ErrorComponent error={error} />
}
Loading
Loading