add support for native es modules in Node
See original GitHub issueDescription
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:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
Closing this issue because it’s unclear when we plan to support ESM because we want to maintain backwards compatibility.