From 90d6e43a91a90aae651963bea1c23608b8efa504 Mon Sep 17 00:00:00 2001 From: Justin Hall Date: Tue, 21 Jan 2025 23:27:44 -0700 Subject: [PATCH] fix(dev): resolve optimizeDeps entries properly on Windows (#12637) * fix(dev): resolve optimizeDeps entries properly on Windows * Add changeset * Sign CLA --- .changeset/gentle-carrots-appear.md | 5 +++++ contributors.yml | 1 + packages/react-router-dev/vite/plugin.ts | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/gentle-carrots-appear.md diff --git a/.changeset/gentle-carrots-appear.md b/.changeset/gentle-carrots-appear.md new file mode 100644 index 0000000000..061682a3b0 --- /dev/null +++ b/.changeset/gentle-carrots-appear.md @@ -0,0 +1,5 @@ +--- +"@react-router/dev": patch +--- + +Properly resolve Windows file paths to scan for Vite's dependency optimization when using the `unstable_optimizeDeps` future flag. diff --git a/contributors.yml b/contributors.yml index 319238170e..4f2c232fa2 100644 --- a/contributors.yml +++ b/contributors.yml @@ -330,6 +330,7 @@ - willemarcel - williamsdyyz - willsawyerrrr +- wkovacs64 - xavier-lc - xcsnowcity - yionr diff --git a/packages/react-router-dev/vite/plugin.ts b/packages/react-router-dev/vite/plugin.ts index 795a8f7182..6220234712 100644 --- a/packages/react-router-dev/vite/plugin.ts +++ b/packages/react-router-dev/vite/plugin.ts @@ -800,9 +800,9 @@ export const reactRouterVitePlugin: ReactRouterVitePlugin = () => { optimizeDeps: { entries: ctx.reactRouterConfig.future.unstable_optimizeDeps ? [ - ctx.entryClientFilePath, + vite.normalizePath(ctx.entryClientFilePath), ...Object.values(ctx.reactRouterConfig.routes).map((route) => - path.join(ctx.reactRouterConfig.appDirectory, route.file) + resolveRelativeRouteFilePath(route, ctx.reactRouterConfig) ), ] : [],