From c41900c66623626e3f6d92afcdcbdbd8db1d9714 Mon Sep 17 00:00:00 2001 From: ComputerGuy <63362464+Ocean-OS@users.noreply.github.com> Date: Fri, 29 Aug 2025 20:55:19 -0700 Subject: [PATCH] more --- .../client/visitors/VariableDeclaration.js | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 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 2461c74dff..ad9f6993d9 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 @@ -51,11 +51,12 @@ export function VariableDeclaration(node, context) { init?.type === 'AwaitExpression' && context.state.analysis.instance?.scope === context.state.scope ) { + const current_chunk = context.state.current_parallelized_chunk; const parallelize = can_be_parallelized( init.argument, context.state.scope, context.state.analysis, - [...(context.state.current_parallelized_chunk?.bindings ?? []), ...bindings] + [...(current_chunk?.bindings ?? []), ...bindings] ); if (parallelize) { const { id, init: visited_init } = /** @type {VariableDeclarator} */ ( @@ -68,15 +69,10 @@ export function VariableDeclaration(node, context) { id, init: /** @type {Expression} */ (visited_init) }; - if ( - context.state.current_parallelized_chunk && - context.state.current_parallelized_chunk.kind === node.kind - ) { - context.state.current_parallelized_chunk.declarators.push(_declarator); - context.state.current_parallelized_chunk.bindings.push(...bindings); - context.state.current_parallelized_chunk.position = /** @type {Program} */ ( - parent - ).body.indexOf(node); + if (current_chunk && current_chunk.kind === node.kind) { + current_chunk.declarators.push(_declarator); + current_chunk.bindings.push(...bindings); + current_chunk.position = /** @type {Program} */ (parent).body.indexOf(node); } else { /** @type {ParallelizedChunk} */ const chunk = { @@ -251,6 +247,7 @@ export function VariableDeclaration(node, context) { /** @type {CallExpression} */ (init) ); let parallelize = false; + const current_chunk = context.state.current_parallelized_chunk; if ( is_async && context.state.analysis.instance && @@ -259,7 +256,7 @@ export function VariableDeclaration(node, context) { declarator.id.type === 'Identifier' ) { parallelize = can_be_parallelized(value, context.state.scope, context.state.analysis, [ - ...(context.state.current_parallelized_chunk?.bindings ?? []), + ...(current_chunk?.bindings ?? []), ...context.state.scope.get_bindings(declarator) ]); } @@ -369,18 +366,14 @@ export function VariableDeclaration(node, context) { if (!parallelize) { declarations.push(...derived_declarators); } else if (derived_declarators.length > 0) { - /** @type {ParallelizedChunk['declarators']} */ const declarators = derived_declarators.map(({ id, init }) => ({ id, init: /** @type {Expression} */ (init) })); - if ( - context.state.current_parallelized_chunk && - context.state.current_parallelized_chunk.kind === node.kind - ) { - context.state.current_parallelized_chunk.declarators.push(...declarators); - context.state.current_parallelized_chunk.bindings.push(...bindings); - context.state.current_parallelized_chunk.position = position; + if (current_chunk && current_chunk.kind === node.kind) { + current_chunk.declarators.push(...declarators); + current_chunk.bindings.push(...bindings); + current_chunk.position = position; } else { /** @type {ParallelizedChunk} */ const chunk = {