From 06d43dfdf5cd24c191ec3c16ef387cfe9e8a8536 Mon Sep 17 00:00:00 2001 From: ComputerGuy <63362464+Ocean-OS@users.noreply.github.com> Date: Sun, 31 Aug 2025 02:33:37 -0700 Subject: [PATCH] make `$.all` a stmt if all awaits are stmts --- .../3-transform/client/visitors/Program.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/Program.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/Program.js index 8dbe245d8d..cee3a7aaf1 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/Program.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/Program.js @@ -165,14 +165,18 @@ export function Program(node, context) { } } else { const pattern = b.array_pattern(chunk.declarators.map(({ id }) => id)); - const init = b.call('$.all', ...chunk.declarators.map(({ init }) => init)); - body.splice( - chunk.position + offset, - 0, - b.declaration(chunk.kind ?? 'const', [ - b.declarator(pattern, b.call(b.await(b.call('$.save', init)))) - ]) + const init = b.call( + b.await(b.call('$.save', b.call('$.all', ...chunk.declarators.map(({ init }) => init)))) ); + if (pattern.elements.every((element) => element === null)) { + body.splice(chunk.position + offset, 0, b.stmt(init)); + } else { + body.splice( + chunk.position + offset, + 0, + b.declaration(chunk.kind ?? 'const', [b.declarator(pattern, init)]) + ); + } } offset++; }