Rich Harris 8 months ago
parent 5bb5a8f767
commit b788ec059a

@ -61,12 +61,14 @@ export function build_template_chunk(values, visit, state) {
'??', '??',
/** @type {Expression} */ (visit(node.expression, state)), /** @type {Expression} */ (visit(node.expression, state)),
b.literal('') b.literal('')
) ),
is_async
) )
) )
) )
); );
expressions.push(b.call('$.get', id));
expressions.push(is_async ? b.await(b.call('$.get', id)) : b.call('$.get', id));
} else if (values.length === 1) { } else if (values.length === 1) {
// If we have a single expression, then pass that in directly to possibly avoid doing // If we have a single expression, then pass that in directly to possibly avoid doing
// extra work in the template_effect (instead we do the work in set_text). // extra work in the template_effect (instead we do the work in set_text).

@ -426,12 +426,15 @@ export function thunk(expression, async = false) {
/** /**
* Replace "(arg) => func(arg)" to "func" * Replace "(arg) => func(arg)" to "func"
* @param {ESTree.Expression} expression * @param {ESTree.ArrowFunctionExpression} expression
* @returns {ESTree.Expression} * @returns {ESTree.Expression}
*/ */
export function unthunk(expression) { export function unthunk(expression) {
if (expression.async && expression.body.type === 'AwaitExpression') {
return unthunk(arrow(expression.params, expression.body.argument));
}
if ( if (
expression.type === 'ArrowFunctionExpression' &&
expression.async === false && expression.async === false &&
expression.body.type === 'CallExpression' && expression.body.type === 'CallExpression' &&
expression.body.callee.type === 'Identifier' && expression.body.callee.type === 'Identifier' &&

Loading…
Cancel
Save