T
TanStack6mo ago
deep-jade

createFileRoute removed on save

Trying to migrate from Next.js, running the alpha. Running into two issues with file based routing: 1. No createFileRoute being inserted in existing files 2. With new files, createFileRoute is added, but when saving the createFileRoute import is removed
"@tanstack/react-router": "1.121.0-alpha.14",
"@tanstack/react-start": "1.121.0-alpha.21",
"@tanstack/react-router": "1.121.0-alpha.14",
"@tanstack/react-start": "1.121.0-alpha.21",
Vite config
import tailwindcss from "@tailwindcss/vite"
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: [tailwindcss(), tsconfigPaths(), tanstackStart()],
})
import tailwindcss from "@tailwindcss/vite"
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: [tailwindcss(), tsconfigPaths(), tanstackStart()],
})
8 Replies
genetic-orange
genetic-orange6mo ago
yes, this is expected. you dont import createFileRoute anymore this will be much smoother soon
deep-jade
deep-jadeOP6mo ago
Thanks, how do we deal with the TypeScript part then? Create a global or something?
genetic-orange
genetic-orange6mo ago
it's done for you automatically no need to worry about that
deep-jade
deep-jadeOP6mo ago
It seems that this only works for 1 file for me. In my index.tsx I dont need the import. In other files it will give me a missing definition error. Also, is there a way to fix #1? It seems that Vite is not adding export const Route ... to files that already existed
genetic-orange
genetic-orange6mo ago
we only prefill empty files so you would need to add the export yourself. should be picked up then .
deep-jade
deep-jadeOP6mo ago
Fair enough, thanks!
genetic-orange
genetic-orange6mo ago
however the code generator is currently being rewritten by me to me much more robust. will be out soon
deep-jade
deep-jadeOP6mo ago
Nice! Looking forward to it Thanks for the help

Did you find this page helpful?