bare imports

This commit is contained in:
Dmitry Vasilev
2022-12-01 02:07:55 +08:00
parent c0327cb8be
commit 536afd88b5
4 changed files with 46 additions and 12 deletions

View File

@@ -240,7 +240,11 @@ const codegen = (node, cxt, parent) => {
return do_codegen(node.key) + ' : ' + do_codegen(node.value);
} else if(node.type == 'import') {
const names = node.imports.map(n => n.value)
return `const {${names.join(',')}} = __modules['${node.full_import_path}'];`;
if(names.length == 0) {
return ''
} else {
return `const {${names.join(',')}} = __modules['${node.full_import_path}'];`;
}
} else if(node.type == 'export') {
const identifiers = collect_destructuring_identifiers(node.binding.name_node)
.map(i => i.value)