question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[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:closed
  • Created 2 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
azeez1776commented, Dec 8, 2021

Hey @exb , pls let me know when your done

1reaction
exbcommented, Dec 8, 2021

Hi @nicolo-ribaudo, I started working on this yesterday 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Can't resolve '@babel/runtime/helpers ...
For me, i solve this by adding .js and .jsx as a resolvable extensions as objectWithoutPropertiesLoose is without extension.
Read more >
Package fail to build with node-rollup-plugin-babel 4.4.0 - ...
Copy sent to Debian Javascript Maintainers ... @babel/runtime/helpers/esm/typeof (imported by src/i18next.js, src/Translator.js, ...
Read more >
rollup.js
js import json from '@rollup/plugin-json'; export default { input: 'src/main.js', output: { file: 'bundle.js', format: 'cjs' } ...
Read more >
JavaScript Require vs. Import
So, let's see what the different types of JavaScript modules available are. 1. AMD — Asynchronous Module Definition. AMD modules were introduced ...
Read more >
CommonJS modules | Node.js v19.3.0 Documentation
Files with an extension that is not .mjs , .cjs , .json , .node , or .js (when the nearest ... Calling import()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found