Babel-loader: Monorepo babel-loader does not read babel config correctly

Created on 17 Oct 2018  路  2Comments  路  Source: babel/babel-loader

I'm submitting a bug report

Webpack Version:
4.20.2

Babel Core Version:
7.x

Babel Loader Version:
8.x

Please tell us about your environment:
OSX 10.14

Current behavior:
When setting custom plugin list through "babel" section of package.json, or through .babelrc.js, at least one plugin is never recognized. Passing the same babel config directly to babel-loader fixes the issue.

babel config:

module.exports = {
  plugins: [
    "@babel/plugin-proposal-class-properties",
    '@babel/plugin-syntax-dynamic-import',
    'react-hot-loader/babel',
  ],
  presets: [
    [
      '@babel/preset-env',
      {
        modules: false,
      },
    ],
    '@babel/preset-react',
  ],
}

Error during compilation:

Support for the experimental syntax 'classProperties' isn't currently enabled (52:20):

Add @babel/plugin-proposal-class-properties (https://git.io/vb4SL) to the 'plugins' section of your Babel config to enable transformation.

It's most likely relevant that our project is a monorepo, which uses Yarn workspaces. We have "devDependencies" only in the root package.json (same level as babel config), but there are multiple other package.json files which specify "dependencies" local to each module.

Most helpful comment

package.json#babel and .babelrc don't work across different modules: what you need is babel.config.js

All 2 comments

package.json#babel and .babelrc don't work across different modules: what you need is babel.config.js

This was the solution, thanks a lot!

Was this page helpful?
0 / 5 - 0 ratings