omgovich / colord

👑 A tiny yet powerful tool for high-performance color manipulations and conversions
https://colord.omgovich.ru
MIT License
1.63k stars 48 forks source link

TypeScript 4.7 - Add missing ESM `types` subpath export condition #94

Closed scott-lc closed 1 year ago

scott-lc commented 1 year ago

The TypeScript 4.7 NodeNext module resolver does not honor the legacy types property in the package.json file. You need to add a types export condition as described here.

Note that the "types" condition should always come first in "exports".

With this change, your package.json exports should look something like:


{
  // ...
  "exports": {
    ".": {
      "types": "./index.d.ts",      // <-- Add this
      "import": "./index.mjs",
      "require": "./index.js",
      "default": "./index.mjs"
    },
    "./plugins/a11y": {
      "types": "./plugins/a11y.d.ts",   // And this
      "import": "./plugins/a11y.mjs",
      "require": "./plugins/a11y.js",
      "default": "./plugins/a11y.mjs"
    },
    // ...
    "./plugins/xyz": {
      "types": "./plugins/xyz.d.ts",    // etc.
      "import": "./plugins/xyz.mjs",
      "require": "./plugins/xyz.js",
      "default": "./plugins/xyz.mjs"
    }
  }
}
omgovich commented 1 year ago

Hi! Thanks for reporting! @pkishorez made a fix and I released it in v2.9.3