-
Notifications
You must be signed in to change notification settings - Fork 241
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
Make it more ESM module friendly #281
Comments
Is this using the ESM integration within Node.js or is this part of the functionality of a bundler like webpack? |
This is part of Node.js, yes, no bundler needed. |
I think EventEmitter2 initially got exported the way it has due to how Node.js' built-in I'd be a bit worried about backwards compat, but maybe we could release a new major version for just those folks that want it. 🤷 Alternately, could we have a separate file for ESM imports that imports the commonjs module and then gives more appropriate ESM exports? |
This issue is not fixed. Adding type definitions only tricks Typescript into thinking it works, when in reality the import breaks during runtime, as Node.js cannot find the EventEmitter2 named export. |
Right now, with ESM modules, we can't do this:
and instead have to do this:
This is a great blog post that explains the issue: https://simonplend.com/node-js-now-supports-named-imports-from-commonjs-modules-but-what-does-that-mean/
Is there anything we can do to make this library more friendly to modern module specs?
Ideally
EventEmitter2
would be a default export and not a named export.The text was updated successfully, but these errors were encountered: