Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for both CJS and ESM #9

Closed
kedrzu opened this issue Feb 25, 2022 · 1 comment
Closed

Add support for both CJS and ESM #9

kedrzu opened this issue Feb 25, 2022 · 1 comment

Comments

@kedrzu
Copy link

kedrzu commented Feb 25, 2022

Using this package in Node JS with any other packages written in CJS is hardly possible.
Would be cool to have both formats in one package.

It's as easy as adding to package.json:

"exports": {
    ".": {
      "require": "./index.cjs", // CJS
      "import": "./index.mjs"   // ESM
    }
}

Source: https://antfu.me/posts/publish-esm-and-cjs

I see a lot of packages, that migrate to ESM without providing any backward compatibility, rendering those packages almost impossible to use in a real dev environment.

If you are not sure, that still supporting CJS is a good thing, take a look at package statistics:
image

It's 17x more downloads for CJS version than ESM one.

@sindresorhus
Copy link
Owner

No plans to support CommonJS. Hybrid packages have a lot of problems too.

https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

Repository owner locked as resolved and limited conversation to collaborators Feb 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants