Parcel: Parsing objects for browserslist fails

Created on 19 Mar 2018  路  5Comments  路  Source: parcel-bundler/parcel

Parcel doesn't interpret environments in a browserslist config.

Using this config

  "browserslist": {
    "development": ">2%, last 1 edge versions, not ie > 0, not op_mini all",
    "production": ">2%, last 1 edge versions, not ie > 0, not op_mini all"
  }

Results in

馃毃  <file>: Browser queries must be an array. Got object.
    at browserslist (.../node_modules/browserslist/index.js:207:11)
    at getTargetEngines (.../node_modules/parcel-bundler/src/utils/getTargetEngines.js:69:24)
    at <anonymous>

It looks like the main browserslist(queries, opts) API that's exported isn't meant to know about environments (it's left to the user to determine which environment to supply it with).

Bug Help Wanted

Most helpful comment

@DeMoorJasper I added the functionality + refactored the test to cover both changes

All 5 comments

The given config wouldn't work either with the current implementation, because the browser list props currently must be defined as an array as described in the browserlist docs. Should parcel be able to parse browserlists defined as comma separated strings too?

Ah hmm, I think that's transparent for browserlist, it probably just does a .split(',') in that case.

The JS docs later on say that "Queries can be a string > 5%, last 1 version or an array ['> 5%', 'last 1 version']".

I guess in that case we might want to implement the string format.
@nicolaisueper perhaps you can add it to your pr?

@DeMoorJasper for sure. :)

@DeMoorJasper I added the functionality + refactored the test to cover both changes

Was this page helpful?
0 / 5 - 0 ratings

Related issues

medhatdawoud picture medhatdawoud  路  3Comments

termhn picture termhn  路  3Comments

donaldallen picture donaldallen  路  3Comments

will-stone picture will-stone  路  3Comments

Niggler picture Niggler  路  3Comments