T
TanStack5mo ago
stormy-gold

Build issue when using virtual file routes in tanstack start

I face an issue when try build my demo app, and get this error what happing is that during build it recreate "routeTree.gen.ts" but it create at as I work with file based not virtual file routes, so it deals with my "routes.ts" as route and show this error, like try to import from "routeTree.gen.ts", as you see I share the error and file config, it's very simple and work locally fine but get this during build
No description
No description
No description
No description
7 Replies
deep-jade
deep-jade5mo ago
would move the routes.ts out of the routes folder. other than that, a complete minimal repro would be needed to debug this
stormy-gold
stormy-goldOP5mo ago
https://github.com/Mohammedelsayed412/tanstack-start-virtual-file-routes-build-issue you can clone it and try build and will see the behavior, it simple have only one route /test
GitHub
GitHub - Mohammedelsayed412/tanstack-start-virtual-file-routes-buil...
Contribute to Mohammedelsayed412/tanstack-start-virtual-file-routes-build-issue development by creating an account on GitHub.
stormy-gold
stormy-goldOP5mo ago
moving "routes.ts" out is working fine, but I think it must be changes so that if I want add different files than routes
deep-jade
deep-jade5mo ago
what exactly is the behavior you see? is this only on production build? ah I found the issue the router plugin needs to be removed as start handles this internally so this works
import { defineConfig } from "@tanstack/react-start/config";
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
import tsConfigPaths from "vite-tsconfig-paths";

import { routes } from "./src/routes";

export default defineConfig({
tsr: {
appDirectory: "src",
virtualRouteConfig: routes,
},
vite: {
plugins: [
tsConfigPaths({
projects: ["./tsconfig.json"],
}),
],
},
});
import { defineConfig } from "@tanstack/react-start/config";
import { TanStackRouterVite } from "@tanstack/router-plugin/vite";
import tsConfigPaths from "vite-tsconfig-paths";

import { routes } from "./src/routes";

export default defineConfig({
tsr: {
appDirectory: "src",
virtualRouteConfig: routes,
},
vite: {
plugins: [
tsConfigPaths({
projects: ["./tsconfig.json"],
}),
],
},
});
stormy-gold
stormy-goldOP5mo ago
no build locally, I edit the repo, as when I add any ts file inside routes like actions/actions.ts to have my server functions it make this issue but I need this plugin to set "TanStackRouterVite" and set path for virtual-file-routes or what you means ?
deep-jade
deep-jade5mo ago
see my config above the virtual route config needs to done inside the tsr prop
stormy-gold
stormy-goldOP5mo ago
yes got it, works now thanks

Did you find this page helpful?