fix: avoid client modules while traversing dependencies to prevent FOUC during dev...
authorSimon H <5968653+dummdidumm@users.noreply.github.com>
Fri, 3 Oct 2025 12:38:53 +0000 (14:38 +0200)
committerGitHub <noreply@github.com>
Fri, 3 Oct 2025 12:38:53 +0000 (08:38 -0400)
commit51214794b40b2fc533b06cb8344e84e661f90be0
tree9f441eab70416c293315fb3a3158d05908d4ab5a
parentcde1458be47ecb6e15a332434b18c0c4c5c9831d
fix: avoid client modules while traversing dependencies to prevent FOUC during dev (#14577)

* fix: avoid client modules while traversing dependencies to prevent FOUC during dev

This tweaks the way we're traversing dependencies to avoid a flash of unstyled content during dev. Previously we were using `getModuleByURL` which loads both the client and server version of the module. This means that server-only dependencies can end up being loaded into the client module graph, which is more likely to happen with remote modules.

Example:
+page.svelte -> foo.remote.ts -> {client: nothing, server: server-only-dependency } -> getModuleByURL for both client and server of server-only dependency -> crash

I'm not totally sure if this may have been a somewhat hidden breaking change from Vite 5 -> 6, but either way this ensures that Vite 5-7 now only load the ssr variant.

Fixes #14519

* snake_case

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
.changeset/late-banks-clean.md [new file with mode: 0644]
packages/kit/src/exports/vite/dev/index.js