You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Version (complete output of terser -V or specific git commit)
$ terser -Vterser 5.15.1
Complete CLI command or minify() options used
I turned off the unsafe option.
$ terser input.js -c unsafe=false
terser input
"use strict";await+0;
or
"use strict";await();
terser output or error
"use strict";await0;
Expected result
Input codes throw ReferenceError:
$ node -e '"use strict"; await + 0;'ReferenceError: await is not defined at [eval]:1:1 at Script.runInThisContext (node:vm:129:12) at Object.runInThisContext (node:vm:313:38) at node:internal/process/execution:79:19 at [eval]-wrapper:6:22 at evalScript (node:internal/process/execution:78:60) at node:internal/main/eval_string:28:3Node.js v18.11.0
$ node -e '"use strict"; await ( ) ;'ReferenceError: await is not defined...
but output code throws SyntaxError:
$ node -e '"use strict"; await 0 ;'[eval]:1"use strict"; await 0 ; ^^^^^SyntaxError: await is only valid in async functions and the top level bodies of modules at new Script (node:vm:100:7) at createScript (node:vm:265:10) at Object.runInThisContext (node:vm:313:10) at node:internal/process/execution:79:19 at [eval]-wrapper:6:22 at evalScript (node:internal/process/execution:78:60) at node:internal/main/eval_string:28:3Node.js v18.11.0
The text was updated successfully, but these errors were encountered:
I think the way I'll solve this is by allowing await on the top-level, at least by default, that is to assume the source code is an ES module for the case of await.
Bug report
Version (complete output of
terser -V
or specific git commit)Complete CLI command or
minify()
options usedI turned off the
unsafe
option.$ terser input.js -c unsafe=false
terser
inputor
terser
output or errorExpected result
Input codes throw
ReferenceError
:but output code throws
SyntaxError
:The text was updated successfully, but these errors were encountered: