Open eighty4 opened 2 days ago
Does not happen in REPL tho
v4: https://svelte.dev/repl/cd08bbafe46342b3bea65bbd333aa867?version=4.2.19 v5: https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAA0WPTY7CMAyFr2IFFiCQKNvQjjTnoCxK6o4iUqdKHCQU9e7kBzFe2X7-nu0oJm3QC3mNgoYZhRS_yyKOgl9LLvwTDWOqvQ1O5U7rldML__TUs0EGZQMxdLD1PDDumv0lKUmbAinWlkCTcjgj8W4PMSs9V-bQwTkP89pTe_q3pfYemBNpSRmtHl38Wqxlbel6CbH4FLoSlfb8MphSSCGdtZzXwifug3r8ucSNEjZN01yqVE8oYHp2tqOeNI5Csgu43tY3Tzm1ricBAAA=
I corrected my OP to use a CSS variable as my local recreation has it, but that still doesn't recreate in REPL.
Here's an example I have from my local project:
{
type: 'StyleSheet',
start: 221,
end: 454,
attributes: [],
children: [
{
type: 'Rule',
prelude: [Object],
block: [Object],
start: 233,
end: 441,
metadata: [Object]
},
{
type: 'Rule',
prelude: [Object],
block: [Object],
start: 443,
end: 446,
metadata: [Object]
}
],
content: {
start: 228,
end: 446,
styles: '\n' +
' span {\n' +
' border: 2px solid var(--highlight-color);\n' +
' display: inline-block;\n' +
' font-size: .8rem;\n' +
' font-weight: bold;\n' +
' padding: .25rem .5rem;\n' +
' border-radius: .25rem;\n' +
' }\n' +
' *{}',
comment: null
}
}
Every Svelte component has the * {}
added to the end of its CSS. metadata.unused
is only true if the CSS only contains the root pseudo class selector.
Does this recreate for you?
git clone https://github.com/eighty4/qwerky
cd qwerky/ui
echo "<script lang="ts">\nimport Footer from '\$lib/footer/qwerky_footer.svelte'\n</script>\n\n<Footer/>\n\n<style>\n :root {\n --footer-height: 4rem;\n }\n</style>" > src/lib/qwerky_app.svelte
pnpm dev
Describe the bug
A component with a
<style>
block that only uses:root { }
to specify CSS variables will log a warning for an unused CSS selector:It seems like every component's CSS has an implicitly added
* {}
at the bottom of its CSS. All components in my app include the* {}
.Only the component that uses
<style>
for specifying root vars flags the* {}
as unused. Somehow the magic behind the scenes* {}
is flagged as used for any components with CSS selectors and properties.Reproduction
This seems to only trigger
metadata.unused
if the CSS only contains a root pseudo class selector and the component's markup only contains a Svelte component.Logs
No response
System Info
Fourth message has guaranteed recreation steps.
Severity
annoyance