question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

missing extension in import paths in @babel/runtime/helpers/esm

See original GitHub issue

Bug Report

File extensions are required in import statements in ES Modules.

But files within @babel/runtime/helpers/esm (which are treated as ES Modules because @babel/runtime/helpers/esm/package.json contains type: "module") don’t use extensions in their import statements.

  • I would like to work on a fix!

Current behavior

I’m getting this correct error with Webpack 5:

ERROR in ./node_modules/@babel/runtime/helpers/esm/get.js 1:0-44
Module not found: Error: Can't resolve './superPropBase' in '/Users/andy/clarity/node_modules/@babel/runtime/helpers/esm'
Did you mean 'superPropBase.js'?
BREAKING CHANGE: The request './superPropBase' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

This is because the first line of @babel/runtime/helpers/esm/get.js is an import without an extension:

import superPropBase from "./superPropBase";

Input Code

var your => (code) => here;

Expected behavior

No problems using @babel/plugin-transform-runtime with useESModules: true

Babel Configuration

  • Filename: (babel config inlined in babel-loader webpack config)
{
  presets: [
    ['@babel/preset-env', {targets: {browsers: 'last 2 versions'}}],
  ],
  plugins: [
    [
      '@babel/plugin-transform-runtime',
      {
        useESModules: true,
      },
    ],
  ]
}

Environment


  • @babel/runtime: 7.11.2
  • @babel/plugin-transform-runtime: 7.11.5
  • webpack: 5.0.0-rc.4
  • babel-loader: 8.1.0

Possible Solution

Use full extensions in imports inside @babel/runtime/helpers/esm, so I don’t get these errors, for example:

import superPropBase from "./superPropBase.js";

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JLHwungcommented, Oct 9, 2020

Duplicate of #12003

0reactions
JLHwungcommented, Oct 14, 2020

Fixed in @babel/runtime@7.12.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript eslint - Missing file extension "ts" import/extensions
Following is a similar error that can be thrown due to '~' in imports: enter image description here. Missing file extension for "~/path/" ......
Read more >
no-restricted-imports - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
JavaScript modules - MDN Web Docs
Throughout this article, we've used .js extensions for our module files, ... based on the path of the script that is importing the...
Read more >
eslint-plugin-import - npm
( no-unresolved ); Ensure named imports correspond to a named export in ... Ensure consistent use of file extension within the import path...
Read more >
babel runtime helpers added with .js extension causing ...
import "@babel/runtime/helpers/esm/extends.js"; ... This is because this path conflicts with the package.json exports subpath pattern: "exports": { ".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found