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
11 changes: 11 additions & 0 deletions e2e/vue-router/basic-vue-query-file-based/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
node_modules
.DS_Store
dist
dist-hash
dist-ssr
*.local

/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
12 changes: 12 additions & 0 deletions e2e/vue-router/basic-vue-query-file-based/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
35 changes: 35 additions & 0 deletions e2e/vue-router/basic-vue-query-file-based/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "tanstack-router-e2e-vue-basic-vue-query-file-based",
"private": true,
"type": "module",
"scripts": {
"dev": "vite --port 3000",
"dev:e2e": "vite",
"build": "vite build && vue-tsc --noEmit",
"preview": "vite preview",
"start": "vite",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"dependencies": {
"@tailwindcss/postcss": "^4.1.15",
"@tanstack/vue-query": "^5.90.0",
"@tanstack/vue-query-devtools": "^6.1.2",
"@tanstack/vue-router": "workspace:^",
"@tanstack/vue-router-devtools": "workspace:^",
"@tanstack/router-plugin": "workspace:^",
"postcss": "^8.5.1",
"redaxios": "^0.5.1",
"tailwindcss": "^4.1.17",
"vue": "^3.5.16",
"zod": "^3.24.2"
},
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
"@vitejs/plugin-vue": "^5.2.3",
"@vitejs/plugin-vue-jsx": "^4.1.2",
"typescript": "~5.8.3",
"vite": "^7.1.7",
"vue-tsc": "^3.1.5"
}
}
Comment on lines +1 to +35
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

🧩 Analysis chain

🏁 Script executed:

# Find all package.json files to see what pattern is used
git ls-files "**package.json" | head -20

Repository: TanStack/router

Length of output: 1105


🏁 Script executed:

# Look for workspace protocol usage patterns in the repo
rg "workspace:\*|workspace:\^" --type json | head -30

Repository: TanStack/router

Length of output: 2758


🏁 Script executed:

# Check for workspace protocol documentation in the repo
rg "workspace:\*|workspace:\^" --type md -B 2 -A 2 | head -50

Repository: TanStack/router

Length of output: 580


🏁 Script executed:

# Check the git history to see when these guidelines were introduced
git log --all --oneline -- "**/AGENTS.md" "**/*guidelines*" | head -10

Repository: TanStack/router

Length of output: 41


🏁 Script executed:

# Check root package.json to understand workspace configuration
cat -n package.json | head -50

Repository: TanStack/router

Length of output: 2574


🏁 Script executed:

# Check git log for changes to AGENTS.md related to workspace protocol
git log --all --oneline --follow -- AGENTS.md | head -20

Repository: TanStack/router

Length of output: 180


🏁 Script executed:

# Look at the actual diff/content changes in AGENTS.md
git log --all --pretty=format:"%h %s" -- AGENTS.md | head -5

Repository: TanStack/router

Length of output: 180


🏁 Script executed:

# Check if there are any recent commits updating package.json files to workspace:*
git log --all --oneline --grep="workspace" | head -10

Repository: TanStack/router

Length of output: 512


🏁 Script executed:

# Check a few other e2e package.json files to confirm the pattern is universal
for file in e2e/react-router/basic-file-based/package.json e2e/solid-start/website/package.json e2e/vue-router/basic/package.json; do
  echo "=== $file ==="; 
  rg "workspace:" "$file" | head -5; 
done

Repository: TanStack/router

Length of output: 774


Use workspace:* for internal dependencies per repo guidelines.

   "dependencies": {
-    "@tanstack/vue-router": "workspace:^",
-    "@tanstack/vue-router-devtools": "workspace:^",
-    "@tanstack/router-plugin": "workspace:^",
+    "@tanstack/vue-router": "workspace:*",
+    "@tanstack/vue-router-devtools": "workspace:*",
+    "@tanstack/router-plugin": "workspace:*",
   "devDependencies": {
-    "@tanstack/router-e2e-utils": "workspace:^",
+    "@tanstack/router-e2e-utils": "workspace:*",

Note: The entire e2e suite currently uses workspace:^, so consider applying this guideline repo-wide for consistency.

🤖 Prompt for AI Agents
In e2e/vue-router/basic-vue-query-file-based/package.json lines 1-35, internal
workspace dependencies use "workspace:^"; update every occurrence of
"workspace:^" to "workspace:*" (for @tanstack/vue-router,
@tanstack/vue-router-devtools, @tanstack/router-plugin,
@tanstack/router-e2e-utils) so internal packages follow repo guidelines; save
the file and run a quick install to verify lockfile updates.

40 changes: 40 additions & 0 deletions e2e/vue-router/basic-vue-query-file-based/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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}`

/**
* 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_SERVER_PORT=${PORT} VITE_EXTERNAL_PORT=${EXTERNAL_PORT} pnpm build && VITE_NODE_ENV="test" VITE_SERVER_PORT=${PORT} VITE_EXTERNAL_PORT=${EXTERNAL_PORT} pnpm preview --port ${PORT}`,
url: baseURL,
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
},

projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
})
5 changes: 5 additions & 0 deletions e2e/vue-router/basic-vue-query-file-based/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export default {
plugins: {
'@tailwindcss/postcss': {},
},
}
39 changes: 39 additions & 0 deletions e2e/vue-router/basic-vue-query-file-based/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { createApp } from 'vue'
import { RouterProvider, createRouter } from '@tanstack/vue-router'
import { QueryClient, VueQueryPlugin } from '@tanstack/vue-query'
import { routeTree } from './routeTree.gen'
import './styles.css'

const queryClient = new QueryClient()

// Set up a Router instance
const router = createRouter({
routeTree,
context: {
queryClient,
},
scrollRestoration: true,
defaultPreload: 'intent',
// Since we're using Vue Query, we don't want loader calls to ever be stale
// This will ensure that the loader is always called when the route is preloaded or visited
defaultPreloadStaleTime: 0,
})

// Register things for typesafety
declare module '@tanstack/vue-router' {
interface Register {
router: typeof router
}
}

const rootElement = document.getElementById('app')!

if (!rootElement.innerHTML) {
createApp({
setup() {
return () => <RouterProvider router={router} />
},
})
.use(VueQueryPlugin, { queryClient })
.mount('#app')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { queryOptions } from '@tanstack/vue-query'
import { fetchPost } from './posts'

export const postQueryOptions = (postId: string) =>
queryOptions({
queryKey: ['posts', { postId }],
queryFn: () => fetchPost(postId),
})
37 changes: 37 additions & 0 deletions e2e/vue-router/basic-vue-query-file-based/src/posts.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import axios from 'redaxios'

export type PostType = {
id: string
title: string
body: string
}

export class PostNotFoundError extends Error {}

let queryURL = 'https://jsonplaceholder.typicode.com'

if (import.meta.env.VITE_NODE_ENV === 'test') {
queryURL = `http://localhost:${import.meta.env.VITE_EXTERNAL_PORT}`
}

export const fetchPost = async (postId: string) => {
console.info(`Fetching post with id ${postId}...`)
const post = await axios
.get<PostType>(`${queryURL}/posts/${postId}`)
.then((r) => r.data)
.catch((err) => {
if (err.status === 404) {
throw new PostNotFoundError(`Post with id "${postId}" not found!`)
}
throw err
})

return post
}

export const fetchPosts = async () => {
console.info('Fetching posts...')
return axios
.get<Array<PostType>>(`${queryURL}/posts`)
.then((r) => r.data.slice(0, 10))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { queryOptions } from '@tanstack/vue-query'
import { fetchPosts } from './posts'

export const postsQueryOptions = queryOptions({
queryKey: ['posts'],
queryFn: () => fetchPosts(),
})
Loading
Loading