babel / babel/babel-loader

Babel Loader ignores webpack resolve config for its own plugins

Open
#895 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.8k
Forks
456
Avg merge
9h 19m
Merged PRs (30d)
2

Description

**Webpack Version:**

> `4.46.0`

**Babel Core Version**:

> "@babel/core": "^7.5.5", -> `7.13.8`

**Babel Loader Version**:

> "babel-loader": "^8.0.6", -> `8.2.2`

**Please tell us about your environment:**

OSX 10.14.6

**Current behavior:**

> Error: Cannot find module '@babel/plugin-proposal-decorators'

**Expected/desired behavior:**

Find Babel plugin.

* **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.**

We have an uncommen directory structure which looks like the following:

- admin/assets
- webpack.config.js
- babel.config.json
- vendor/...
- moduleA
- package.json
- .babelrc

The vendors are added as babelRoots:

```
{
"babelrcRoots": [
".",
"../../vendor/*"
]
}
```

because how npm works we need to override webpack module resolver to something like this:

```
resolve: {
modules: ['node_modules', assetAdminNodeModulesPath],
},
resolveLoader: {
modules: ['node_modules', assetAdminNodeModulesPath],
},
```

but it looks like babel-loader itself does not use this webpack config to load the plugin and so it ends with:

> Error: Cannot find module '@babel/plugin-proposal-decorators'

* **What is the expected behavior?**

I would expect that the resolve config of weback is used to find the `@babel/plugin-proposal-decorators` module.

* **What is the motivation / use case for changing the behavior?**

Fixing problem with a custom dependency resolve configuration.

Contributor guide

Open the contributing guide

Research direction

Start with admin/assets/webpack.config.js and compare its resolve and resolveLoader settings with how babel-loader resolves plugins referenced by vendor module .babelrc files. Review admin/assets/babel.config.json and the vendor module configuration, then verify that @babel/plugin-proposal-decorators is found through the custom dependency path.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.