jashkenas / underscore

JavaScript's utility _ belt
https://underscorejs.org
MIT License
27.29k stars 5.53k forks source link

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

Closed naugtur closed 2 years ago

naugtur commented 2 years ago

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

naugtur commented 2 years ago

ok, I found this https://github.com/jashkenas/underscore/blob/master/modules/package.json

Can't say I like the idea :D

jgonggrijp commented 2 years ago

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.

naugtur commented 2 years ago

.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 🤷

jgonggrijp commented 2 years ago

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.