babel: bug: Can't resolve '@babel/runtime/helpers/esm/extends [7.13.0 to 7.13.5]

Bug Report

Current behavior

When the Run server step runs in this GitHub Actions Build, this error is given:

ModuleNotFoundError: Module not found: Error: Can't resolve '@babel/runtime/helpers/esm/extends'

This currently happens with @babel/runtime from 7.13.0 to 7.13.5.

Current Fix I was able to resolve this by install @babel/runtimeas a devDependency and forcing it to stay at7.12.18`. This can be seen in this GitHub Actions Build

Environment

  System:
    OS: macOS 10.15.7
  Binaries:
    Node: 12.20.1 - ~/.nvm/versions/node/v12.20.1/bin/node
    npm: 6.14.10 - ~/.nvm/versions/node/v12.20.1/bin/npm
  npmPackages:
    @babel/register: ^7.10.4 => 7.12.13 
    babel-eslint: ^10.0.1 => 10.1.0 
    babel-jest: ^25.1.0 => 25.5.1 
    babel-plugin-module-resolver: ^4.0.0 => 4.1.0 
    eslint: ^6.8.0 => 6.8.0 
    eslint-import-resolver-babel-module: ^5.1.2 => 5.2.0 
    jest: ^26.1.0 => 26.6.3 
    webpack: ^4.32.0 => 4.46.0 

Additional context I’m not sure but I think this may be related to #12880.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 4
  • Comments: 41 (18 by maintainers)

Most upvoted comments

.mjs may not be resolved in some reasons,please @nicolo-ribaudo change _index.mjs to _index.js

resolved.

why is it loading that file as base64 : url-loader. It build-in roadhog.

solution: add webpack.config.js as

module.exports = config => {
  config.module.rules.forEach(item => {
    if (item.loader && item.loader.indexOf('url-loader') > -1) {
      item.exclude.push(/\.mjs$/);
    }
  });
  return config;
};

thanks

i will making repository with sample for reproduce .

I accidentally pushed the fix to main rather than to a PR: https://github.com/babel/babel/commit/cfdbdc0d1c0f061b9633b04d85b54892e01cdd4d

The problem is that we had export maps like "./helpers/esm/*: "./helpers/esm/*.js" which don’t work in every tool, so we also had "./helpers/esm/: "./helpers/esm/" as a fallback. However, the fallback doesn’t specify the .js extension, so it fails in some tools.

I fixed it by explicitly listing all the exports of the esm folder.