Make browsers list configurable#2358
Conversation
…he browserslist key in package.json which allows developers to set browsers list in queries like "Chrome >= 35", "Firefox >= 38" for both production and development. Autoprefixer which relies on Browserslist will find its config automatically. This PR fixes facebook#2248 and facebook#892
|
Does this let me specify |
Yes. Running |
|
Do you think it would make sense to use a single list by default, and document splitting dev/prod in user guide? Not sure if it would be confusing to most people or not. I also think we should still provide a default for people who don't have a |
|
@gaearon I agree that if people forget to add
A number of people have asked to split dev/prod |
|
I'd like to split these changes if you don't mind. Let's start with using default values when I would also like to support both single array and an object with |
…ich is no longer supported
| let supportedBrowsers = require(paths.appPackageJson).browserslist; | ||
| if (!supportedBrowsers || Object.keys(supportedBrowsers).length === 0) { | ||
| console.log( | ||
| chalk.yellow( |
There was a problem hiding this comment.
I'd like to not introduce warnings for this.
It will be a straightforward step in migration guide, but for now I don't want people to get annoyed.
|
Sorry, I accidentally messed up committing my changes while merging changes from upstream. |
|
Hmm. I wonder if we should count this as a breaking change or not. I guess not. |
|
IIRC, browserlist searches all the way up the folder tree. This might cause confusing situations if users have dangling package.jsons (something we've seen before) or malformed ones (it complains loudly when malformed). |
|
@Timer Any idea how to limit the browserlist search scope? |
| const paths = require('./paths'); | ||
| const getClientEnvironment = require('./env'); | ||
|
|
||
| // Get supported browsers list |
There was a problem hiding this comment.
I think this can be moved to a separate module to avoid DRY, maybe config/getSupportedBrowsers?
|
@cr101 https://github.com/ai/browserslist/blob/master/index.js#L361 looks like it can't be configured; open an issue and PR maybe? |
|
@Timer |
|
What needs done here? |
I don't believe so. I'm now on Windows which makes it tricky to test the changes. |
|
Really sorry about this—we were very busy with React 16 rollout and by the time we got around to reviewing #3644 was more fresh so we took it instead. Thanks for prototyping this early on! |

Autoprefixer's
browsersoption is currently hardcoded. This PR adds thebrowserslistkey inpackage.jsonwhich allows developers to set different browsers for both production and development.Autoprefixer which relies on Browserslist will find its config automatically.
This PR fixes #2248 and #892