-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Top-level await is not available in the configured target environment" #1096
Comments
Some language features can be transpiled but others can't be. Top-level await can't really be transpiled because there's no equivalent older syntax. Up until the introduction of top-level await, all ESM module evaluation was synchronous. There was no way to insert an asynchronous step at the top-level. |
@evanw This requires a bundler to be aware of top-level awaits, but I don't see fundamental problems with this. Webpack supports this, doesn't it? I guess an equivalent is that every module export is wrapped with async IIFE. |
Webpack doesn't even support the ESM output format at all I think (open issue: webpack/webpack#2933) so it's not equivalent. I'm planning to add support for top-level await to the IIFE output format for esbuild, in which case this should work. |
Closing this as a duplicate of #253, which is the general open issue for top-level await support. I'm using that issue to represent adding top-level await support to the IIFE format. |
I thought that ESBuild was meant to be able to transpile code so it works in older browsers? Or is the point of
target
just to show me errors telling me I can't use certain features?My output format is ES modules, in which I thought top level await is meant to be able to work?
The text was updated successfully, but these errors were encountered: