From ce2d1b333692cda82b0563ec90a08355409db234 Mon Sep 17 00:00:00 2001 From: ComputerGuy <63362464+Ocean-OS@users.noreply.github.com> Date: Sun, 1 Jun 2025 15:34:09 -0700 Subject: [PATCH] tag iterables used in destructuring --- .../client/visitors/VariableDeclaration.js | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js index eed4f793e6..1cedb02a59 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js @@ -90,7 +90,12 @@ export function VariableDeclaration(node, context) { binding.kind === 'bindable_prop' && should_proxy(initial, context.state.scope) ) { - initial = b.call('$.proxy', initial, dev ? b.literal(id.name) : undefined, dev ? b.literal(PROXY_REMOVE_PATH) : undefined); + initial = b.call( + '$.proxy', + initial, + dev ? b.literal(id.name) : undefined, + dev ? b.literal(PROXY_REMOVE_PATH) : undefined + ); } if (is_prop_source(binding, context.state)) { @@ -168,7 +173,7 @@ export function VariableDeclaration(node, context) { const call = b.call('$.derived', expression); return b.declarator( id, - dev ? b.call('$.tag_source', call, b.literal(id.name)) : call + dev ? b.call('$.tag_source', call, b.literal('[$state iterable]')) : call ); }), ...paths.map((path) => { @@ -209,8 +214,13 @@ export function VariableDeclaration(node, context) { let expression = /** @type {Expression} */ (context.visit(value)); if (rune === '$derived') expression = b.thunk(expression); - - declarations.push(b.declarator(id, b.call('$.derived', expression))); + const call = b.call('$.derived', expression); + declarations.push( + b.declarator( + id, + dev ? b.call('$.tag_source', call, b.literal('[$derived iterable]')) : call + ) + ); } const { inserts, paths } = extract_paths(declarator.id, rhs); @@ -220,7 +230,13 @@ export function VariableDeclaration(node, context) { context.state.transform[id.name] = { read: get_value }; const expression = /** @type {Expression} */ (context.visit(b.thunk(value))); - declarations.push(b.declarator(id, b.call('$.derived', expression))); + const call = b.call('$.derived', expression); + declarations.push( + b.declarator( + id, + dev ? b.call('$.tag_source', call, b.literal('[$derived iterable]')) : call + ) + ); } for (const path of paths) {