Description
Which project does this relate to?
Router
Describe the bug
When using @tanstack/router-plugin/vite to automatically generate routes, together with unplugin-auto-import/vite for automatic imports, the auto-import feature does not work inside .tsx files located in the routes directory.
However, components imported from other directories (such as views or components) can be auto-imported correctly without manual import statements.
This discrepancy causes inconsistent developer experience, requiring manual imports in the routes folder, but not elsewhere.
Your Example Website or App
This issue occurs in a project using: • @tanstack/router-plugin/vite for route generation • unplugin-auto-import/vite for automatic imports • React + TypeScript + Vite setup I currently do not have a minimal reproduction URL but can provide code snippets if needed.
Steps to Reproduce the Bug or Issue
1. Configure @tanstack/router-plugin/vite to generate routes from src/routes folder.
2. Configure unplugin-auto-import/vite with basic imports (e.g. react).
3. Write a .tsx file inside src/routes that uses React hooks (like useState) without manual import.
4. Notice auto-imports do not work — errors appear for undefined hooks.
5. Write a .tsx file inside src/views using the same hooks.
6. Auto-import works correctly without manual imports.
Expected behavior
I expect auto-imports to work uniformly in all directories including routes, so that React APIs and other configured imports are automatically available without manual import statements.
Screenshots or Videos
No response
Platform
- OS: [macOS, Windows]
- Browser: [N/A]
- Version: [e.g. 91.1]
Additional context
I suspect the issue is related to how unplugin-auto-import scans directories or how @tanstack/router-plugin/vite processes route files, causing the auto-import plugin to miss the routes directory files.
A possible workaround might be to explicitly include src/routes in unplugin-auto-import’s dirs configuration, but I would like to understand if this is intended behavior or a bug.