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
Define the global regeneratorRuntime
in @babel/runtime/regenerator
#14581
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/52006/ |
regeneratorRuntime = runtime; | ||
} catch (accidentalStrictMode) { | ||
if (typeof globalThis === "object") { | ||
globalThis.regeneratorRuntime = runtime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove the global definition behind the BABEL_8_BREAKING
flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this file isn't compiled.
module.exports = require("../helpers/regeneratorRuntime")(); | ||
// TODO(Babel 8): Remove this file. | ||
|
||
const runtime = require("../helpers/regeneratorRuntime")(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more appropriate to use var
like runtime helpers, otherwise, this code needs to be compiled into es5 with babel self 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for that, we released the fix 2 minutes ago!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 🚀
Even if
@babel/runtime' was documented as being a pure set of helpers and the
@babel/runtime/regeneratorentry point exported the
regeneratorRuntimehelper, it also accientally used to define a
regeneratorRuntimeglobal due to its depenency on
regenerator-runtime`.Many packages relied on this global being "accidentally" present due to something else in the dependencies tree loading
@babel/runtime/regenerator
. I'm annoyed by this, but let's restore the old (accidental and undocumented) behavior because I have already seen multiple repositories with this problem. We'll remove this legacy entry point in Babel 8.Closes #14576.