2
2
/** @import { AST } from '#compiler' */
3
3
/** @import { ComponentContext } from '../types' */
4
4
import { dev } from '../../../../state.js' ;
5
- import { extract_identifiers } from '../../../../utils/ast.js' ;
5
+ import { extract_identifiers , is_expression_async } from '../../../../utils/ast.js' ;
6
6
import * as b from '#compiler/builders' ;
7
7
import { create_derived } from '../utils.js' ;
8
8
import { get_value } from './shared/declarations.js' ;
@@ -17,7 +17,7 @@ export function ConstTag(node, context) {
17
17
// TODO we can almost certainly share some code with $derived(...)
18
18
if ( declaration . id . type === 'Identifier' ) {
19
19
const init = build_expression ( context , declaration . init , node . metadata . expression ) ;
20
- let expression = create_derived ( context . state , b . thunk ( init ) ) ;
20
+ let expression = create_derived ( context . state , b . thunk ( init , is_expression_async ( init ) ) ) ;
21
21
22
22
if ( dev ) {
23
23
expression = b . call ( '$.tag' , expression , b . literal ( declaration . id . name ) ) ;
@@ -58,7 +58,8 @@ export function ConstTag(node, context) {
58
58
b . block ( [
59
59
b . const ( /** @type {Pattern } */ ( context . visit ( declaration . id , child_state ) ) , init ) ,
60
60
b . return ( b . object ( identifiers . map ( ( node ) => b . prop ( 'init' , node , node ) ) ) )
61
- ] )
61
+ ] ) ,
62
+ is_expression_async ( init )
62
63
) ;
63
64
64
65
let expression = create_derived ( context . state , fn ) ;
0 commit comments