huozhi / bunchee

Zero config bundler for ECMAScript and TypeScript packages
https://npmjs.com/bunchee
859 stars 28 forks source link

[question] Should `prepare` use mjs entry for `main` field? #515

Closed hyoban closed 2 months ago

hyoban commented 2 months ago

https://github.com/frehner/modern-guide-to-packaging-js-library#set-the-main-field

main should point to a CommonJS-compatible bundle; it should probably match the same file as your package export's require field.

https://github.com/huozhi/bunchee/blob/521c5a9a7ec0c69bcda7afe77e1580b01c118d10/src/prepare.ts#L234-L239

huozhi commented 2 months ago

CJS and esm entry are both available, it doesn't have to be a CJS file