|
2 | 2 | /** @import { Binding } from '#compiler' */ |
3 | 3 | /** @import { ComponentContext, ParallelizedChunk } from '../types' */ |
4 | 4 | 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'; |
6 | 6 | import * as b from '#compiler/builders'; |
7 | 7 | import * as assert from '../../../../utils/assert.js'; |
8 | 8 | import { get_rune } from '../../../scope.js'; |
@@ -49,7 +49,8 @@ export function VariableDeclaration(node, context) { |
49 | 49 | } |
50 | 50 | if ( |
51 | 51 | 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) |
53 | 54 | ) { |
54 | 55 | const current_chunk = context.state.current_parallelized_chunk; |
55 | 56 | const parallelize = can_be_parallelized( |
@@ -182,6 +183,7 @@ export function VariableDeclaration(node, context) { |
182 | 183 | declarator.id.type === 'Identifier' && |
183 | 184 | context.state.analysis.instance?.scope === context.state.scope && |
184 | 185 | value.type === 'AwaitExpression' && |
| 186 | + !is_expression_async(value.argument) && |
185 | 187 | can_be_parallelized(value.argument, context.state.scope, context.state.analysis, [ |
186 | 188 | ...(current_chunk?.bindings ?? []), |
187 | 189 | ...bindings |
@@ -317,10 +319,12 @@ export function VariableDeclaration(node, context) { |
317 | 319 | const current_chunk = context.state.current_parallelized_chunk; |
318 | 320 | if ( |
319 | 321 | is_async && |
| 322 | + init.type === 'AwaitExpression' && |
320 | 323 | context.state.analysis.instance && |
321 | 324 | context.state.scope === context.state.analysis.instance.scope && |
322 | 325 | // TODO make it work without this |
323 | | - declarator.id.type === 'Identifier' |
| 326 | + declarator.id.type === 'Identifier' && |
| 327 | + !is_expression_async(init.argument) |
324 | 328 | ) { |
325 | 329 | parallelize = can_be_parallelized(value, context.state.scope, context.state.analysis, [ |
326 | 330 | ...(current_chunk?.bindings ?? []), |
|
0 commit comments