router
                                
                                 router copied to clipboard
                                
                                    router copied to clipboard
                            
                            
                            
                        Router CLI Replaces Strings
Describe the bug
Just wanted to drop a quick note to say thanks for the awesome router. I did run into a little hiccup, though. When I'm creating routes using the router, I noticed that the router-cli is swapping out my const values with string literals.
Here's my original code snippet:
const Route = new FileRoute(URI.ROOT).createRoute({
  component: Component
});
But after the router-cli does its thing, it becomes:
const Route = new FileRoute('/').createRoute({
  component: Component
});
I'm trying to have all my routes in a central const file for easy management. The substitution of const values with string literals is throwing a bit of a wrench into that plan.
Is there a possibility to support such configuration?
Thanks!
Your Example Website or App
N/A
Steps to Reproduce the Bug or Issue
N/A
Expected behavior
N/A
Screenshots or Videos
No response
Platform
- router/cli version 1.4.3
Additional context
No response
You could build your central file based on FileRoutes:
import { Route as PostsRoute } from './routes/posts'
import { Route as FooRoute } from './routes/foo'
// or use Route.id, this is just an example
export const routes = { 'posts': PostsRoute.fullPath, 'foo':  FooRoute.fullPath };
Yeah, this isn't really functionality we can change right now. @schiller-manuel's approach is recommended.
You could build your central file based on
FileRoutes:import { Route as PostsRoute } from './routes/posts' import { Route as FooRoute } from './routes/foo' // or use Route.id, this is just an example export const routes = { 'posts': PostsRoute.fullPath, 'foo': FooRoute.fullPath };
@tannerlinsley
I tried calling const routeApi = getRouteApi(routes.contactsRoute.id) from a central file in a component and got an Uncaught ReferenceError: Cannot access 'routes' before initialization error. This component is being used in a route so I figure it's a circular dependency.
Figured I'd try this object approach since I notice it's a kind of annoying to go find the string paths throughout the codebase that need to be changed whenever files are moved.