TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
8.01k stars 616 forks source link

Vite plugin regression causes plugin to break when having a root configured #2030

Closed reihwald closed 2 months ago

reihwald commented 2 months ago

Describe the bug

I noticed that my routes are no longer getting generated after updating my vite plugin. This is most noticeable by the fact that creating a new file in the routes folder no longer generates the small createFileRoute snippet.

It is possible to trigger the plugin to update the gen.ts file by stopping the relaunching the vite dev command but I am still not getting the correct type inference in my editor when using search params. Everything works fine when doing a production build.

This is caused by the root setting in vite. Removing it and configuring vite to run without it makes the problem disappear.

Your Example Website or App

https://stackblitz.com/edit/github-snnf6b

Steps to Reproduce the Bug or Issue

  1. Run npm run dev
  2. Create a new file under someFolder/anotherFolder/routes with a name like test.tsx
  3. No createFileRoute snippet is being generated

Please note that the vite example does not show anything when running the dev command. We run vite in a customized environment but this should not be of concern for this bug.

Expected behavior

Please take a look at this example: https://stackblitz.com/edit/github-snnf6b-aobdnw

  1. This is the exact same vite setup as the first example but using version 1.34.8 of @tanstack/router-vite-plugin.
  2. The problem is not reproducible in this version. Doing the same steps as above creates a createFileRoute snippet

I'd expect that the vite plugin still work when using the root setting.

Screenshots or Videos

No response

Platform

Additional context

No response

schiller-manuel commented 2 months ago

is this the same as https://github.com/TanStack/router/issues/1550?

reihwald commented 2 months ago

@schiller-manuel It certainly looks very similar. This issue is however still happening on the latest version even after that merged PR.

schiller-manuel commented 2 months ago

could be a regression caused by moving over to unplugin

cc @SeanCassiere

SeanCassiere commented 2 months ago

could be a regression caused by moving over to unplugin

cc @SeanCassiere

Very unlikely tbh. Their implementation for vite is dead-simple.

vbifonixor commented 2 months ago

Found a tiny crutch to work around it - used vite-plugin-restart to restart vite every time route files change. I think it should be definitely a bad one for large projects (mine was just started two days ago). Hope the issue is fixed soon!