From e0594886f710e640e73b8610127e35e6600a7dd5 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Wed, 18 Jun 2025 13:33:29 -0700 Subject: [PATCH 1/3] chore: introduce new structure --- app.config.ts | 12 ------- app/api.ts | 6 ---- app/client.tsx | 7 ---- eslint.config.mjs | 31 ++++++++++++++++ package.json | 44 +++++++++++------------ {app => src}/routeTree.gen.ts | 65 ++++++++++------------------------ {app => src}/router.tsx | 2 ++ {app => src}/routes/__root.tsx | 25 +++++++------ {app => src}/routes/index.tsx | 0 app/ssr.tsx => src/server.ts | 2 -- tsconfig.json | 4 +-- vite.config.ts | 15 ++++++++ 12 files changed, 105 insertions(+), 108 deletions(-) delete mode 100644 app.config.ts delete mode 100644 app/api.ts delete mode 100644 app/client.tsx create mode 100644 eslint.config.mjs rename {app => src}/routeTree.gen.ts (63%) rename {app => src}/router.tsx (77%) rename {app => src}/routes/__root.tsx (59%) rename {app => src}/routes/index.tsx (100%) rename app/ssr.tsx => src/server.ts (76%) create mode 100644 vite.config.ts diff --git a/app.config.ts b/app.config.ts deleted file mode 100644 index 346ac63..0000000 --- a/app.config.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { defineConfig } from '@tanstack/react-start/config' -import tsConfigPaths from 'vite-tsconfig-paths' - -export default defineConfig({ - vite: { - plugins: [ - tsConfigPaths({ - projects: ['./tsconfig.json'], - }), - ], - }, -}) diff --git a/app/api.ts b/app/api.ts deleted file mode 100644 index 8b9fef1..0000000 --- a/app/api.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { - createStartAPIHandler, - defaultAPIFileRouteHandler, -} from '@tanstack/react-start/api' - -export default createStartAPIHandler(defaultAPIFileRouteHandler) diff --git a/app/client.tsx b/app/client.tsx deleted file mode 100644 index 9fb62bd..0000000 --- a/app/client.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { hydrateRoot } from 'react-dom/client' -import { StartClient } from '@tanstack/react-start' -import { createRouter } from './router' - -const router = createRouter() - -hydrateRoot(document!, ) diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..081c5c2 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,31 @@ +import globals from 'globals' +import pluginJs from '@eslint/js' +import tseslint from 'typescript-eslint' +import pluginReactConfig from 'eslint-plugin-react/configs/recommended.js' +import { fixupConfigRules } from '@eslint/compat' + +export default [ + { files: ['**/*.{mjs,ts,jsx,tsx}'] }, + { languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } }, + { languageOptions: { globals: globals.browser } }, + pluginJs.configs.recommended, + ...tseslint.configs.recommended, + ...fixupConfigRules(pluginReactConfig), + { + settings: { + react: { + version: 'detect', + pragma: 'React', + pragmaFrag: 'React.Fragment', + }, + }, + }, + { + rules: { + 'react/react-in-jsx-scope': 'off', + }, + }, + { + ignores: ['dist/'], + }, +] diff --git a/package.json b/package.json index d04f97a..3b3b970 100644 --- a/package.json +++ b/package.json @@ -4,38 +4,38 @@ "sideEffects": false, "type": "module", "scripts": { - "dev": "vinxi dev", - "build": "vinxi build", - "start": "vinxi start", - "lint": "prettier --check '**/*' --ignore-unknown && eslint --ext .ts,.tsx ./app", - "format": "prettier --write '**/*' --ignore-unknown" + "dev": "vite dev", + "build": "vite build && tsc --noEmit", + "start": "vite start", + "format": "prettier --write .", + "lint": "eslint . --report-unused-disable-directives --max-warnings 0" }, "dependencies": { - "@clerk/tanstack-react-start": "0.16.0", - "@tanstack/server-functions-plugin": "1.120.17", - "@tanstack/router-generator": "1.120.17", - "@tanstack/react-router-devtools": "1.120.17", - "@tanstack/react-start": "1.120.17", - "@tanstack/react-start-config": "1.120.17", - "@tanstack/router-plugin": "1.120.17", - "@tanstack/react-start-client": "1.120.17", - "@tanstack/react-start-plugin": "1.120.17", - "@tanstack/react-start-server": "1.120.17", - "@tanstack/start-server-core": "1.120.17", - "@typescript-eslint/parser": "^8.31.1", + "@clerk/tanstack-react-start": "0.18.0-canary.v20250618190251", + "@tanstack/react-router": "^1.121.24", + "@tanstack/react-router-devtools": "^1.121.24", + "@tanstack/react-start": "^1.121.24", "react": "^19.1.0", - "react-dom": "^19.1.0", - "vinxi": "0.5.6" + "react-dom": "^19.1.0" }, "devDependencies": { + "@eslint/compat": "^1.2.8", + "@eslint/js": "^9.25.1", + "@typescript-eslint/parser": "^8.31.1", + "@typescript-eslint/eslint-plugin": "^8.31.1", + "eslint": "^9.25.1", + "eslint-plugin-react": "^7.37.5", + "eslint-plugin-react-hooks": "^5.2.0", + "eslint-plugin-react-refresh": "^0.4.20", "@types/node": "^22.15.3", "@types/react": "^19.1.2", "@types/react-dom": "^19.1.3", "autoprefixer": "^10.4.21", - "eslint": "^9.25.1", - "eslint-config-react-app": "^7.0.1", "prettier": "^3.5.3", "typescript": "^5.8.3", + "typescript-eslint": "^8.31.1", + "vite": "^6.3.5", "vite-tsconfig-paths": "^5.1.4" - } + }, + "packageManager": "npm@10.9.2" } diff --git a/app/routeTree.gen.ts b/src/routeTree.gen.ts similarity index 63% rename from app/routeTree.gen.ts rename to src/routeTree.gen.ts index 5e68293..d204c26 100644 --- a/app/routeTree.gen.ts +++ b/src/routeTree.gen.ts @@ -8,48 +8,25 @@ // You should NOT make any changes in this file as it will be overwritten. // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. -// Import Routes +import { Route as rootRouteImport } from './routes/__root' +import { Route as IndexRouteImport } from './routes/index' -import { Route as rootRoute } from './routes/__root' -import { Route as IndexImport } from './routes/index' - -// Create/Update Routes - -const IndexRoute = IndexImport.update({ +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', - getParentRoute: () => rootRoute, + getParentRoute: () => rootRouteImport, } as any) -// Populate the FileRoutesByPath interface - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexImport - parentRoute: typeof rootRoute - } - } -} - -// Create and export the route tree - export interface FileRoutesByFullPath { '/': typeof IndexRoute } - export interface FileRoutesByTo { '/': typeof IndexRoute } - export interface FileRoutesById { - __root__: typeof rootRoute + __root__: typeof rootRouteImport '/': typeof IndexRoute } - export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath fullPaths: '/' @@ -58,31 +35,25 @@ export interface FileRouteTypes { id: '__root__' | '/' fileRoutesById: FileRoutesById } - export interface RootRouteChildren { IndexRoute: typeof IndexRoute } +declare module '@tanstack/react-router' { + interface FileRoutesByPath { + '/': { + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport + parentRoute: typeof rootRouteImport + } + } +} + const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, } - -export const routeTree = rootRoute +export const routeTree = rootRouteImport ._addFileChildren(rootRouteChildren) ._addFileTypes() - -/* ROUTE_MANIFEST_START -{ - "routes": { - "__root__": { - "filePath": "__root.tsx", - "children": [ - "/" - ] - }, - "/": { - "filePath": "index.tsx" - } - } -} -ROUTE_MANIFEST_END */ diff --git a/app/router.tsx b/src/router.tsx similarity index 77% rename from app/router.tsx rename to src/router.tsx index b8744cb..e423256 100644 --- a/app/router.tsx +++ b/src/router.tsx @@ -5,6 +5,8 @@ export function createRouter() { const router = createTanStackRouter({ routeTree, defaultPreload: 'intent', + defaultErrorComponent: (err) =>

{err.error.stack}

, + defaultNotFoundComponent: () =>

not found

, scrollRestoration: true, }) diff --git a/app/routes/__root.tsx b/src/routes/__root.tsx similarity index 59% rename from app/routes/__root.tsx rename to src/routes/__root.tsx index 7d11c2d..257d3bf 100644 --- a/app/routes/__root.tsx +++ b/src/routes/__root.tsx @@ -1,22 +1,26 @@ +/// +import * as React from 'react' +import { TanStackRouterDevtools } from '@tanstack/react-router-devtools' +import { ClerkProvider } from '@clerk/tanstack-react-start' import { HeadContent, Outlet, - createRootRoute, Scripts, + createRootRoute, } from '@tanstack/react-router' -import type * as React from 'react' -import { ClerkProvider } from '@clerk/tanstack-react-start' export const Route = createRootRoute({ - component: () => { - return ( - - - - ) - }, + component: RootComponent, }) +function RootComponent() { + return ( + + + + ) +} + function RootDocument({ children }: { children: React.ReactNode }) { return ( @@ -26,6 +30,7 @@ function RootDocument({ children }: { children: React.ReactNode }) { {children} + diff --git a/app/routes/index.tsx b/src/routes/index.tsx similarity index 100% rename from app/routes/index.tsx rename to src/routes/index.tsx diff --git a/app/ssr.tsx b/src/server.ts similarity index 76% rename from app/ssr.tsx rename to src/server.ts index 0e3d061..bd67177 100644 --- a/app/ssr.tsx +++ b/src/server.ts @@ -2,13 +2,11 @@ import { createStartHandler, defaultStreamHandler, } from '@tanstack/react-start/server' -import { getRouterManifest } from '@tanstack/react-start/router-manifest' import { createRouter } from './router' import { createClerkHandler } from '@clerk/tanstack-react-start/server' export default createClerkHandler( createStartHandler({ createRouter, - getRouterManifest, }), )(defaultStreamHandler) diff --git a/tsconfig.json b/tsconfig.json index d1b5b77..b3a2d67 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,5 @@ { - "include": ["**/*.ts", "**/*.tsx"], + "include": ["**/*.ts", "**/*.tsx", "public/script*.js"], "compilerOptions": { "strict": true, "esModuleInterop": true, @@ -15,7 +15,7 @@ "forceConsistentCasingInFileNames": true, "baseUrl": ".", "paths": { - "~/*": ["./app/*"] + "~/*": ["./src/*"] }, "noEmit": true } diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..1f5fd19 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,15 @@ +import { tanstackStart } from '@tanstack/react-start/plugin/vite' +import { defineConfig } from 'vite' +import tsConfigPaths from 'vite-tsconfig-paths' + +export default defineConfig({ + server: { + port: 3000, + }, + plugins: [ + tsConfigPaths({ + projects: ['./tsconfig.json'], + }), + tanstackStart(), + ], +}) From a4e08204702e287f70268b524e105e23b9fe4724 Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Thu, 19 Jun 2025 20:43:26 -0700 Subject: [PATCH 2/3] chore: bump deps --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 3b3b970..9dafcbc 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ }, "dependencies": { "@clerk/tanstack-react-start": "0.18.0-canary.v20250618190251", - "@tanstack/react-router": "^1.121.24", - "@tanstack/react-router-devtools": "^1.121.24", - "@tanstack/react-start": "^1.121.24", + "@tanstack/react-router": "^1.121.27", + "@tanstack/react-router-devtools": "^1.121.27", + "@tanstack/react-start": "^1.121.28", "react": "^19.1.0", "react-dom": "^19.1.0" }, From 0c9b77d351fa6888e81c783cec43c195b8904fbf Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Tue, 24 Jun 2025 09:11:25 -0700 Subject: [PATCH 3/3] update deps --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 9dafcbc..39f8a07 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,10 @@ "lint": "eslint . --report-unused-disable-directives --max-warnings 0" }, "dependencies": { - "@clerk/tanstack-react-start": "0.18.0-canary.v20250618190251", - "@tanstack/react-router": "^1.121.27", - "@tanstack/react-router-devtools": "^1.121.27", - "@tanstack/react-start": "^1.121.28", + "@clerk/tanstack-react-start": "0.18.0", + "@tanstack/react-router": "^1.121.34", + "@tanstack/react-router-devtools": "^1.121.34", + "@tanstack/react-start": "^1.121.35", "react": "^19.1.0", "react-dom": "^19.1.0" },