⚠️ Breaking Changes
ESM-only
This release converts the package to ESM-only. CommonJS require() is no longer supported.
// ❌ No longer works
const getContrastRatio = require('get-contrast-ratio')
// ✅ Option 1: Convert to ESM
import getContrastRatio from 'get-contrast-ratio'
// ✅ Option 2: Use dynamic import
const { default: getContrastRatio } = await import('get-contrast-ratio')For consumers already using ESM: no changes needed.
See the ESM Module FAQ for more guidance.
Dropped support for old Node.js versions
Node.js 8, 10, and 11 are no longer supported. The package is tested on Node.js 20, 22, and 24.
What's Changed
Refactored to TypeScript
The source has been rewritten in TypeScript and built with tsc (previously Babel). TypeScript type declarations are now included — no @types/ package needed.
There are no functional changes to the API.
Updated dependency: get-relative-luminance 0.3.1 → 2.0.0
The underlying luminance calculation dependency has been updated to its stable 2.0.0 release, which also ships as ESM.
Build tooling modernized
- ESLint 9 with flat config
- TypeScript 5.9
tsxfor test execution (replacests-node)- CI moved from Travis CI to GitHub Actions
Full changelog: v0.2.1...v1.0.0