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
Invalid Import Path for core-js Imports When Using type: module #12003
Comments
Hey @trisys3! 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." |
As a workaround, it should already work when using the new |
Sorry, to be honest I wasn't even sure what to search for, though I did try. Also, even if I did, that issue has been closed for a long time. Do you have an idea of when this will be (re-)implemented? |
@nicolo-ribaudo to your point, we are waiting on this fix to and its stopping us from moving to webpack 5 + esmodule modern build... would using I'm trying it currently but the documentation of how to switch to it is a bit difficult, so i was hoping to know if im wasting my time, since it seems i may run into the same issue (since by my understanding, we would still be using |
argh yeah i switched from:
to:
and am still getting:
is there another workaround to this issue while waiting for #10853 ? |
@nicolo-ribaudo since For example I'm getting this error with webpack 5:
This is because the first line of import superPropBase from "./superPropBase"; |
I guess I should file a new issue for what I described above |
@jedwards1211 You don't need file one. It will be fixed by #10853. |
Ah okay, OP seemed like it was only about import statements injected by |
Bug Report
Current behavior
A clear and concise description of the behavior.
When I use
@babel/preset-env
with theuseBuiltIns
option, thecore-js
imports still output without the.js
. This is usually fine, except when running in a node environment that supports built-in modules, e.g. withtype: module
in the package.json or outputting to a file with the.mjs
extension.This happens even if I use
--out-file-extension .mjs
.--out-file-extension .cjs
works, if you don't usemodules: false
, but then you're not outputting modules.Input Code
test.js
Output:
Expected behavior
A clear and concise description of what you expected to happen (or code).
No errors
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
babel.config.js
Environment
Possible Solution
One possible solution would be to always output with the extension. This would create longer output, but it would be future-proof and wouldn't require the user to do anything.
The best solution would probably be to guess whether the extension is needed, based on whether the package.json has
type: module
, and have a configuration option likeaddExtension
oraddCorejsExtension
to force it one way or the other.The last option I can think of is to always output
.cjs
, or add a configuration likechangeExtension
..mjs
would output to a.mjs
file AND add thecorejs
path extensions..cjs
would output to.cjs
and wouldn't add the extensions..js
, the default, would output to.js
and possibly guess or use theaddCorejsExtension
option. I notice there is a--out-file-extension
option for@babel/cli
: having this keep thecorejs
extensions when you use.mjs
would be fine, too.Additional context
Add any other context about the problem here. Or a screenshot if applicable
The text was updated successfully, but these errors were encountered: