@nkp/supports-color
Detect whether a terminal supports color.
Fork of supports-color
with support for both ESM and CommonJS.
Table of contents
Exports
@nkp/supports-color
exports both CommonJS and ES modules.
Fork
@nkp/supports-color
is a fork of supports-color
that exports both ESM and CommonJS.
In 2021 Sindre Sorhus, prolific creator and maintainer of many popular npm packages
, including some with over 150 million weekly monthly downloads, pushed a new major version of many of his packages removing CommonJS support and making them "pure ESM". This was a major breaking change. Sindre's universally popular packages were now incompatible with a large parts of the NodeJS ecosystem.
Sindre's packages could have been kept backwards compatible by producing both ESM and CJS exports, however Sindre believed he could push the NodeJS community to adopt ESM sooner by introducing breaking changes.
Personally, I plan to (migrate to Pure ESM instead of provide backwards compatibility) as I think it’s better to rip off the bandaid and push the ecosystem forward.
For many, the breaking change's haven't gone over well. Many project's now find themselves spending hours, days or even weeks trying to placate these pure EMS packages only to find too many incompatibilities and revert back.
Hence this fork. @nkp/supports-color
is intended to be an functionally equivalent clone of styles-ansi
but with both ESM and CJS exports.
Installation
npm
npm install @nkp/supports-color
yarn
yarn add @nkp/supports-color
pnpm
pnpm add @nkp/supports-color
Publishing
To a release a new version:
- Update the version number in package.json
- Push the new version to the
master
branch on GitHub - Create a
new release
on GitHub for the latest version
This will trigger a GitHub action that tests and publishes the npm package.