* chore: reenable server CSS output through a compiler option
There are various use cases where this continues to be necessary/nice to have:
- rendering OG cards
- rendering emails
- basically anything where you use `render` manually and want to quickly stitch together the CSS without setting up an elaborate tooling chain
* cssRenderOnServer -> css: 'injected'
* update tests
* move append_styles into new module, update implementation
* get HMR working
* don't append styles to head when compiling as a custom element
* update changeset
* tweak
* tweak
* tweak wording
* update test
* fix
* reinstate optimisation, but without the bug
* fix sourcemap test
* move breaking change note
* Update packages/svelte/src/internal/server/index.js
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
---------
Co-authored-by: Simon Holthausen <simon.holthausen@vercel.com>
Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
*-`'external'`:theCSSwill be returnedinthe`css`fieldofthecompilationresult.MostSveltebundlerpluginswillsetthisto`'external'`andusetheCSSthatisstaticallygeneratedforbetterperformance,asitwillresultinsmallerJavaScriptbundlesandtheoutputcanbeservedascacheable`.css`files.
*-`'external'`:theCSSwillonly be returnedinthe`css`fieldofthecompilationresult.MostSveltebundlerpluginswillsetthisto`'external'`andusetheCSSthatisstaticallygeneratedforbetterperformance,asitwillresultinsmallerJavaScriptbundlesandtheoutputcanbeservedascacheable`.css`files.
*-`'external'`:theCSSwill be returnedinthe`css`fieldofthecompilationresult.MostSveltebundlerpluginswillsetthisto`'external'`andusetheCSSthatisstaticallygeneratedforbetterperformance,asitwillresultinsmallerJavaScriptbundlesandtheoutputcanbeservedascacheable`.css`files.
*-`'external'`:theCSSwillonly be returnedinthe`css`fieldofthecompilationresult.MostSveltebundlerpluginswillsetthisto`'external'`andusetheCSSthatisstaticallygeneratedforbetterperformance,asitwillresultinsmallerJavaScriptbundlesandtheoutputcanbeservedascacheable`.css`files.
*-`'external'`:theCSSwill be returnedinthe`css`fieldofthecompilationresult.MostSveltebundlerpluginswillsetthisto`'external'`andusetheCSSthatisstaticallygeneratedforbetterperformance,asitwillresultinsmallerJavaScriptbundlesandtheoutputcanbeservedascacheable`.css`files.
*-`'external'`:theCSSwillonly be returnedinthe`css`fieldofthecompilationresult.MostSveltebundlerpluginswillsetthisto`'external'`andusetheCSSthatisstaticallygeneratedforbetterperformance,asitwillresultinsmallerJavaScriptbundlesandtheoutputcanbeservedascacheable`.css`files.
If the `css` compiler option was set to `'injected'`, `<style>` elements will be included in the `head`.
## `svelte/elements`
Svelte provides built-in [DOM types](https://github.com/sveltejs/svelte/blob/master/packages/svelte/elements.d.ts). A common use case for DOM types is forwarding props to an HTML element. To properly type your props and get full intellisense, your props interface should extend the attributes type for your HTML element:
`render` also no longer returns CSS; it should be served separately from a CSS file.
In Svelte 4, rendering a component to a string also returned the CSS of all components. In Svelte 5, this is no longer the case by default because most of the time you're using a tooling chain that takes care of it in other ways (like SvelteKit). If you need CSS to be returned from `render`, you can set the `css` compiler option to `'injected'` and it will add `<style>` elements to the `head`.