1- import { resolve , win32 } from "node:path " ;
1+ import * as Path from "pathe " ;
22import * as v from "valibot" ;
33import pick from "lodash/pick" ;
4+
45import invariant from "../invariant" ;
56
67declare global {
@@ -315,7 +316,7 @@ export function relative(directory: string): typeof helpers {
315316 * `relative` call that created this helper.
316317 */
317318 route : ( path , file , ...rest ) => {
318- return route ( path , resolve ( directory , file ) , ...( rest as any ) ) ;
319+ return route ( path , Path . resolve ( directory , file ) , ...( rest as any ) ) ;
319320 } ,
320321 /**
321322 * Helper function for creating a route config entry for an index route, for
@@ -324,7 +325,7 @@ export function relative(directory: string): typeof helpers {
324325 * `relative` call that created this helper.
325326 */
326327 index : ( file , ...rest ) => {
327- return index ( resolve ( directory , file ) , ...( rest as any ) ) ;
328+ return index ( Path . resolve ( directory , file ) , ...( rest as any ) ) ;
328329 } ,
329330 /**
330331 * Helper function for creating a route config entry for a layout route, for
@@ -333,7 +334,7 @@ export function relative(directory: string): typeof helpers {
333334 * `relative` call that created this helper.
334335 */
335336 layout : ( file , ...rest ) => {
336- return layout ( resolve ( directory , file ) , ...( rest as any ) ) ;
337+ return layout ( Path . resolve ( directory , file ) , ...( rest as any ) ) ;
337338 } ,
338339
339340 // Passthrough of helper functions that don't need relative scoping so that
@@ -343,6 +344,7 @@ export function relative(directory: string): typeof helpers {
343344}
344345
345346export function configRoutesToRouteManifest (
347+ appDirectory : string ,
346348 routes : RouteConfigEntry [ ] ,
347349 rootId = "root"
348350) : RouteManifest {
@@ -353,7 +355,9 @@ export function configRoutesToRouteManifest(
353355 let manifestItem : RouteManifestEntry = {
354356 id,
355357 parentId,
356- file : route . file ,
358+ file : Path . isAbsolute ( route . file )
359+ ? Path . relative ( appDirectory , route . file )
360+ : route . file ,
357361 path : route . path ,
358362 index : route . index ,
359363 caseSensitive : route . caseSensitive ,
@@ -381,11 +385,7 @@ export function configRoutesToRouteManifest(
381385}
382386
383387function createRouteId ( file : string ) {
384- return normalizeSlashes ( stripFileExtension ( file ) ) ;
385- }
386-
387- function normalizeSlashes ( file : string ) {
388- return file . split ( win32 . sep ) . join ( "/" ) ;
388+ return Path . normalize ( stripFileExtension ( file ) ) ;
389389}
390390
391391function stripFileExtension ( file : string ) {
0 commit comments