unjs / fontaine

Automatic font fallback based on font metrics
MIT License
1.47k stars 23 forks source link

fix: support `moduleResolution: "Bundler"` in TS #275

Closed kripod closed 10 months ago

kripod commented 10 months ago

While importing 'fontaine' from an ES module context (either a '.mjs' file or a '.js' file when type: "module" is present within the consumer’s package.json file), type declarations for 'node_modules/fontaine/dist/index.mjs' can’t be resolved.

There are types at 'node_modules/fontaine/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'fontaine' library may need to update its package.json or typings.

By adding a "types" conditional export explicitly, TypeScript projects would be able to resolve the type declarations of fontaine when moduleResolution: "Bundler" is specified within TSConfig.

danielroe commented 10 months ago

I believe this is already fixed with the latest unbuild upgrade - fontaine just needs to be rebuilt + published.

danielroe commented 10 months ago

Yes - looks good now: https://arethetypeswrong.github.io/?p=fontaine.

danielroe commented 10 months ago

Oh - and thank you very much for spotting the issue and opening the PR ❤️