This commit is contained in:
Dmitry Vasilev
2022-12-07 05:42:33 +08:00
parent 707c34bc66
commit 3ea0bedc31
7 changed files with 84 additions and 36 deletions

View File

@@ -203,9 +203,20 @@ export const topsort_modules = (modules) => {
}
export const has_toplevel_await = modules =>
Object.values(modules).some(m =>
m.children.find(c => c.type == 'unary' && c.operator == 'await' ) != null
)
Object.values(modules).some(m => node_has_toplevel_await(m))
const node_has_toplevel_await = node => {
if(node.type == 'unary' && node.operator == 'await') {
return true
}
if(node.type == 'function_expr') {
return false
}
if(node.children == null) {
return false
}
return node.children.find(c => node_has_toplevel_await(c)) != null
}
// TODO not implemented
// TODO detect cycles when loading modules