Stylesheet visitor fails when using custom properties in 1.30.2
Issue
CSS:
.foo {
color: var(--color-red);
}
Visitor:
{
StyleSheet(stylesheet) {
return stylesheet;
}
}
Expected
.foo{color:var(--color-red)}
Current behaviour
/* ERROR: failed to deserialize; expected an object-like struct named Specifier, found () */
Reproduction
Playground example Set version to 1.30.2 to reproduce the issue
Works from 1.18.0 to 1.30.1.
Hi guys!
Hope you are doing well.
I have the same issue with my plugin from the 1.30.2.
It's pretty hard to spot from where come the issue from but it fail when it has to call a registered "rule" like this:
.my-element {
@s-transition(fast);
}
and my rule is registered like so:
{
Rule: {
unknown(rule) {
try {
switch (true) {
case rule.name === `s-transition`:
return __transitionRule(rule, finalSettings);
}
} catch (e) {
console.error(e);
}
},
},
}
All my plugin documentation is available here: https://sugarcss.blackbyte.space
Hope this is not a deep issue...
I also have this on projects when using custom visitors and drafts. If i remove both of these the issue disappears
lightningcss: {
drafts: { customMedia: true },
visitor: composeVisitors([
breakpoints({
mobile: 640,
tablet: 1024,
laptop: 1280,
desktop: 1440
}),
fluid({ vmax: 1600 }),
size
])
}
visitors in use are here https://github.com/mattpilott/kitto/tree/main/src/lib/lightningcss
Same issue in #1071
For me it is the same. The newest rolldown-vite installs automatically version 1.30.2 then I could make the smallest reproducable visitor:
{
Function: {
'--Foo': (args) => {
return {
type: 'var',
value: {
name: { ident: '--foo', from: null },
fallback: null,
},
};
},
}
}