- 3N
Fixes #92.
Repro: TS project with moduleResolution node importing { clsx } from 'clsx/lite' fails with TS2307 before this change, passes after. bundler mode still passes.
Root cause: ./lite exposed only via exports map; classic node resolution ignores exports and looks for lite.d.ts at root.
Change: package.json adds typesVersions { *: { lite: [./clsx.d.ts] } }; readme notes bundler/nodenext/node16+ for full exports support.
Tests: npm run build + npm test green; tsc matrix node=pass, bundler=pass; CJS smoke clsx('hello', true && 'foo') => 'hello foo'. Trace snippet attached in comments.
Unknown GitHub usercommitted cc53c09e0ce52 months ago on GitHub
Unknown GitHub usercommitted 60f1d38a9b2f2 months ago on GitHub
- 3N
`tsc --traceResolution` (TS 5.5.4, `moduleResolution: node`) after fix — local paths shortened to `<repro>`:
``` ======== Resolving module 'clsx/lite' from '<repro>/check.ts'. ======== Explicitly specified module resolution kind: 'Node10'. Loading module 'clsx/lite' from 'node_modules' folder, target file types: TypeScript, Declaration. Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration. Found 'package.json' at '<repro>/node_modules/clsx/package.json'. 'package.json' has a 'typesVersions' field with version-specific path mappings. 'package.json' has a 'typesVersions' entry '*' that matches compiler version '5.5.4', looking for a pattern to match module name 'lite'. Module name 'lite', matched pattern 'lite'. Trying substitution './clsx.d.ts', candidate module location: './clsx.d.ts'. File '<repro>/node_modules/clsx/clsx.d.ts' exists - use it as a name resolution result. ======== Module name 'clsx/lite' was successfully resolved to '<repro>/node_modules/clsx/clsx.d.ts'. ======== ```
Before the fix, the same project failed with `TS2307: Cannot find module 'clsx/lite'`. (Earlier version of this comment pasted raw local paths — replaced with the sanitized trace above; proof unchanged.)
typesmentioned2 months ago on GitHub