Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lemon-beers-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: avoid FOUC when using CSS modules in dev
11 changes: 8 additions & 3 deletions packages/kit/src/exports/vite/dev/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,20 @@ export async function dev(vite, vite_config, svelte_config) {
const styles = {};

for (const dep of deps) {
const parsed = new URL(dep.url, 'http://localhost/');
const query = parsed.searchParams;
const url = new URL(dep.url, 'http://localhost/');
const query = url.searchParams;

if (
isCSSRequest(dep.file) ||
(query.has('svelte') && query.get('type') === 'style')
) {
// setting `?inline` to load CSS modules as css string
query.set('inline', '');
Comment thread
DrLoopFall marked this conversation as resolved.

try {
const mod = await loud_ssr_load_module(dep.url);
const mod = await loud_ssr_load_module(
`${url.pathname}${url.search}${url.hash}`
Comment thread
Rich-Harris marked this conversation as resolved.
);
styles[dep.url] = mod.default;
} catch {
// this can happen with dynamically imported modules, I think
Expand Down