fix: $state.eager() is sometimes incorrect in SSR (#18530)

Fix #18529

A simple fix : `context.visit()` was missing on the argument of
`$state.eager()`, so the generated code can be incorrect in some case :
pull/18497/head
adiGuba 1 week ago committed by GitHub
parent 199ffebca3
commit a4fd67e361
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: ensure `$state.eager()` is correctly transormed for SSR output

@ -46,7 +46,7 @@ export function CallExpression(node, context) {
}
if (rune === '$state.eager') {
return node.arguments[0];
return context.visit(node.arguments[0]);
}
if (rune === '$state.snapshot') {

@ -0,0 +1,7 @@
<script>
let props = $props();
const value = $derived(props.number ?? 0);
</script>
<div>value={value}</div>
<div>eager={$state.eager(value)}</div>
Loading…
Cancel
Save