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

@babel/preset-env doesn't work with default in browserslistrc #10867

Closed
taralx opened this issue Dec 15, 2019 · 2 comments
Closed

@babel/preset-env doesn't work with default in browserslistrc #10867

taralx opened this issue Dec 15, 2019 · 2 comments
Labels
i: bug i: duplicate outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@taralx
Copy link

taralx commented Dec 15, 2019

Bug Report

Current Behavior
If relying on external browserslist config, "defaults" in that file resolves to empty set, which enables all transforms.

Expected behavior/code
"defaults" should resolve normally. In the example below, many transforms should be disabled.

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

  • Filename: babel.config.js
module.exports = {
  presets: [
    ['@vue/cli-plugin-babel/preset', {debug: true}],
  ]
}
  • Filename: .browserslistrc
defaults and last 4 years

Environment

  System:
    OS: Linux 5.3 Debian GNU/Linux bullseye/sid
  Binaries:
    Node: 10.17.0 - /usr/bin/node
    npm: 6.13.0 - /usr/local/bin/npm
  npmPackages:
    babel-eslint: ^10.0.1 => 10.0.3
    eslint: ^6.7.0 => 6.7.0

Additional context/Screenshots
This is broken because of legacy support:

// If no targets are passed, we need to overwrite browserslist's defaults
// so that we enable all transforms (acting like the now deprecated
// preset-latest).
//
// Note, if browserslist resolves the config (ex. package.json), then usage
// of `defaults` in queries will be different since we don't want to break
// the behavior of "no targets is the same as preset-latest".
if (!hasTargets) {
browserslist.defaults = objectToBrowserslist(targets);
}

This causes defaults to be empty (since !hasTargets) and thus the result is empty. 😢

@babel-bot
Copy link
Collaborator

Hey @taralx! 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."

@JLHwung
Copy link
Contributor

JLHwung commented Dec 16, 2019

Closing this as it duplicates #9962. We plan to fix it in babel v8.

@taralx It is a nice report, thank you!

@JLHwung JLHwung closed this as completed Dec 16, 2019
@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 Mar 17, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 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