Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
feat: support top-level await in modules
Browse files Browse the repository at this point in the history
I thought this was turned on logn ago. But I forgot a flag in the parser as well as declaring the variable that holds the value being pass to await.
  • Loading branch information
lachrist committed Feb 15, 2022
1 parent ea17330 commit 60ee6e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions components/instrumentation/default/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export default (dependencies) => {
parseEstree(content, {
allowHashBang: true,
sourceType: type,
allowAwaitOutsideFunction: type === "module",
ecmaVersion: configuration.language.version,
locations: true,
}),
Expand Down
6 changes: 6 additions & 0 deletions components/instrumentation/default/visit.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,12 @@ export default (dependencies) => {
type: "Program",
sourceType: type,
body: [
makeVariableDeclaration("let", [
makeVariableDeclarator(
makeIdentifier(`${runtime}_JUMP`),
makeLiteral(null),
),
]),
makeVariableDeclaration("let", [
makeVariableDeclarator(
makeIdentifier(`${runtime}_JUMP_ID`),
Expand Down
3 changes: 2 additions & 1 deletion components/instrumentation/default/visit.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ assertEqual(
),
normalize(
`
let $_JUMP_ID = null
let $_JUMP = null;
let $_JUMP_ID = null;
try { } catch ($_ERROR) {
if ($_JUMP_ID !== null) {
$.recordAfterJump($_JUMP_ID);
Expand Down

0 comments on commit 60ee6e6

Please sign in to comment.