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

Parsing objects for browserslist fails #1026

Closed
sohkai opened this issue Mar 19, 2018 · 5 comments · Fixed by #1053
Closed

Parsing objects for browserslist fails #1026

sohkai opened this issue Mar 19, 2018 · 5 comments · Fixed by #1053

Comments

@sohkai
Copy link

sohkai commented Mar 19, 2018

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).

@nicolaisueper
Copy link
Contributor

nicolaisueper commented Mar 27, 2018

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?

@sohkai
Copy link
Author

sohkai commented Mar 27, 2018

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']".

@DeMoorJasper
Copy link
Member

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

@nicolaisueper
Copy link
Contributor

@DeMoorJasper for sure. :)

@nicolaisueper
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants