-
-
Notifications
You must be signed in to change notification settings - Fork 158
Send file path to browserslist #26
Comments
I guess we could check the file but given a preset could be somewhere else I'm not sure. Also relevant facebook/create-react-app#892 |
If someone wants to make a PR |
I tried looking into it, but the preset doesn't have access to useful information about the The preset is called with a |
I made a PR, but having slept on it I feel like the original suggestion would be much more elegant. Looks like it'd be possible to change babel-core to pass the current file to the preset. Do you think babel-core would be open to a PR like that? |
@hzoo I changed Browserslist to fit Babel and CRA requirements. Now it is your turn to enable a config (not just a option). |
Hey @ai, I'd like to jump in and get this working on the Babel side. I'm not sure what you mean by your last comment though - could you elaborate? |
@motiz88 I mean that it is Babel turn to set |
babel/babel#4834 would enable this nicely. Related: It's worth considering how this fits together with #161, which supports specifying an explicit path in the preset options. Possible behaviours off the top of my head:
|
I think, that if user set config path, we should use only this config. |
We already have #161. It accepts all logic provided by browserslist, including |
@motiz88 It handles ["env", {
"path": "path/to/config"
}] where Without This PR isn't merged yet, so it's cool to see more propositions about technical realization, etc. 😉 |
@yavorsky in next major Browserslist will not look in
|
@ai But browserslist currently use
|
Yeap, but semantically So in Autoprefixer/Stylelint, user doesn’t need to specify path to config manually. Developer just processes files in Autoprefixer. And Browserslist automatically find config in CSS files parents directories. |
But in the case of preset-env we haven't any js files on preset building stage. We only have possible process root and config provided by the user. 🤔 |
@yavorsky as a short-term solution rename As a long-term solution try to change API to allow rebuild preset for every file. I think users will expect same behaviour as for |
@ai Thanks! 👍 Also I'll play with preset's context and maybe it helps. |
@ai @yavorsky Babel does rebuild the preset for every input file, and as I alluded to above, babel/babel#4834 amends that behaviour to pass the input path as an extra argument to the preset constructor. Hopefully that PR is on its way to being merged on the Babel side. |
@motiz88 I mean it doesn't support Thanks for the link, I really never met or just forgot about this PR. 🎉 |
@yavorsky What is the final implementation algorithm? I want to champion this PR 😄 |
This issue has been automatically marked as |
Any updates on this? |
@knynkwl I think 2.x version supports this feature, so you would need to upgrade to babel 7 |
Done in #161 (correct for v7) |
Browserslist could use
browserslist
config file. It is useful, because many different tools will share same config (Autoprefixer, Stylelint, cssnext, doiuse).But to enable a config, you need to pass a path for current file:
The text was updated successfully, but these errors were encountered: