-
Notifications
You must be signed in to change notification settings - Fork 214
Allow browserslistsrc file to configure babel targets #1141
Comments
A potential downside is confusion over what you're targeting (browsers vs node), when building a server and a frontend. My current workaround is to maintain a .browserslistrc file, and manually call the browerslist function like so:
Not a bad solution, but I think we should take an official stance on this, and perhaps document an example if people do want to use a browerslistrc file. |
Hi! It looks like the browserlist config cannot be JS (config docs), so I guess Neutrino can't offer an output handler for this. As such, the options seem to be:
For (1), we could make this simpler to do, by supporting passing For (2), there are lots of different ways the config can be set, so we'd presumably have to just use the For (3), this would mean I think we should do either (1) or (2). |
@edmorley I'm in favor of 2. I've run into problems where I was doing the |
With the changes above to make (1) easier, it wouldn't be necessary to have a direct dependency on |
@edmorley with 1), are you suggesting we just tell users to do what I'm already doing? |
No, this:
ie: // .neutrinorc.js
module.exports = {
options: {
root: __dirname,
},
use: [
[
'@neutrinojs/web',
{
// Stop Neutrino from setting targets, so @babel/preset-env uses browserlist instead.
targets: false,
}
]
]
}; |
🤦♀️ my bad, in that case 1) is my vote! |
Think we should do this directly on
|
Just noticed this: https://babeljs.io/docs/en/babel-preset-env#targetsbrowsers
|
Another consideration is babel/babel-loader#690. |
@edmorley I'm so glad you mentioned babel/babel-loader#690, I had to set |
A while back I brought this up: #229
It is desirable to have a browserslist file so various tools can pick use it (autoprefixer, stylelint, eslint-plugin-compat, and of course, @babel/preset-env).
@babel/preset-env
supports this out of the box: https://babeljs.io/docs/en/babel-preset-env#browserslist-integration, however, since Neutrino passes targets directly, I'm assuming it will take those values and not read them from the file.I'm not sure if this is a situation where we can use
neutrinorc
as the single source of truth, as.browserslistrc
files, I believe are just plain text (no js).The text was updated successfully, but these errors were encountered: