Skip to content

Commit 24164f9

Browse files
committed
fix
1 parent 41eeaba commit 24164f9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

packages/svelte/src/compiler/phases/3-transform/client/visitors/ExpressionStatement.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/** @import { Expression, ExpressionStatement, Node, Program } from 'estree' */
22
/** @import { ComponentContext, ParallelizedChunk } from '../types' */
33
import * as b from '#compiler/builders';
4+
import { is_expression_async } from '../../../../utils/ast.js';
45
import { get_rune } from '../../../scope.js';
56
import { can_be_parallelized } from '../utils.js';
67

@@ -30,6 +31,7 @@ export function ExpressionStatement(node, context) {
3031
}
3132
if (
3233
node.expression.type === 'AwaitExpression' &&
34+
!is_expression_async(node.expression.argument) &&
3335
context.state.analysis.instance?.scope === context.state.scope
3436
) {
3537
const current_chunk = context.state.current_parallelized_chunk;

packages/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/** @import { Binding } from '#compiler' */
33
/** @import { ComponentContext, ParallelizedChunk } from '../types' */
44
import { dev, is_ignored, locate_node } from '../../../../state.js';
5-
import { extract_paths } from '../../../../utils/ast.js';
5+
import { extract_paths, is_expression_async } from '../../../../utils/ast.js';
66
import * as b from '#compiler/builders';
77
import * as assert from '../../../../utils/assert.js';
88
import { get_rune } from '../../../scope.js';
@@ -49,7 +49,8 @@ export function VariableDeclaration(node, context) {
4949
}
5050
if (
5151
init?.type === 'AwaitExpression' &&
52-
context.state.analysis.instance?.scope === context.state.scope
52+
context.state.analysis.instance?.scope === context.state.scope &&
53+
!is_expression_async(init.argument)
5354
) {
5455
const current_chunk = context.state.current_parallelized_chunk;
5556
const parallelize = can_be_parallelized(
@@ -182,6 +183,7 @@ export function VariableDeclaration(node, context) {
182183
declarator.id.type === 'Identifier' &&
183184
context.state.analysis.instance?.scope === context.state.scope &&
184185
value.type === 'AwaitExpression' &&
186+
!is_expression_async(value.argument) &&
185187
can_be_parallelized(value.argument, context.state.scope, context.state.analysis, [
186188
...(current_chunk?.bindings ?? []),
187189
...bindings
@@ -317,10 +319,12 @@ export function VariableDeclaration(node, context) {
317319
const current_chunk = context.state.current_parallelized_chunk;
318320
if (
319321
is_async &&
322+
init.type === 'AwaitExpression' &&
320323
context.state.analysis.instance &&
321324
context.state.scope === context.state.analysis.instance.scope &&
322325
// TODO make it work without this
323-
declarator.id.type === 'Identifier'
326+
declarator.id.type === 'Identifier' &&
327+
!is_expression_async(init.argument)
324328
) {
325329
parallelize = can_be_parallelized(value, context.state.scope, context.state.analysis, [
326330
...(current_chunk?.bindings ?? []),

0 commit comments

Comments
 (0)