-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support ?inline
query on svelte style virtual modules
#1024
base: main
Are you sure you want to change the base?
Conversation
optimizeDeps: { | ||
// eagerly include these, otherwise vite optimizer might interfere with restarting while the test is running | ||
include: ['svelte-i18n', 'e2e-test-dep-svelte-api-only'] | ||
} | ||
}; | ||
|
||
export default config; | ||
/** | ||
* Workaround until https://github.com/sveltejs/kit/pull/13007 is merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets merge the kit PR first then, really not a fan of extra code in tests to work around issues in the setup being tested. users don't have the same luxury so this is just hiding an issue.
would rather merge this with a failed test than hiding it if we can't get the kit PR released in time
@@ -162,4 +162,11 @@ describe.runIf(!isBuild)('ssrLoadModule', () => { | |||
const result = await ssrLoadDummy('?raw&svelte&type=style'); | |||
await expect(result).toMatchFileSnapshot(snapshotFilename('ssr-style')); | |||
}); | |||
test('?inline&svelte&type=style&lang.css', async () => { | |||
// Preload Dummy.svelte first so its CSS is processed in the module graph, otherwise loading |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, wouldn't this also affect real use if the inline style is explicitly asked for without the .svelte being processed first? The solution here would be to compile the file if cache is empty instead of just bailing.
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.