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
Update regenerator-runtime to latest version #9442
Update regenerator-runtime to latest version #9442
Conversation
Unless something around this code changed since November, I can say that it will break the build, because Babel relies on the polyfill being a global, IIRC. How I found out: I use I may be wrong, but that's basically what happened: I used 0.13 with Babel 7.something, and things broke. |
You're right, the tests are failing. It looks like my local I guess |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/10505/ |
Hmm, it looks like var regeneratorRuntime = require('regenerator-runtime/runtime'); instead of just: require('regenerator-runtime/runtime') as reported in #9205. @benjamn @loganfsmyth Is it okay if I continue with this? Or do you think I should use a different approach? |
Sorry for the long silence. The changes look good to me, but yes we need to update Also I wonder what we should do in polyfill if the regenerator runtime does already exists on the global object? The old version of the regenerator-runtime was not overwriting and silently not doing anything if imported a second time. Should we do the same or trigger a warning? |
This way of |
Sure, I could help with that. I'm just not entirely certain on what approach we'd want to take, see below.
Good point. I'd say we should not overwrite the global if it already exists, so you can load a modified version of
Is this about this line? global.regeneratorRuntime = regeneratorRuntime; I'm pretty sure that CommonJS typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {} Otherwise,
I hadn't seen your pull request yet, looks very interesting! But indeed, with this new version of Do we need a wrapper around
Alternatively, we update |
See this issue.
Since now we haven't standard global object reference, without entry point which defines
But what should do import 'regenerator-runtime/runtime'; but how we can detect that we should remove import regeneratorRuntime from 'regenerator-runtime';
Function('return this')().regeneratorRuntime = regeneratorRuntime; ? Moreover, since we deprecate import 'core-js/stable';
import 'regenerator-runtime/runtime'; but not import 'core-js/stable';
import 'core-js/features/global-this';
import regeneratorRuntime from 'regenerator-runtime';
globalThis.regeneratorRuntime = regeneratorRuntime; |
Can we hold this PR until facebook/regenerator#369 is released? |
@benjamn Sure! I think whatever solution we come up with for Babel would involve defining |
packages/babel-polyfill/package.json
Outdated
@@ -12,6 +12,6 @@ | |||
"main": "lib/index.js", | |||
"dependencies": { | |||
"core-js": "^2.5.7", | |||
"regenerator-runtime": "^0.12.0" | |||
"regenerator-runtime": "^0.13.1" |
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.
"regenerator-runtime": "^0.13.1" | |
"regenerator-runtime": "^0.13.2" |
Version 0.13.2 includes facebook/regenerator#369, which defines regeneratorRuntime
globally without needing to detect the global object, using these two techniques.
@@ -10,7 +10,7 @@ | |||
"author": "Sebastian McKenzie <sebmck@gmail.com>", | |||
"dependencies": { | |||
"core-js": "^2.5.7", | |||
"regenerator-runtime": "^0.12.0" | |||
"regenerator-runtime": "^0.13.1" |
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.
"regenerator-runtime": "^0.13.1" | |
"regenerator-runtime": "^0.13.2" |
packages/babel-runtime/package.json
Outdated
@@ -9,7 +9,7 @@ | |||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-runtime", | |||
"author": "Sebastian McKenzie <sebmck@gmail.com>", | |||
"dependencies": { | |||
"regenerator-runtime": "^0.12.0" | |||
"regenerator-runtime": "^0.13.1" |
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.
"regenerator-runtime": "^0.13.1" | |
"regenerator-runtime": "^0.13.2" |
packages/babel-polyfill/src/index.js
Outdated
@@ -25,4 +25,5 @@ if (global._babelPolyfill && typeof console !== "undefined" && console.warn) { | |||
); | |||
} | |||
|
|||
global.regeneratorRuntime = 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.
This should no longer be necessary, though it also won't do any harm.
@@ -14,4 +14,5 @@ import "core-js/fn/promise/finally"; | |||
// Ensure that we polyfill ES6 compat for anything web-related, if it exists. | |||
import "core-js/web"; | |||
|
|||
import "regenerator-runtime/runtime"; | |||
import regeneratorRuntime from "regenerator-runtime/runtime"; | |||
global.regeneratorRuntime = 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.
The old import "regenerator-runtime/runtime"
should work fine here, too.
Cause of facebook/regenerator#369, I bumped |
Updated to version 0.13.2. However, I think there's still a problem with the new approach. The new I've suggested an alternative approach in a comment on facebook/regenerator#369. I would love to hear your thoughts on this. 🙂 |
I agree with you. Ideally the global variable assignment should be opt-in (or at least it should be possible to opt out). |
Correct. Sure, if it's okay that |
Seeing a lot of: _Object$defineProperty is not a function Scanning the release notes: https://github.com/babel/babel/releases This one stands out: https://github.com/babel/babel/releases/tag/v7.4.0 Specifically, "Update to core-js@3": babel/babel#7646 There are 133 comments which I confess to not having read, and various offshoots to places like: babel/babel#9442 and: facebook/regenerator#369 I did find this enormous update doc, but haven't found the answer in there yet and the Babel docs themselves don't appear to have been updated: https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md Although this blog post is briefer and covers a few things: https://babeljs.io/blog/2019/03/19/7.4.0 In the end the build works if I get rid of `@babel/plugin-transform-runtime`, which doesn't seem to play too well in conjunction with `@babel/preset-env`, at least in this set-up.
regenerator-runtime
(minor)Update
regenerator-runtime
from version0.12.0
to the latest version0.13.1
.facebook/regenerator#353 changes how the runtime defines the
regeneratorRuntime
global variable (when loaded as a script) or its module exports (when loaded as a CommonJS module). This obsoletes a previous attempt (facebook/regenerator#346) at fixing a CSP violation (facebook/regenerator#336). This change is a minor bump forregenerator-runtime
(because it no longer has a separateruntime-module.js
), but I don't think it will affect Babel users.facebook/regenerator#355 fixes a regression where IE8 would throw a parse error when loading the runtime (#1286).