Support iterating generators in browsers without Symbol#13129
Support iterating generators in browsers without Symbol#13129nicolo-ribaudo merged 5 commits intobabel:mainfrom
Symbol#13129Conversation
|
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
Symbolsupport and without aSymbolpolyfill, regenerator uses@@iterator/@@asyncIteratorto 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/@@asyncIteratorin the spread and for-of helpers, so that they work with compiled generators.