isaacs / node-lru-cache

A fast cache that automatically deletes the least recently used items
http://isaacs.github.io/node-lru-cache/
ISC License
5.38k stars 353 forks source link

fix: change the order of `exports` field keys to fix type resolution #323

Closed haoqunjiang closed 1 year ago

haoqunjiang commented 1 year ago

As both ./min and . points to the same type definition file, sometimes TypeScript will resolve the type definition entry to the ./min key as it appears first.

https://github.com/microsoft/TypeScript/issues/56290#issuecomment-1792883895

While this is not incorrect behavior, it breaks compatibility with older build environments that do not support the exports field. (e.g. TypeScript with moduleResolution: "node" instead of bundler or node16), as the ./min entry is only available through the exports field.

Some Vue.js users are experiencing this issue: https://github.com/vuejs/core/issues/9521

isaacs commented 1 year ago

As it happens, I'm in the middle of refactoring the artisanal hand-crafted build scripts to use tshy anyway, will do this as part of that.