Skip to content

@babel/core 7.13.* trying to get browserslist config of a node_module #13014

@jancama2

Description

@jancama2

Bug Report

I'm using ejected CRA of the lastest version. There are no changes to the babel configuration from the one CRA provides by default.

When updating to version 7.13.0 and other newer versions, compilation fails on this error

Failed to compile.
./node_modules/@ackee/jerome/es/index.js
Error: Cannot find module '@ackee/browserslist-config'
Require stack:
- /usr/src/app/node_modules/@babel/helper-compilation-targets/node_modules/browserslist/node.js
- /usr/src/app/node_modules/@babel/helper-compilation-targets/node_modules/browserslist/index.js
- /usr/src/app/node_modules/@babel/helper-compilation-targets/lib/index.js
- /usr/src/app/node_modules/@babel/core/lib/config/resolve-targets.js
- /usr/src/app/node_modules/@babel/core/lib/config/partial.js
- /usr/src/app/node_modules/@babel/core/lib/config/full.js
- /usr/src/app/node_modules/@babel/core/lib/config/index.js
- /usr/src/app/node_modules/@babel/core/lib/index.js
- /usr/src/app/node_modules/babel-loader/lib/index.js
- /usr/src/app/node_modules/loader-runner/lib/loadLoader.js
- /usr/src/app/node_modules/loader-runner/lib/LoaderRunner.js
- /usr/src/app/node_modules/webpack/lib/NormalModule.js
- /usr/src/app/node_modules/webpack/lib/NormalModuleFactory.js
- /usr/src/app/node_modules/webpack/lib/Compiler.js
- /usr/src/app/node_modules/webpack/lib/webpack.js
- /usr/src/app/scripts/buildClient.js
    at Array.reduce (<anonymous>)
    at loadPrivatePartialConfig.next (<anonymous>)
    at Generator.next (<anonymous>)

Package @ackee/jerome has @ackee/browserslist-config defined in its package.json and babel is used as devDependency.
Because we use Renovatebot, I was able to track the issue's started after adding these changes https://app.renovatebot.com/package-diff?name=@babel%2fcore&from=7.12.17&to=7.13.0

Expected behavior
I would expect babel to not care about browserslist of any node_module but I might be wrong. Honestly I'm not sure how this should work.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
const hasJsxRuntime = (() => {
    if (process.env.ENABLE_NEW_JSX_TRANSFORM !== 'true') {
        return false;
    }

    try {
        require.resolve('react/jsx-runtime');
        return true;
    } catch (e) {
        return false;
    }
})();

module.exports = {
    presets: [
        [
            require.resolve('babel-preset-react-app'),
            {
                runtime: hasJsxRuntime ? 'automatic' : 'classic',
            },
        ],
    ],
};

Environment
Ejected latest version of CRA (4.0.3)

  • Babel version(s): 7.13.10 (but 7.12.17 works just fine)
  • Node/npm version: Node 12/yarn 1.22
  • OS: macOS 10.15.7
  • Monorepo: no
  • How you are using Babel: webpack

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions