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.

convert-commonjs-to-esm doesn't work

See original GitHub issue

Issue Description

I enabled convert-commonjs-to-esm/require and convert-commonjs-to-esm/exports here:

Now I expect it to complain about require() calls in test.js, but it doesn’t.

What did I do wrong?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

EvgenyOrekhovcommented, Apr 26, 2021

It works now, thank you!

coderaisercommented, Apr 26, 2021

Looks like it is related with configuration of convert-commonjs-to-esm, the whole rule is disabled by default with:

    "rules": {
        "convert-commonjs-to-esm": "off"

And when you partially enable it with:

    "rules": {
        "convert-commonjs-to-esm": "off",
        "convert-commonjs-to-esm/require": "on",
        "convert-commonjs-to-esm/exports": "on"

It’s do not get loaded, so one of solutions could be to enable the whole rule, and then disable parts you don’t need. Anyways it looks useful, worth fixing and landed in @putout/engine-loader v4.3.0 🎉 .

Is it works for you 😃?

Read more comments on GitHub >

github_iconTop Results From Across the Web

CommonJS to ESM in Node.js - Aral Balkan
First off, I started by running the following regular expression to quickly convert CommonJS require syntax to ESM import syntax: ...
Read more >
Upgrade your Node app: From CommonJS to ES Modules
Step by step: From CommonJS to ES Modules · 1) Prepare your code · 2) Update the package.json · 3) Convert all imports...
Read more >
Switch from commonjs (cjs) to ES6 modules (esm) #1459
When adding the third party lib which uses ES6 modules and running yarn run dev , I got the errors require() of ES...
Read more >
Node Modules at War: Why CommonJS and ES ... - Code Red
You can opt-in to ESM mode by renaming your script from .js to .mjs . Alternately, you can set "type": "module" in package.json...
Read more >
Converting CommonJS to ES modules - node.js - Stack Overflow
So, to translate this to ESM, you change your routes module to export a named function. You can then import that named function...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found