Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
jedwards1211 opened this issue Oct 9, 2020 · 5 comments
Closed
1 task done

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

jedwards1211 opened this issue Oct 9, 2020 · 5 comments
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@jedwards1211
Copy link
Contributor

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";
@babel-bot
Copy link
Collaborator

Hey @jedwards1211! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@jedwards1211
Copy link
Contributor Author

Seems like this will be fixed by #10853

@JLHwung
Copy link
Contributor

JLHwung commented Oct 9, 2020

Duplicate of #12003

@JLHwung JLHwung marked this as a duplicate of #12003 Oct 9, 2020
@JLHwung JLHwung closed this as completed Oct 9, 2020
@JLHwung JLHwung marked this as not a duplicate of #12003 Oct 9, 2020
@JLHwung
Copy link
Contributor

JLHwung commented Oct 9, 2020

Duplicate of #8462

@JLHwung
Copy link
Contributor

JLHwung commented Oct 14, 2020

Fixed in @babel/runtime@7.12.0.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 14, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

3 participants