parse import expressions correctly (#5551)

fixes #5550
This commit is contained in:
Alex Lam S.L
2022-07-08 12:25:30 +01:00
committed by GitHub
parent b2bc2e1173
commit 0b808f6428
2 changed files with 34 additions and 6 deletions

View File

@@ -858,13 +858,11 @@ function parse($TEXT, options) {
next();
return export_();
case "import":
if (!toplevel && options.module !== "") unexpected();
var token = peek();
if (!(token.type == "punc" && /^[(.]$/.test(token.value))) {
next();
return import_();
}
break;
if (token.type == "punc" && /^[(.]$/.test(token.value)) break;
if (!toplevel && options.module !== "") unexpected();
next();
return import_();
case "let":
if (is_vardefs()) {
next();