-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Prevent regeneratorRuntime is not defined
errors by defensively copying targets
(preventing @babel/helper-compilation-targets
from mutating targets
)
#345
Merged
rwjblue
merged 1 commit into
emberjs:master
from
fivetanley:stitchfix-for-babel-compilation-helpers
May 30, 2020
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
Babel 7.10.0 [introduced a change that mutates the `targets` object passed into [`@babel/helper-compilation-targets`](babel/babel#11500). Since [ember-cli caches the value of `config/targets.js` on the Project](https://github.com/ember-cli/ember-cli/blob/master/lib/models/project.js#L271-L289), that means any subsequent calls to ember-cli-babel would lose `@babel/preset-env` options defined in `targets` if the ember-cli babel was included again anywhere else in the tree (which it usually is due to addons depending on ember-cli-babel). This would sometimes result in a `regeneratorRuntime is not defined` error for addons like Ember Concurrency that use ECMAScript features like generator functions or async functions, because the addon would not be compiled against the appropriate `browsers` list (or other `@babel/preset-env` options) because `@babel/helper-compilation-targets` mutated it away. This would happen usually in development or test, if [limiting the targets used in development](https://www.rwjblue.com/2017/10/30/async-await-configuration-adventure/#limit-targets-locally), which has been the [default in Ember CLI for a while now](ember-cli/ember-cli@7798114). As a workaround, we can copy the `targets` object before passing it to `@babel/helper-compilation-targets` as a workaround until the regression is [fixed upstream in babel](babel/babel#11648).
rwjblue
approved these changes
May 30, 2020
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.
Thank you again @fivetanley!
targets
so @babel/helper-compilation-targets can't mutate targets
regeneratorRuntime is not defined
errors by defensively copying targets
(preventing @babel/helper-compilation-targets
from mutating targets
)
HeroicEric
added a commit
to HeroicEric/ember-cli-babel
that referenced
this pull request
Jul 3, 2022
This removes a workaround that was added for a bug in `babel-helper-compilation-targets` that was fixed upstream and is included in the version that is required by this addon. The bugfix in `babel-helpers-compilation-targets` was included in `7.10.2` `ember-cli-babel@7.21.0` began requiring a version of `babel-helpers-compilation-targets` that includes the bugfix since `v7.21.0`. This addon has had a depenedency on `7.10.2` - [Original bugfix workaround PR](emberjs#345) - [`ember-cli-babel@7.21.0` Release notes](https://github.com/babel/ember-cli-babel/blob/master/CHANGELOG.md#v7210-2020-06-12) - [`babel-compilation-targets@7.10.2` Release notes](https://github.com/babel/babel/blob/main/CHANGELOG.md#v7102-2020-05-30)
HeroicEric
added a commit
to HeroicEric/ember-cli-babel
that referenced
this pull request
Jul 3, 2022
This removes a workaround that was added for a bug in `babel-helper-compilation-targets` that was fixed upstream and is included in the version that is required by this addon. The bugfix in `babel-helpers-compilation-targets` was included in [`v7.10.2`](https://github.com/babel/babel/releases/tag/v7.10.2) `ember-cli-babel` began requiring a version of `babel-helpers-compilation-targets` that includes the bugfix since [`v7.21.0`](https://github.com/babel/ember-cli-babel/releases/tag/v7.21.0) --- - [Original bugfix workaround PR](emberjs#345) - [Dependency upgrade PR](emberjs#354) - [`ember-cli-babel@7.21.0` Release notes](https://github.com/babel/ember-cli-babel/releases/tag/v7.21.0) - [`babel-compilation-targets@7.10.2` Release notes](https://github.com/babel/babel/releases/tag/v7.10.2)
bertdeblock
pushed a commit
to HeroicEric/ember-cli-babel
that referenced
this pull request
Nov 3, 2022
This removes a workaround that was added for a bug in `babel-helper-compilation-targets` that was fixed upstream and is included in the version that is required by this addon. The bugfix in `babel-helpers-compilation-targets` was included in [`v7.10.2`](https://github.com/babel/babel/releases/tag/v7.10.2) `ember-cli-babel` began requiring a version of `babel-helpers-compilation-targets` that includes the bugfix since [`v7.21.0`](https://github.com/babel/ember-cli-babel/releases/tag/v7.21.0) --- - [Original bugfix workaround PR](emberjs#345) - [Dependency upgrade PR](emberjs#354) - [`ember-cli-babel@7.21.0` Release notes](https://github.com/babel/ember-cli-babel/releases/tag/v7.21.0) - [`babel-compilation-targets@7.10.2` Release notes](https://github.com/babel/babel/releases/tag/v7.10.2)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Babel 7.10.0 introduced a change that mutates the
targets
object passed into@babel/helper-compilation-targets
. Since ember-cli caches the value ofconfig/targets.js
on the Project,that means any subsequent calls to ember-cli-babel would lose
@babel/preset-env
options defined intargets
if the ember-cli babel wasincluded again anywhere else in the tree (which it usually is due to addons depending on ember-cli-babel). This would sometimes result in a
regeneratorRuntime is not defined
error for addons like Ember Concurrency that use ECMAScript features like generator functions or async functions, because the addon would not be compiled against the appropriatebrowsers
list (or other@babel/preset-env
options) because@babel/helper-compilation-targets
mutated it away. This would happen usually in development or test, if limiting the targets used in development , which has been the default in Ember CLI for a while now. regenerator was not included in the host app because it was using the appropriate browserlist, and soember-maybe-import-regenerator
did not includeregenerator runtime
in the build. Ember concurrency then would get compiled without the appropriatetargets
, and would get compiled down to IE9/regenerator runtime instead of using native generator/async await syntax.As a workaround, we can copy the
targets
object before passing it to@babel/helper-compilation-targets
as a workaround until the regression is fixed upstream in babel.The yarn.lock changes were made to bring in babel 7.10.0 so we could test this change.