jashkenas/underscore

modules/* are defined as CJS in package.json exports

naugtur opened this issue · 4 comments

the default keyword will most likely be interpreted as pointing to CJS files. Was that supposed to be import?
https://github.com/jashkenas/underscore/blob/master/package.json#L46

I agree it's an ugly hack. There's not much I can do about it, given that the Node.js maintainers decided to put up all kinds of barriers between CommonJS and ESM and given that I didn't want to break backwards compatibility.

.mjs is less surprising, at least to me as someone who works on loading packages. Implementing lookups for package.json in every folder sucks, but it is established and had to be done 🤷

Also, if you ask me, .mjs is an ugly hack as well. It's very specific to Node.js as well, while the modules/* are mostly intended for consumption by bundling tools.