mirror of https://github.com/sveltejs/svelte
Fixes a regression introduced in #15820: deriveds need to be lazily called on the server, too, since they can close over variables only later defined Fixes #15960pull/15964/head
parent
7183886a73
commit
e6c4e8c5c5
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: make deriveds on the server lazy again
|
@ -0,0 +1,23 @@
|
|||||||
|
/** @import { ClassBody, MemberExpression } from 'estree' */
|
||||||
|
/** @import { Context } from '../types.js' */
|
||||||
|
import * as b from '#compiler/builders';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {MemberExpression} node
|
||||||
|
* @param {Context} context
|
||||||
|
*/
|
||||||
|
export function MemberExpression(node, context) {
|
||||||
|
if (
|
||||||
|
context.state.analysis.runes &&
|
||||||
|
node.object.type === 'ThisExpression' &&
|
||||||
|
node.property.type === 'PrivateIdentifier'
|
||||||
|
) {
|
||||||
|
const field = context.state.state_fields?.get(`#${node.property.name}`);
|
||||||
|
|
||||||
|
if (field?.type === '$derived' || field?.type === '$derived.by') {
|
||||||
|
return b.call(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
context.next();
|
||||||
|
}
|
Loading…
Reference in new issue