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

"defaults" query in .browserslistrc is not accepted by babel-preset-env #10965

Closed
1 task done
htulipe opened this issue Jan 6, 2020 · 3 comments
Closed
1 task done
Labels
i: bug i: duplicate outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@htulipe
Copy link

htulipe commented Jan 6, 2020

Bug Report

  • I would like to work on a fix!

Current Behavior
I have a . browserlistrc file that contains the defaults query. I don't have targets option defined in babel-preset-env options. With that setup, the preset includes 148 core-js imports.

If I change this setup and define the targets option to defaults I would expect the output to be the same. It is not. The preset includes 129 core-js imports.

Note that this happens only with the defaults query. If I target for instance Chrome 75, both setups work the same.

Input Code
See:
https://github.com/htulipe/bug-babel-preset-env

In lib you'll find a file compiled without the targets option and another with the option defined.

Expected behavior/code

I would expect that defining defaults in .browserslistrc or in the preset options to ouput the same result.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

See sample repo

Environment

  System:
    OS: macOS 10.15.2
  Binaries:
    Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node
    Yarn: 1.21.1 - /usr/local/bin/yarn
    npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm
  npmPackages:
    @babel/cli: ^7.7.7 => 7.7.7
    @babel/core: ^7.7.7 => 7.7.7
    @babel/preset-env: ^7.7.7 => 7.7.7
@babel-bot
Copy link
Collaborator

Hey @htulipe! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@htulipe htulipe changed the title "defaults" query in .browserlistrc is not accepted by babel-preset-env "defaults" query in .browserslistrc is not accepted by babel-preset-env Jan 6, 2020
@JLHwung
Copy link
Contributor

JLHwung commented Jan 7, 2020

Closing this as duplicate of #9962 , it is fixed in #10897. However we can not ship it until Babel 8 because it is a breaking change.

As a workaround, you can specify defaults again in targets.browsers. We recognize that it is not ideal but could not ship in Babel 7 because we are changing the behaviour of default options.

[["@babel/preset-env", { "targets": "defaults" }]]

@htulipe A personal thank-you for this report and the reproduction repo!

@htulipe
Copy link
Author

htulipe commented Jan 7, 2020

Sorry I missed that @JLHwung, thanks for the link and the workaround.

For those stumbling on the same issue, I got around it by "expliciting" defaults. Meaning I put > 0.5%, last 2 versions, Firefox ESR, not dead in my .browserslist file. Works fine.

@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 Apr 8, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: duplicate outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

3 participants