Skip to content
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

Merged
merged 3 commits into from
Apr 30, 2020
Merged

Conversation

nicolo-ribaudo
Copy link
Member

Q                       A
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes? devDep ⬆️
License MIT

This was harder than usual 😕

delete inputTargets.browsers;

// $FlowIgnore
let targets = (inputTargets: Targets);
Copy link
Member Author

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",
Copy link
Member Author

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.

@babel-bot
Copy link
Collaborator

babel-bot commented Apr 29, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/21661/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 29, 2020

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:

Sandbox Source
dawn-feather-5dwz4 Configuration
practical-napier-s890u Configuration

@nicolo-ribaudo
Copy link
Member Author

Ok I broke something

@nicolo-ribaudo
Copy link
Member Author

I had to refactor a bit @babel/preset-env to make the flow errors disappear without breaking anything, but I'm satisfied of the result. Now we have a better separation between the input targets (with esmodules and browsers) and the resolved targets, so we don't have to manually exclude browsers when iterating.

Copy link
Member

@existentialism existentialism left a 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!

@nicolo-ribaudo nicolo-ribaudo merged commit 90a9103 into babel:master Apr 30, 2020
@nicolo-ribaudo nicolo-ribaudo deleted the update-flow branch April 30, 2020 13:26
fivetanley added a commit to fivetanley/babel that referenced this pull request May 29, 2020
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)
fivetanley added a commit to fivetanley/babel that referenced this pull request May 29, 2020
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)
fivetanley added a commit to fivetanley/ember-cli-6to5 that referenced this pull request May 29, 2020
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).
fivetanley added a commit to fivetanley/babel that referenced this pull request May 30, 2020
…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)
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jul 31, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: flow outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants