-
Notifications
You must be signed in to change notification settings - Fork 936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ESModules instead of module.exports #786
Comments
It's not supported natively, so a build step would be required. Unfortunately, package management for the different types of modules still is pretty terrible. This is why most large modules are still CJS exported. |
You are right... Conditional exports be a solution when not experimental anymore, or for next major: // package.json https://nodejs.org/dist/latest-v15.x/docs/api/packages.html#packages_conditional_exports Storing it here to not loosing this... |
Any news on this topic? |
In Node.js ESM this works for me: import debugModule from 'debug'; |
Yep, v5 will be pure ESM. |
It would be cool to see debug being a ESM only package, It would put pressure on many packages towards upgrading their commonjs packages to ESM as well and benefit the hole js ecosystem in the end. |
Hi @Qix-, we've been working on ESM support for This work is also published as |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The workaround suggested in the comment above
didn't work for me with the version 4.3.3. I get the error Generally if I have Any other workaround for usage in an es module? Or do I better wait for the next major release? |
Works fine for me. |
we should at least discourage this antipattern it's bad to call/chain require, it only makes it harder for those who wish to swtich to esm at some point later const debugFactory = require('debug')
const debug = debugFactory('foo:bar') |
@jimmywarting agreed, PR welcome. That's a good start. |
Debug is not a class. Don't call it with |
Thank you, @qix. I deleted my comment since it was incorrect. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I've been doing similar research into CJS/ESM for metalsmith and documented findings in this issue. TLDR:
In the case of debug, potentially even more build outputs would be required to work with native browser imports & bundlers. |
Not using ESModules is breaking my build. This lib is buried deep in dependency chain of a lib I wanted to use and it is now not usable beucause of the incorrect modules.export usage. So, please fix soon, as this might break down many builds. |
hey @Qix- |
Today, debug use module.exports facility.
But nodejs and browser can support import / export notation, aka es6 modules.
While preparing the v5, why not going into that mode?
#656 ?
The text was updated successfully, but these errors were encountered: