doodlewind / nativebird

🐦 Bluebird alternative within ~200 loc
78 stars 8 forks source link

Add a cjs version? #10

Closed so1ve closed 1 year ago

so1ve commented 1 year ago

Though esm is the future of JavaScript, there are still many projects using cjs. If we can use nativebird in cjs (such as hexo - to drop bluebird) it would be fantastic.

If you like I can send a pr.

doodlewind commented 1 year ago

Thanks for your interest! I think the CJS build is already provided (see https://github.com/doodlewind/nativebird/blob/main/scripts/build.cjs#L11), but I'm not sure if all related setups work. I'm open to related fixes.

so1ve commented 1 year ago

Ah, thanks for pointing it out! I missed that part 😢

One more question: there is type: module in package.json 🤔 , does it prevents users to require() this package?

doodlewind commented 1 year ago

To my knowledge, in this case Node will treat the package as an ES6 module, but if a user tries to require() it in a CommonJS context, Node will attempt to load it as a CommonJS module. And that's why we need the .cjs suffix to distinguish between them.

Anyway it's just in theory, feel free to try it out locally!

so1ve commented 1 year ago

Thanks for your explanation!

谢谢雪碧佬 =v=