question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

browserslist and babel-preset-env

See original GitHub issue

Currently, we default a browser list config for babel-preset-env. I’m not sure if it’s possible yet (https://github.com/babel/babel-preset-env/pull/161), but it would be great if we allowed this to be configured via the browserslist config key in package.json (https://github.com/ai/browserslist).

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
weaverryancommented, Nov 16, 2018

As of Encore 0.21.0, the browserslist config is respected by Babel 😃

0reactions
Nemo64commented, May 29, 2018

how about configuring babel like this?:

    .configureBabel(function(babelConfig) {
        babelConfig.presets[0][1].targets.browsers = require('browserslist')();
    })

This will get the browserlist from the environment which is what we want. I’m not sure how i can validate if that actually works as I expect.

EDIT: I figured a way out to test it. So you can set babelConfig.presets[0][1].debug = true which will output which polyfills and (if included) plugins are used but also “using targets”. As far as I can tell, they match my browser list which basically is “defaults, IE >= 9, not OperaMini all”. Mobile browsers are for some reason absent but that seems to be normal for babel.

So yes: I think my way works. But it seems too easy.

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel/preset-env
babel /preset-env` is a smart preset that allows you to use the latest JavaScript without needing to micromanage which syntax transforms (and optionally, ......
Read more >
Babel with babel-preset-env seems to ignore browserslist config
"By default @babel/preset-env will use browserslist config sources unless either the targets or ignoreBrowserslistConfig options are set.".
Read more >
How to create a custom .browserlistrc for babel-preset-env
Let's have a look. Start the tool like this in the root directory of your project (no further installation necessary):. npx browserslist-ga.
Read more >
browserslist/browserslist: Share target browsers ... - GitHub
The config to share target browsers and Node.js versions between different front-end tools. It is used in: Autoprefixer · Babel · postcss-preset-env ·...
Read more >
How babel preset-env, core-js, and browserslistrc work together
In this post we're going to see how babel preset-env, core-js, and browserslistrc work nicely together to enable newer JavaScript features ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found