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

fix: use semver gte comparison on polyfill version tester #12783

Merged
merged 8 commits into from Feb 11, 2021

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Feb 9, 2021

Q                       A
Fixed Issues? Fixes #12650
Patch: Bug Fix? Y
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Manually tested semverGte with examples
Documentation PR Link
Any Dependency Changes?
License MIT

Currently we use parseFloat (#12458) to compare node versions and to apply polyfills conditionally, however it will fail, for example, on comparing 10.8 to 10.12, which is the case in #12650.

The following affected packages should be republished:

  • @babel/cli
  • @babel/node
  • @babel/register

We don't need to republish @babel/transfrom-runtime since only scripts is modified and we never build Babel on Node.js 10.

@JLHwung JLHwung added PR: Bug Fix 🐛 A type of pull request used for our changelog categories i: regression labels Feb 9, 2021
@babel-bot
Copy link
Collaborator

babel-bot commented Feb 9, 2021

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Feb 9, 2021

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 6b8ed33:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@JLHwung JLHwung force-pushed the fix-12650 branch 3 times, most recently from 22387b8 to 94a25f1 Compare February 9, 2021 16:42
babel.config.js Outdated
// semverGte("8.9", "8.9") // true
// semverGte("9.0", "8.9") // true
// semverGte("8.9", "8.10") // false
`((v,w)=>(v=v.split("."),w=w.split("."),+v[0]>+w[0]||v[0]==w[0]&&+v[1]>=+w[1]))`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this expression be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was meant for documentation of a stringified function only. 🤦‍♂️

I didn't figure out how to use @babel/template so it can import the function defined here, but since we only used it twice, I am good with copying this function so far.

// semverGte("8.9", "8.10") // false
// TODO: figure out how to inject it to the `@babel/template` usage so we don't need to
// copy and paste it.
// `((v,w)=>(v=v.split("."),w=w.split("."),+v[0]>+w[0]||v[0]==w[0]&&+v[1]>=+w[1]))`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could to

const semverGte = template.ast`(v,w)=>(v=v.split("."),w=w.split("."),+v[0]>+w[0]||v[0]==w[0]&&+v[1]>=+w[1])`

And then use it with interpolations in the other templates.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok it looks like I was wrong, because we are not using template.ast here but the version that returns a factory function 😅

JLHwung and others added 2 commits February 9, 2021 16:37
Co-Authored-By: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
5 participants