Skip to content

Commit b788ec0

Browse files
committed
fix
1 parent 5bb5a8f commit b788ec0

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ export function build_template_chunk(values, visit, state) {
6161
'??',
6262
/** @type {Expression} */ (visit(node.expression, state)),
6363
b.literal('')
64-
)
64+
),
65+
is_async
6566
)
6667
)
6768
)
6869
);
69-
expressions.push(b.call('$.get', id));
70+
71+
expressions.push(is_async ? b.await(b.call('$.get', id)) : b.call('$.get', id));
7072
} else if (values.length === 1) {
7173
// If we have a single expression, then pass that in directly to possibly avoid doing
7274
// extra work in the template_effect (instead we do the work in set_text).

packages/svelte/src/compiler/utils/builders.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,15 @@ export function thunk(expression, async = false) {
426426

427427
/**
428428
* Replace "(arg) => func(arg)" to "func"
429-
* @param {ESTree.Expression} expression
429+
* @param {ESTree.ArrowFunctionExpression} expression
430430
* @returns {ESTree.Expression}
431431
*/
432432
export function unthunk(expression) {
433+
if (expression.async && expression.body.type === 'AwaitExpression') {
434+
return unthunk(arrow(expression.params, expression.body.argument));
435+
}
436+
433437
if (
434-
expression.type === 'ArrowFunctionExpression' &&
435438
expression.async === false &&
436439
expression.body.type === 'CallExpression' &&
437440
expression.body.callee.type === 'Identifier' &&

0 commit comments

Comments
 (0)