.babelrc or config package.json is not considered
See original GitHub issueI’m submitting a bug report
Webpack Version: 4.9.1
Babel Core Version: 7.0.0-beta.49
Babel Loader Version: 8.0.0-beta.3
Please tell us about your environment: Windows 10
Current behavior: babel-loader doesn’t include config options from “.babelrc” or "package.json
Expected/desired behavior: babel-loader uses “.babelrc” or “package.jso”
webpack:
{
test: /\.js$/,
loader: 'babel-loader',
options: {
babelrc: true,
cacheDirectory: true
}
}
workaround:
{
test: /\.js$/,
loader: 'babel-loader',
options: {
babelrc: true,
extends: path.join(__dirname + '/.babelrc'),
cacheDirectory: true
}
}
- What is the expected behavior?
Before I configured babel trough “package.json”. I just regonized this issue because I disabled comments in babel and found comments in my output.
- What is the motivation / use case for changing the behavior?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:17
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Configure Babel
Create a file called babel.config.json with the following content at the root of your project (where the package.json is). { "presets": [...], "plugins":...
Read more >babelrc configuration placed in package.JSON - Stack Overflow
Babel will look for a .babelrc in the current directory of the file being transpiled. If one does not exist, it will travel...
Read more >How to Setup Babel in Node.js - freeCodeCamp
Now add the folder to the workspace, and open your terminal. Let's initialize and create a package.json file for our app: npm init....
Read more >Babel 7: Configuration, Preset, and Plugin Usage
For those who have never used Node.js, understand package.json as a various metadata holder for all modules used by the application, including ...
Read more >配置文件 - Babel 中文文档
项目范围的配置. babel.config.json 文件,以及不同扩展名的文件. 相关文件的配置 .babelrc.json 文件,以及不同扩展名的文件; 带有 "babel" 键的 package.json 文件 ...
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
I’m affected by this too after trying to upgrade everything to v7. I think that this is only happening when transpiling
node_modules
(which I need to do for a dependency) - I don’t get any errors for the files in my project, but the config is not considered for files in node_modules and I get errors that plugins are missing.Could it be that because these files are in node_modules, the config search “stops” at the package.json of the dependency, instead of traversing up? Or maybe looking in parent directories is broken in general?
I have a similar problem.
babel-loader
works correctly if the.babelrc
is right next to mypackage.json
directory, but if it’s located 1 directory above (I use a monorepo) – then it’s not loaded.Not sure if that’s intentional or not.
UPDATE: Our solution was to migrate from
.babelrc
tobabel.config.js
which is the new recommended configuration structure for monorepos.