Prevent regeneratorRuntime is not defined
errors by defensively copying targets
(preventing @babel/helper-compilation-targets
from mutating targets
)
#345
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.