pull/17038/head
Rich Harris 1 week ago
parent 3e7589360a
commit d18d1b9fae

@ -693,18 +693,46 @@ export function analyze_component(root, source, options) {
let awaiting = false; let awaiting = false;
let i = 0; let i = 0;
for (const node of instance.ast.body) { for (let node of instance.ast.body) {
const has_await = has_await_expression(node); if (node.type === 'ExportNamedDeclaration' && node.declaration) {
awaiting ||= has_await; node = node.declaration;
}
if (node.type === 'VariableDeclaration') {
for (const declarator of node.declarations) {
const has_await = has_await_expression(declarator);
awaiting ||= has_await;
if (!awaiting) continue;
if (!awaiting) continue; const id = b.id(`$$${i++}`);
for (const identifier of extract_identifiers(declarator.id)) {
analysis.awaited_declarations.set(identifier.name, {
id,
has_await,
pattern: declarator.id,
updated_by: new Set()
});
}
}
} else {
const has_await = has_await_expression(node);
awaiting ||= has_await;
const id = b.id(`$$${i++}`); if (!awaiting) continue;
analysis.awaited_statements.set(node, { if (node.type === 'ClassDeclaration' || node.type === 'FunctionDeclaration') {
id, throw new Error('TODO handle class/function declaration');
has_await } else {
}); const id = b.id(`$$${i++}`);
analysis.awaited_statements.set(node, {
id,
has_await
});
}
}
} }
} }

@ -126,7 +126,7 @@ export interface ComponentAnalysis extends Analysis {
*/ */
awaited_declarations: Map< awaited_declarations: Map<
string, string,
{ id: Identifier; pattern: Pattern; updated_by: Set<Identifier> } { id: Identifier; has_await: boolean; pattern: Pattern; updated_by: Set<Identifier> }
>; >;
/** /**
* Information about top-level instance statements that need to be transformed * Information about top-level instance statements that need to be transformed

Loading…
Cancel
Save