[Bug]: runtime/helpers/esm/*.js import the CJS version of "typeof"
See original GitHub issue💻
- Would you like to work on a fix?
How are you using Babel?
Other (Next.js, Gatsby, vue-cli, …)
Input code
This lines from node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
import _typeof from "@babel/runtime/helpers/typeof";
import assertThisInitialized from "./assertThisInitialized.js";
should be
import _typeof from "./typeof.js";
import assertThisInitialized from "./assertThisInitialized.js";
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 imports typeof.js
has the same problem, and for some reason it’s specific to typeof.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:
Uncaught SyntaxError: The requested module '../typeof.js' does not provide an export named 'default'
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.
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (8 by maintainers)
Hey @exb , pls let me know when your done
Hi @nicolo-ribaudo, I started working on this yesterday 😃