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>