From aafa27f5a3570784a0ff98c911137484901d555e Mon Sep 17 00:00:00 2001 From: ComputerGuy <63362464+Ocean-OS@users.noreply.github.com> Date: Thu, 28 Aug 2025 18:06:59 -0700 Subject: [PATCH] don't parallelize if only one derived can be parallelized --- .../phases/3-transform/client/visitors/Program.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 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 65532d42ec..3146c6ef03 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 @@ -144,9 +144,18 @@ export function Program(node, context) { const chunk = context.state.parallelized_derived_chunks?.at(-1); body.push(transformed); if (chunk && chunk.position === i) { - const pattern = b.array_pattern(chunk.declarators.map(({ id }) => id)); - const init = b.call('$.all', b.array(chunk.declarators.map(({ init }) => init))); - body.push(b.declaration(chunk.kind, [b.declarator(pattern, b.await(init))])); + if (chunk.declarators.length === 1) { + const declarator = chunk.declarators[0]; + body.push( + b.declaration(chunk.kind, [ + b.declarator(declarator.id, b.call(b.await(b.call('$.save', declarator.init)))) + ]) + ); + } else { + const pattern = b.array_pattern(chunk.declarators.map(({ id }) => id)); + const init = b.call('$.all', b.array(chunk.declarators.map(({ init }) => init))); + body.push(b.declaration(chunk.kind, [b.declarator(pattern, b.await(init))])); + } } } return {