diff --git a/packages/svelte/src/compiler/phases/3-transform/client/utils.js b/packages/svelte/src/compiler/phases/3-transform/client/utils.js index 5a372e17bc..efb06c4996 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/utils.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/utils.js @@ -38,9 +38,10 @@ export function is_state_source(binding, analysis) { */ export function can_be_parallelized(expression, scope, analysis, bindings) { let has_closures = false; + let should_stop = false; /** @type {Set} */ const references = new Set(); - walk(expression, null, { + walk(/** @type {Node} */ (expression), null, { ArrowFunctionExpression(_, { stop }) { has_closures = true; stop(); @@ -53,9 +54,25 @@ export function can_be_parallelized(expression, scope, analysis, bindings) { if (is_reference(node, /** @type {Node} */ (path.at(-1)))) { references.add(node.name); } + }, + MemberExpression(node, { stop }) { + should_stop = true; + stop(); + }, + CallExpression(node, { stop }) { + should_stop = true; + stop(); + }, + NewExpression(node, { stop }) { + should_stop = true; + stop(); + }, + StaticBlock(node, { stop }) { + has_closures = true; + stop(); } }); - if (has_closures) { + if (has_closures || should_stop) { return false; } for (const reference of references) { 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 a4a1084da4..1e9789e9d5 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 @@ -153,7 +153,7 @@ export function Program(node, context) { ); } else { const pattern = b.array_pattern(chunk.declarators.map(({ id }) => id)); - const init = b.call('$.all', b.array(chunk.declarators.map(({ init }) => init))); + const init = b.call('$.all', ...chunk.declarators.map(({ init }) => init)); body.push(b.declaration(chunk.kind, [b.declarator(pattern, b.await(init))])); } }