.babelrc.js is being ignored
- Dominant language
- JavaScript
- Stars
- 4.8k
- Forks
- 456
- Avg merge
- 9h 19m
- Merged PRs (30d)
- 2
Description
**I'm submitting a bug report**
**Webpack Version:**
4.29.6
**Babel Core Version**:
7.4.0
**Babel Loader Version**:
8.0.5
**Please tell us about your environment:**
Windows 10
**Current behavior:**
`.babelrc.js` files are being ignored
**Expected/desired behavior:**
`.babelrc.js` files are NOT being ignored :)
## Additional Info
The project is a monorepo, where the root package (i.e. `bundler`) is placed as a sibling to the other subpackages (i.e. `module1`).
Both the root package and the subpackage have the same alias - `components`, but it points to a different path in each. However, apparently the `module1` babelrc is being ignored, since babel is searching in the `bundler` package for modules that are in `module1`.
**project/bundler/babel.config.js**
```
const {resolve} = require('path');
module.exports = api => {
api.cache(true);
return {
babelrcRoots: [
'.',
'../module1'
],
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: [
[
'module-resolver',
{
cwd: resolve(__dirname, './babel.config.js'),
root: resolve(__dirname, './'),
alias: {
components: resolve(__dirname, './src/components'),
module1: resolve(__dirname, '../module1/src')
}
}
]
]
};
};
```
**project/module1/.babelrc.js**
```
const {resolve} = require('path');
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
cwd: 'babelrc',
root: resolve('./'),
alias: {
components: resolve(__dirname, './src/components'),
}
}
]
]
};
```
The build fails with the following error:
>ERROR in ../module1/src/Module1Component.jsx
Module not found: Error: Can't resolve 'path\to\bundler\src\components/Module1Component2' in 'path\to\module1\src'
Contributor guide
Research direction
Start with project/bundler/babel.config.js and project/module1/.babelrc.js, then reproduce the webpack build described in the report. Trace why the module1 configuration is ignored and verify that the module1 components alias resolves to module1/src/components rather than bundler/src/components.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, webpack
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100