You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm just trying out Tanstack Router in an existing project using "virtual file routing". At the moment I'm just testing things with a dead-simple route config.
It took me a while before I realized that the error was stating that routes.ts file's export was expected to be an object with type property equal to "root". Logging the value of the routes object, it had the shape { type: 'root', file: '__root.tsx', children: undefined }. So something else must have been going on.
Following the stack trace, I found that the internal getVirtualRouteConfigFromFileExport uses loadConfigFile.loadConfigFile to get an exports object that has the shape
Note that my routes.ts file doesn't have a default export. The presence of this strange default export is causing this
// equal to `{ routes: [Getter] }`constvirtualRouteConfig="default"inexports2 ? exports2.default : exports2.routes;// which causes this to fail with the Zod errorreturnconfig.virtualRootRouteSchema.parse(virtualRouteConfig);
Monkey patching the code like so fixes the error and the vite dev server starts correct
The text was updated successfully, but these errors were encountered:
jorroll
changed the title
Internal getVirtualRouteConfigFromFileExport function appears to incorrectly load config file
bug: Internal getVirtualRouteConfigFromFileExport function appears to incorrectly load config file
Jan 8, 2025
Which project does this relate to?
Router
Describe the bug
I'm just trying out Tanstack Router in an existing project using "virtual file routing". At the moment I'm just testing things with a dead-simple route config.
When attempting to start the vite dev server, I keep seeing the following error.
It took me a while before I realized that the error was stating that
routes.ts
file's export was expected to be an object with type property equal to"root"
. Logging the value of theroutes
object, it had the shape{ type: 'root', file: '__root.tsx', children: undefined }
. So something else must have been going on.Following the stack trace, I found that the internal
getVirtualRouteConfigFromFileExport
usesloadConfigFile.loadConfigFile
to get anexports
object that has the shapeNote that my
routes.ts
file doesn't have a default export. The presence of this strange default export is causing thisMonkey patching the code like so fixes the error and the vite dev server starts correct
Your Example Website or App
see explanation, above
Steps to Reproduce the Bug or Issue
See explanation above
Expected behavior
See explanation above
Screenshots or Videos
No response
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: