missing extension in import paths in @babel/runtime/helpers/esm
See original GitHub issueBug 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.5webpack
: 5.0.0-rc.4babel-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:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Duplicate of #12003
Fixed in
@babel/runtime@7.12.0
.