feat: support ?inline
query on svelte style virtual modules
#1024
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Vite 6, importing CSS in SSR now no longer return a default export of the transformed CSS file, you'd need to use
?inline
instead. This was already pushed for in Vite 5 but we forgot to remove support in SSR.That means frameworks who do CSS crawling to prevent FOUC will now have to use
?inline
to get the transformed CSS, which most already did. However, there's a quirk where v-p-s always strips out the?inline
here:vite-plugin-svelte/packages/vite-plugin-svelte/src/index.js
Lines 127 to 136 in da54670
This was fine for Vite 5 as mentioned above, Vite still supported default exports of CSS files in SSR, but with Vite 6 it is now empty. For v-p-s to properly support
?inline
, it needs to leave the query as is, similar to?raw
handling.In practice, this isn't a breaking change, however due to some unintended reliance of the old behaviour,
the SvelteKit tests here will fail due to HMR(added a workaround here for now). I sent a PR upstream to fix this sveltejs/kit#13007 and if we want to play it safe for now, we can merge this only in the next major.With this merged, it should unblock Vite 6 support for CSS FOUC for both SvelteKit and Astro.