This repository has been archived by the owner on Feb 1, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Convert runtime.js to a normal CommonJS module. #353
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If this works, then it removes the need for hacks to discover the global object, which continue to be problematic (e.g. #336, #346). Importantly, the regenerator-runtime/runtime.js module can still be evaluated as a non-CJS script, and it will not pollute the global scope except for defining regeneratorRuntime.
@Benjamin-Dobell Thoughts on this approach? |
@benjamn Any chance you could push out a patch release for this? |
This was referenced Nov 16, 2018
Closed
So - I think this caused my build to fail. Is it Babel's responsibility to make this global? |
Thanks for the release! 🙂 Since this is a minor bump on a 0.x release, packages such as |
I've opened babel/babel#9442 to update |
benjamn
added a commit
that referenced
this pull request
Mar 7, 2019
In #353, I simplified the implementation of regenerator-runtime by converting runtime.js to a normal CommonJS module. No more global object detection, and no more sneaky capture/deletion of regeneratorRuntime. Unfortunately, folks who use only @babel/polyfill and not @babel/transform-runtime may have existing code that relies on a global regeneratorRuntime variable. That code will eventually disappear (:crossed-fingers:), but in the meantime we can continue supporting it by simply ensuring that regeneratorRuntime is defined globally as a side-effect of importing regenerator-runtime. This turns out to be much easier than detecting the global object, as long as runtime.js runs as a non-strict CommonJS module. See my code comments for another fallback solution that should cover all remaining cases. Background discussion: babel/babel#7646 (comment) Fixes #363. Fixes #337. Fixes #367.
benjamn
added a commit
that referenced
this pull request
Mar 7, 2019
* Define regeneratorRuntime globally as a side-effect, again. In #353, I simplified the implementation of regenerator-runtime by converting runtime.js to a normal CommonJS module. No more global object detection, and no more sneaky capture/deletion of regeneratorRuntime. Unfortunately, folks who use only @babel/polyfill and not @babel/transform-runtime may have existing code that relies on a global regeneratorRuntime variable. That code will eventually disappear (:crossed_fingers:), but in the meantime we can continue supporting it by simply ensuring that regeneratorRuntime is defined globally as a side-effect of importing regenerator-runtime. This turns out to be much easier than detecting the global object, as long as runtime.js runs as a non-strict CommonJS module. See my code comments for another fallback solution that should cover all remaining cases. Background discussion: babel/babel#7646 (comment) Fixes #363. Fixes #337. Fixes #367. * Update regenerator/package-lock.json. * Fix Travis CI tests by running `npm i` instead of `npm ci`. * Prevent Travis from running `npm ci` by default.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If this works, then it removes the need for hacks to discover the global object, which continues to be problematic (e.g. #336, #346).
Importantly, the
regenerator-runtime/runtime.js
module can still be evaluated as a non-CJS script, and it will not pollute the global scope except for definingregeneratorRuntime
.