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
Support iterating generators in browsers without Symbol
#13129
Support iterating generators in browsers without Symbol
#13129
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/45241/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit a664ac3:
|
That was fast 🤩 |
It's a crutch and solves only a part of the problem. As you could see, #13128 use polyfilling with The actual The proper solution here - if you load a polyfill with |
The goal of this PR is to allow using generators without a polyfill, similarly to how array spread or array for-of works without polyfills.
Wouldn't that make it incompatible with some Firefox versions, that implemented the iterator protocol before implementing symbol support? |
However, #13128 uses polyfills.
Nobody bothers to implement iterators from scratch. It will not work with |
b76c3ec
to
46e7748
Compare
I'm merging this since:
As @zloirock noted the fix isn't complete, and we'll need to polyfill symbols when using generators. |
In browsers without
Symbol
support and without aSymbol
polyfill, regenerator uses@@iterator
/@@asyncIterator
to mark (async) generators as iterable. (ref)Since from a user point of view regenerator is effectively part of Babel (because we use it by default in
@babel/preset-env
), we should make sure that it works well with the other plugins.This PR adds checks for
@@iterator
/@@asyncIterator
in the spread and for-of helpers, so that they work with compiled generators.