Skip to content

Commit ddd6176

Browse files
authored
Acorn optimizer: Allow top-level await expressions (#21117)
`-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.
1 parent c4d76b8 commit ddd6176

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

test/test_other.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ def test_export_es6_allows_export_in_post_js(self):
407407
@parameterized({
408408
'': ([],),
409409
# load a worker before startup to check ES6 modules there as well
410-
'pthreads': (['-pthread', '-sPTHREAD_POOL_SIZE=1'],),
410+
# pass -O2 to ensure the worker JS file is minified with Acorn
411+
'pthreads': (['-O2', '-pthread', '-sPTHREAD_POOL_SIZE=1'],),
411412
})
412413
def test_export_es6(self, args, package_json):
413414
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORT_ES6',

tools/acorn-optimizer.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,6 +2029,7 @@ try {
20292029
preserveParens: closureFriendly,
20302030
onComment: closureFriendly ? sourceComments : undefined,
20312031
sourceType: exportES6 ? 'module' : 'script',
2032+
allowAwaitOutsideFunction: true,
20322033
});
20332034
} catch (err) {
20342035
err.message += (() => {

0 commit comments

Comments
 (0)