Rename the files to mjs
stevefan1999-personal opened this issue · comments
Guidelines
- Please search other issues to make sure this feature has not already been requested.
Which problem is this feature request solving?
This prevents the module to be accidentally loaded in a CommonJS context since Node will resolve the ESM files by its extension, so we can mix both world
Describe the solution you'd like
Just rename the source files to mjs
Pull request (optional)
- I can submit a pull request.
Hi @stevefan1999-personal, 👋
Thanks for your message. When using CommonJS, this module should be loaded using a dynamic import()
. Using a static import
of a ESM module from CommonJS is an error from the consumer, not the library.
I do agree that preventing consumer errors is a good thing, and using *.mjs
would achieve that. However, in this case, I think the instruction in the "Install" section of the README
should be enough.
Thanks a lot for suggesting it though!