From 1e4ab3705ee5ad1dc0e0948d4ee9123fef00a3fa Mon Sep 17 00:00:00 2001 From: Artur Date: Tue, 10 Dec 2024 15:23:01 +0200 Subject: [PATCH] fix: Make file route HMR work on Windows (#2978) Fixes #2964 --- packages/ts/file-router/src/vite-plugin.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/ts/file-router/src/vite-plugin.ts b/packages/ts/file-router/src/vite-plugin.ts index 2d8bc14e57..a3d7a86b37 100644 --- a/packages/ts/file-router/src/vite-plugin.ts +++ b/packages/ts/file-router/src/vite-plugin.ts @@ -115,7 +115,8 @@ export default function vitePluginFileSystemRouter({ }, transform(code, id): Promise | TransformResult { let modifiedCode = code; - if (id.startsWith(fileURLToPath(_viewsDir)) && !basename(id).startsWith('_')) { + const viewsDirUsingSlashes = fileURLToPath(_viewsDir).replaceAll('\\', '/'); + if (id.startsWith(viewsDirUsingSlashes) && !basename(id).startsWith('_')) { if (isDevMode) { // To enable HMR for route files with exported configurations, we need // to address a limitation in `react-refresh`. This library requires