[Feature] default to top-level-await
Motivation
while it's possible via // @top-level-await (#833), i think this behavior could be default.
Proposed Solution
make this flag the default.
Use Cases
- it's convenient to
awaitweb APIs.
const isIncognito = await navigator.storage.getDirectory().then(() => false).catch(() => true)
(code from https://github.com/Joe12387/detectIncognito/issues/51)
- less surprises to people new to userscript that expects valid JS syntax to work
I disagree because it's not enabled by default, this is not "valid JS syntax" out of the box. One must explicitly declare a module in order to enable it, so declaring @top-level-await serves the same purpose.
Another problem is that the browser.userScripts API doesn't allow registering a module, meaning that top-level await won't work for userscripts registered in their own isolated JS world that can be done without the intermediate wrapper added by the extension, the way it's been done forever in Firefox and recently implemented in Chrome's MV3.