Skip to content

fix(plugin-vite): correct module resolution when Vite optimizeDeps is enabled (#3895) - #3896

Open
mryall-mawson wants to merge 3 commits into
freshframework:mainfrom
mryall-mawson:fix/3895-vite-loader
Open

fix(plugin-vite): correct module resolution when Vite optimizeDeps is enabled (#3895)#3896
mryall-mawson wants to merge 3 commits into
freshframework:mainfrom
mryall-mawson:fix/3895-vite-loader

Conversation

@mryall-mawson

Copy link
Copy Markdown

Enabling optimizeDeps in Vite config causes the Fresh dev server to fail with file-not-found errors. In this mode, modules URLs include a query string which is not stripped before being passed to Deno's loader, which interprets them as filenames.

See #3895 for the full bug description and reproduction.

This PR provides a simple test case using an existing fixture, and the fix in plugin-vite to strip the query strings before loading.

Note there are some existing test failures on main which this PR does not attempt to fix.

@mryall-mawson mryall-mawson changed the title fix: plugin-vite: strip query from URLs before loading (#3895) fix(plugin-vite): strip query from URLs before loading (#3895) Jul 30, 2026
@mryall-mawson
mryall-mawson force-pushed the fix/3895-vite-loader branch from 9d2def1 to fe855b5 Compare July 30, 2026 11:21
@mryall-mawson

mryall-mawson commented Jul 31, 2026

Copy link
Copy Markdown
Author

I made a couple more fixes in this PR to get Vite’s optimizeDeps fully working in Fresh for client-side modules, with new tests to reproduce the issues I found along the way.

It is now tested and working for me, and I've released a fork here which we will use until this fix is released: https://jsr.io/@mawson/fresh-plugin-vite

We saw a reduction in our functional test execution time from 3.5 min to 2.5 mins against a dev server with optimizeDeps enabled for some large and deep dependency trees.

Edit: the specific error I saw was: Cannot read properties of undefined (reading '__$f') This indicated a duplicate copy of Preact was loaded on the front-end.

@mryall-mawson mryall-mawson changed the title fix(plugin-vite): strip query from URLs before loading (#3895) fix(plugin-vite): correct module resolution when Vite optimizeDeps is enabled (#3895) Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant