I'm submitting a bug report
Webpack Version:
4.25.1
Babel Core Version:
7.1.5
Babel Loader Version:
8.0.4
Please tell us about your environment:
MacOS 10.13.6
Current behavior:
I want to compile codes through the babel also exists under the node_modules.
Expected/desired behavior:
The bebel compiles codes under the node_modules properly, but without my own .babelrc.
(In the other word, it compiles without any presets and also plugins)
I'd created a repository which reproduces the behavior.
What is the expected behavior?
I'd expect if babel-loader compiles also code under the node_modules, those function using arrow expression might be function literal, too like here.
I got progress a bit, if I convert .babelrc to babel.config.js with same configuration, babel-loader worked as expected.
That's odd 馃
It's because .babelrc doesn't "leak" across different packages (delimited by package.json)
I also fell into this trap...
In previous versions of babel, webpack and babel-loader I could do the following, to transpile certain dependencies in node_modules (all our internal projects start webapp-):
{
test: /\.js$/,
include: {
or: [{ not: [/node_modules/] }, /node_modules\/webapp-/],
},
use: ['babel-loader'],
},
This is no longer true when defining config inside .babelrc, only when config is in babel.config.js.
same bug here
with
"webpack": "^5.18.0",
"babel-loader": "^8.2.2",
If I use .babelrc, the files in node_modules are not compiled.
workaround is to change .babelrc to babel.config.js or set options in the webpack rule config.
It's not a bug.
.babelrc means "only apply this config to the specific package containing this config file"babel.config.js (or babel.config.json) means "apply this config to the whole project.
Most helpful comment
I got progress a bit, if I convert
.babelrctobabel.config.jswith same configuration,babel-loaderworked as expected.That's odd 馃