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.

add support for native es modules in Node

See original GitHub issue

Description

Native ES modules were landed in node@12.7.0 (see proposal-pkg-exports).

I created small repo with interested for me packages like express, lodash, redux, redux-saga, etc - and try to run app in esm mode.

By default, there are many errors, but they easily fixed by npm run patch.

Some packages need to fix their source, but redux-saga packages need to fix only package.json. You can see example of fixes here - https://github.com/rifler/node-esm-example/blob/master/patches/packageJsonConfigs.js

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, Feb 27, 2022

ESM is a dangerous thing that often cannot be shipped within the current major version of a library. Each library is different though so this should be carefully evaluated here - maybe there is a way to make CJS and ESM entrypoints coexist here but from my experience, there probably isn’t.

In a way, I would probably put this aside until React ships its ESM - cause this might be a final push for the React community to drop CJS and bump major versions everywhere.

0reactions
neurosnapcommented, Oct 10, 2022

Closing this issue because it’s unclear when we plan to support ESM because we want to maintain backwards compatibility.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Native ES Modules in Node.js
With the native ESM support in browser, it seems now essential to have it in Node.js . From its beginning, Node.js uses a...
Read more >
Using ES modules in Node.js
Adding support for ES modules in Node today ... It's important to know that because Node.js now supports both ES modules and commonJS ......
Read more >
ECMAScript modules | Node.js v19.3.0 Documentation
Node.js fully supports ECMAScript modules as they are currently specified and provides interoperability between them and its original module format, CommonJS.
Read more >
Publishing NPM Packages as Native ES Modules
Node.js has had native support for ES modules since version 14, here's why you should (probably) be using it, how to migrate, and...
Read more >
Documentation - ECMAScript Modules in Node.js
Node.js supports two extensions to help with this: .mjs and .cjs . .mjs files are always ES modules, and .cjs files are always...
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