-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 Flow to 0.123.0 #11500
Update Flow to 0.123.0 #11500
Conversation
delete inputTargets.browsers; | ||
|
||
// $FlowIgnore | ||
let targets = (inputTargets: Targets); |
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.
It was complaining a lot because esmodules
/browsers
are not part of Targets
, which should contain the resolved targets.
@@ -14,7 +15,4 @@ export const TargetNames = { | |||
android: "android", | |||
electron: "electron", | |||
samsung: "samsung", | |||
|
|||
// deprecated | |||
uglify: "uglify", |
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.
In practice, we handle this by deleting targets.uglify
before using this object.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/21661/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 8e592d2:
|
Ok I broke something |
I had to refactor a bit |
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.
👍 I started working on this PR a few weeks back and ran into the same thing. Never picked it back up but this was the path I was headed to, nice work!
If `@babel/helper-compilation-targets` is called directly, as it is in the [Ember-CLI babel](https://github.com/babel/ember-cli-babel/blob/6f76f405b9dd2a48cce394c4826dd50847f74282/index.js#L543-L545) and [Vue CLI](https://github.com/vuejs/vue-cli/blob/c8cecffedbf7b19cf930bb2821b5c352bc716a67/packages/%40vue/babel-preset-app/index.js#L17) integrations, we don't want to mutate the input passed in. At least in Ember CLI, babel could be called multiple times. So, on subsequent passes all `browsers` and `esmodules` info would be lost (and losing the `browsers` info affects the output in negative ways.. Copying the object before dropping keys allows callers not have to worry about babel mutating the object they pass in. Switching to a more functional approach makes it easier for babel to not worry about what consumers are passing in. Dropping the `browser` property was introduced in: babel#11500 Dropping the `esmodules` property was introduced in babel#11124 Discussion about dropping the `esmodules` property: babel#11124 (comment)
If `@babel/helper-compilation-targets` is called directly, as it is in the [Ember-CLI babel](https://github.com/babel/ember-cli-babel/blob/6f76f405b9dd2a48cce394c4826dd50847f74282/index.js#L543-L545) and [Vue CLI](https://github.com/vuejs/vue-cli/blob/c8cecffedbf7b19cf930bb2821b5c352bc716a67/packages/%40vue/babel-preset-app/index.js#L17) integrations, we don't want to mutate the input passed in. At least in Ember CLI, babel could be called multiple times. So, on subsequent passes all `browsers` and `esmodules` info would be lost (and losing the `browsers` info affects the output in negative ways). Copying the object before dropping keys allows callers not have to worry about babel mutating the object they pass in. Switching to a more functional approach makes it easier for babel to not worry about what consumers are passing in. Dropping the `browser` property was introduced in: babel#11500 Dropping the `esmodules` property was introduced in babel#11124 Discussion about dropping the `esmodules` property: babel#11124 (comment)
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).
…argets If `@babel/helper-compilation-targets` is called directly, as it is in the [Ember-CLI babel](https://github.com/babel/ember-cli-babel/blob/6f76f405b9dd2a48cce394c4826dd50847f74282/index.js#L543-L545) and [Vue CLI](https://github.com/vuejs/vue-cli/blob/c8cecffedbf7b19cf930bb2821b5c352bc716a67/packages/%40vue/babel-preset-app/index.js#L17) integrations, we don't want to mutate the input passed in. At least in Ember CLI, babel could be called multiple times. So, on subsequent passes all `browsers` and `esmodules` info would be lost (and losing the `browsers` info affects the output in negative ways). Copying the object before dropping keys allows callers not have to worry about babel mutating the object they pass in. Switching to a more functional approach makes it easier for babel to not worry about what consumers are passing in. Dropping the `browser` property was introduced in: babel#11500 Dropping the `esmodules` property was introduced in babel#11124 Discussion about dropping the `esmodules` property: babel#11124 (comment)
This was harder than usual 😕