[Bug]: true `ignoreBrowserslistConfig` but reading `.browserslistrc`
See original GitHub issue💻
- Would you like to work on a fix?
How are you using Babel?
Input code
$ strace -f -e file -o file.log babel --config-file ./babel.config.json example.mjs
Configuration file name
babel.config.json
Configuration
{
"presets": [
[
"@babel/preset-env",
{
"debug": true,
"ignoreBrowserslistConfig": true,
"targets": {
"chrome": "92"
}
}
]
]
}
Current and expected behavior
Actual
$ grep -F .browserslist file.log && echo FAIL || echo OK
... access("/path/to/cwd/browserslist", F_OK) = -1 ENOENT (No such file or directory)
... access("/path/to/cwd/.browserslistrc", F_OK) = -1 ENOENT (No such file or directory)
... access("/path/to/cwd/browserslist-stats.json", F_OK) = -1 ENOENT (No such file or directory)
... access("/path/to/browserslist-stats.json", F_OK) = -1 ENOENT (No such file or directory)
... access("/path/browserslist-stats.json", F_OK) = -1 ENOENT (No such file or directory)
... access("/browserslist-stats.json", F_OK) = -1 ENOENT (No such file or directory)
FAIL
Expected
$ grep -F .browserslist file.log && echo FAIL || echo OK
OK
Environment
@babel/preset-env: ^7.15.6 => 7.15.6
Possible solution
No response
Additional context
Not a real world use case
Just try to analyze filesystem footprint, to solve another config problem by another build tool .
Found babel have this footprint, even set ignoreBrowserslistConfig
to false.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
browserslistrc being ignored #2332 - rails/webpacker - GitHub
Webpacker seems to be ignoring browserslist. ... browserlist settings, reading all the docs we could find, but it just doesn't seem to work....
Read more >Babel with babel-preset-env seems to ignore browserslist config
But, the problem is that Babel seems to ignore the browserslist key. The same is true if I use a .browserslistrc file containing:...
Read more >babel/preset-env
By default @babel/preset-env will use browserslist config sources unless either the targets or ignoreBrowserslistConfig options are set.
Read more >browserslist | Yarn - Package Manager
The config to share target browsers and Node.js versions between different ... Improved unknown region and unknown feature error (by Alexander Chabin).
Read more >@babel/preset-env - npm
Browserslist config will be ignored if: 1) targets.browsers was specified 2) or with ignoreBrowserslistConfig: true option (see more): ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
https://github.com/loynoir/reproduce-babel-13780.js
The current behaviour is expected:
preset-env
does not load.browserslistrc
as instructed byignoreBrowserslistConfig: true
. Actually since you have specifiedtargets
, you can safely removeignoreBrowserslistConfig
.@babel/core
loads.browserslistrc
because the top leveltargets
option is not provided. Note that@babel/core
is unaware ofpreset-env
, so it tries to load the browserslist config, in order to determine a globaltargets
information that can be respected by all plugins/presets.In your case, if you migrate
targets
inpreset-env
to top level, Babel will not load browserslistrc.