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
Regenerator relies on Function#name, breaks minifiers #283
Comments
Also see mishoo/UglifyJS#552 |
I've done a possible fix. I'm going to spend some time rewriting the regenerator runtime and simplifying it. It'll have to be released with 2.0.0 though due to breaking changes and incompatible API. |
@sebmck I'm glad you fixed it, but how are you going to stay up-to-date with regenerator's runtime? It sounds like you want to completely fork it. Would be nice to see if we could merge changes upstream. |
@jlongster We wouldn't. Maintenance of the regenerator runtime is minimal compared to everything else. |
Thanks! Released as of 1.15.0. |
Please don't spend any time rewriting the regenerator runtime without looping me in! I'm sincerely confused why no one CC'd me here. You didn't even want to know why that assertion exists? Come on, people: facebook/regenerator#156 |
@benjamn I'm sorry you weren't CC'd. 6to5 moves at a really fast pace than other tools so this kind of thing becomes somewhat necessary. However, it's a goal to bring bug fixes and features back into the original libraries. |
@benjamn We know why the assertion exists, in fact I discuss it a bit in the first post. I personally don't care if the constructor is the correct name and don't want an error raised if it isn't. I feel easy minification is much, much more important than spec compliance in this corner case. Note that if you DO care what the constructor name is, you can configure your preferred minifier to not mangle that name. We can even put a note in the documentation. |
In 6to5 2.13.3 I am still getting |
@aaronshaf Where are you getting the polyfill/runtime from? regenerator/runtime.js doesn't include the |
* account for web.iterable * extra test, remove unncessary warning
* account for web.iterable * extra test, remove unncessary warning
* Update CHANGELOG.md * Update CHANGELOG.md [skip ci]
See here.
The author of this code tries to be clever and set
GF.name
in the line above, but this actually isn't possible to do (try it in Chrome or Firefox, it will just ignore the assignment).Having
"GeneratorFunction"
as the constructor name is mandated by the specification. However, I would argue it's not a very important part of the specification, and that convenient minification is much more important. At the very least, thethrow
line should be removed, so people who don't care what the constructor name is aren't affected. It's worth noting that Regenerator itself does not care what the constructor name is.However, there is a case for removing the
"GeneratorFunction"
trick altogether: it would allow for removing themark()
call in the following, improving the readability of the generated code:Here's the issue which lead to
mark
being added: facebook/regenerator#48. The primary reason seems to be allowing theco
library to perform some magic to distinguish between regular functions and generator functions. I guess I'm not swayed by this becauseco
isn't very useful when you have async functions (like we do).The text was updated successfully, but these errors were encountered: