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
[Bug]: runtime/helpers/esm/*.js import the CJS version of "typeof" #13786
Comments
Hey @pmcelhaney! 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." |
The code which should "fix" the imports in the helpers is at in
I'm assigning tihs to you, since you selected "Would you like to work on a fix?"! If it is the first time that you contribute to Babel, follow these steps: (you need to have
|
I spent a few hours looking into it and I'm lost. :( With most of the runtime helpers,
I can't figure out where the code to stick the import for the typeof helper at the top of the file is. I noticed there's a babel-runtime/helpers/typeof.js but its counterpart is missing from babel-runtime/helpers/esm/. Also typeof seems to be a special case here: babel/packages/babel-plugin-transform-runtime/scripts/build-dist.js Lines 238 to 258 in 178d43f
Not sure if either of those has anything to do with it. |
@pmcelhaney It looks like this is a problem when injecting an import because the helpers is being transpiled and depends on another helper, not for normal helper dependencies. In the babel/packages/babel-helpers/src/helpers.ts Lines 618 to 630 in 89cab43
A working workaround would be to remove the |
Hi @pmcelhaney! Are you still working on this? |
Hi, |
Sure, thanks! If you need any help, feel free to ask here or on slack. |
Hi @FuryACE007! 👋 Still working on this? If not, I’d like to pick this up. |
@exb If @FuryACE007 doesn't respond within Monday, this bug is yours! |
Hey @nicolo-ribaudo can I try working on the problem? |
@exb Are you still working on this? |
Hi @nicolo-ribaudo, I started working on this yesterday :) |
Hey @exb , pls let me know when your done |
💻
How are you using Babel?
Other (Next.js, Gatsby, vue-cli, ...)
Input code
This lines from
node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
should be
In other words, the second line should match the first. It should import the ESM version of
typeof.js
rather than the CJS version which lives in the parent directory. Every file in that directory that importstypeof.js
has the same problem, and for some reason it's specific totypeof.js
. Other siblings are imported the same as they are in line 2 above.Configuration file name
No response
Configuration
n/a
Current and expected behavior
Current:
Expected:
No error, because it's loading the ESM version of
typeof.js
instead of the CJS version.Environment
Babel version 7.15.4
Possible solution
This looks like a trivial fix. I just can't figure out where the source code that generates these files lives.
Additional context
I encountered this error when importing i18next in a browser. I was able to fix it by changing that import directly in node_modules. I then installed @babel/runtime directly in a clean npm repo to confirm my node_modules wasn't altered by some other process.
The text was updated successfully, but these errors were encountered: