Skip to content

Commit

Permalink
Acorn optimizer: Allow top-level await expressions (#21117)
Browse files Browse the repository at this point in the history
`-pthread` + `-sEXPORT_ES6` emits a top-level await expression
in the main worker file after commit 49ab23a. Ensure the Acorn
optimizer is aware of this.
  • Loading branch information
kleisauke committed Jan 25, 2024
1 parent c4d76b8 commit ddd6176
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ def test_export_es6_allows_export_in_post_js(self):
@parameterized({
'': ([],),
# load a worker before startup to check ES6 modules there as well
'pthreads': (['-pthread', '-sPTHREAD_POOL_SIZE=1'],),
# pass -O2 to ensure the worker JS file is minified with Acorn
'pthreads': (['-O2', '-pthread', '-sPTHREAD_POOL_SIZE=1'],),
})
def test_export_es6(self, args, package_json):
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORT_ES6',
Expand Down
1 change: 1 addition & 0 deletions tools/acorn-optimizer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,7 @@ try {
preserveParens: closureFriendly,
onComment: closureFriendly ? sourceComments : undefined,
sourceType: exportES6 ? 'module' : 'script',
allowAwaitOutsideFunction: true,
});
} catch (err) {
err.message += (() => {
Expand Down

0 comments on commit ddd6176

Please sign in to comment.