Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this PR, esbuild will now transform
async
generator functions into normal generator functions when the configured target environment doesn't support them. These functions behave similar to normal generator functions except that they use theSymbol.asyncIterator
interface instead of theSymbol.iterator
interface and the iteration methods return promises. Here's an example (helper functions are omitted):This is an older feature that was added to JavaScript in ES2018 but I didn't implement the transformation then because it's a rarely-used feature. Note that esbuild already added support for transforming
for await
loops (the other part of the asynchronous iteration proposal) a year ago, so support for asynchronous iteration should now be complete.I have never used this feature myself and code that uses this feature is hard to come by, so this transformation has not yet been tested on real-world code. If you do write code that uses this feature, please let me know if esbuild's
async
generator transformation doesn't work with your code.Fixes #2780