From 03288f50efd439c8738ff79d1a6e95358e307a41 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 29 Nov 2023 05:08:28 -0500 Subject: [PATCH] emit $.proxy --- .../phases/3-transform/client/visitors/javascript-runes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js index 5bb5216be6..32ec138d4e 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js @@ -84,7 +84,7 @@ export const javascript_visitors_runes = { value = field.kind === 'state' - ? b.call('$.source', init) + ? b.call('$.source', b.call('$.proxy', init)) : b.call('$.derived', b.thunk(init)); } else { // if no arguments, we know it's state as `$derived()` is a compile error @@ -219,7 +219,7 @@ export const javascript_visitors_runes = { if (declarator.id.type === 'Identifier') { const callee = rune === '$state' ? '$.source' : '$.derived'; - const arg = rune === '$state' ? value : b.thunk(value); + const arg = rune === '$state' ? b.call('$.proxy', value) : b.thunk(value); declarations.push(b.declarator(declarator.id, b.call(callee, arg, opts))); continue; }