-
-
Notifications
You must be signed in to change notification settings - Fork 158
Promote shareable browserslist config #108
Comments
Nice! It might be the first step for configs generalization. I come across cases when people (and my projects too) are using it in bundler's config files, something like:
And use it depending what build tool you have. By putting this logic to the separate config file we would decrease config mess. Also, it could be useful for other things that want to know what envs your app is supporting. |
Would it be possible to remove the if statement from these lines: https://github.com/babel/babel-preset-env/blob/master/src/index.js#L145-L149. |
@yavorsky I found that unfortunately current version of Could we change it? What do you need to change it? |
@yavorsky BTW, this solution is not ideal: const browsers = ['> 4%', 'ie 11', 'safari 8'];
…
plugins: [require('autoprefixer')(browsers)]
…
presets: [
["env", {targets: {browsers}}]
] Not only Autoprefixer and Babel need a browsers list. Stylelint and webpack CSS compression uses (or will use soon) browsers information too. In this case we could not pass browsers to all tools manually. I agree that config mess is a problem. This is why new Browserslist version supports |
@ai actually, removing single condition will fix it. |
As I understand, by passing config searching process to browserslist we can't determine original source (config/arguments/defaults). |
@yavorsky you could convert var queries = targets.browsers || []
var byName = Object.keys(targets).filter(i => i !== 'browsers').map(i => i + ' ' + browsers[i])
var browsers = browserslist(queries.concat(byName), { path: processedFile }) Note about |
@ai Yes! Also, check for node and it must work perfect! |
@ai Some time ago I thought to make a PR, but stacked with queries like |
@ai BTW, whether there any reasons/use cases where defaults with no args is useful?
|
@yavorsky the problem is only country based statistics or we have no global statistics sources too?
|
@ai I haven't found any global updatable statistics. To determine browser version we just need to read request header, but to get node.js version.. unless, that npm statistics or public opinion polls :) |
@ai I wasn't ignoring you in particular, I've been taking a break from OSS over the holiday so didn't really do anything the past 2 weeks |
@ai I'm sure we could gather more OSS giants :) |
@yavorsky but do we need 100% accurate statistics? I am OK with mistakes around 10%. |
How does babel import the |
@amilajack browserslist is searching config by itself |
Hi, guys. Are there any updates? |
I am requiring package.json into webpack config as a workaround: targets: { browsers: require('./package.json').browserslist }, |
Hi there! Just wondering if you have any plan to make babel-preset-env compatible with browserlist trough package.json so we could finally have a universal shared configuration? |
@jmbelloteau yes, that is absolutely our plan... and we will be landing it in 2.0 via #161. |
@existentialism great! thanks a lot 😄 |
It's very much an alpha... but I do know some brave souls running it already :) |
I'll be brave on a test project then 😃 ! Thanks 👍 |
If someone is interested in a workaround that uses browserslist's own configuration loading logic while using babel-loader in webpack, here it is: I pass an options object to the babel-loader in webpack instead of relying on a .babelrc file (
And this is the code to get
This has browserslist as a package dependency:
|
I'm currently defining babel config in a |
+1 Would be nice if it'd pick up the "browserlist" property as a default :) |
@LimeWub it does now: upgrade to latest https://github.com/damianobarbati/react-app/blob/master/package.json#L183 |
@damianobarbati any timing on 2.0 out of alpha? 😎 |
It's used at behance (where I work), and babel itself and it's a good time to try it. Ok closing since this is done in 2.0 |
I think we should promote shareable browsers config instead of
browsers
option. Maybebrowserslist
key inpackage.json
will be the best way.I think most of babel-preset-env users also use Autoprefixer. So for better maintainability they should use shareable browsers config to use same browsers list in Autoprefixer and babel-preset-env. But most of developers doesn’t know about this option and benefits of it.
I already removed
browsers
option from all examples in Autoprefixer docs and focused on sharable configs.The text was updated successfully, but these errors were encountered: