Skip to content
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

Merged
merged 1 commit into from May 25, 2022

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented May 24, 2022

Q                       A
Fixed Issues? Fixes #14576
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Even if @babel/runtime' was documented as being a pure set of helpers and the @babel/runtime/regeneratorentry point exported theregeneratorRuntimehelper, it also accientally used to define aregeneratorRuntimeglobal due to its depenency onregenerator-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.

@babel-bot
Copy link
Collaborator

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;
Copy link
Contributor

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?

Copy link
Member Author

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")();
Copy link
Contributor

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 👀

Copy link
Member Author

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!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🚀

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Aug 25, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: @babel/runtime v7.18.0 cause a runtime "regeneratorRuntime is not defined" error
5 participants