[Bug]: generated .d.ts not handle imports' extensions correctly #678
Open
Description
Version
System:
OS: Windows 11 10.0.26100
CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700
Memory: 2.34 GB / 15.77 GB
Browsers:
Edge: Chromium (131.0.2903.63)
Internet Explorer: 11.0.26100.1882
npmPackages:
@rslib/core: ^0.3.1 => 0.3.1
Details
dist/es/index.d.ts
expected:
export { foo } from './foo.js';
actual:
export { foo } from './foo';
dist/lib/index.d.cts
expected:
export { foo } from './foo.cjs';
actual:
export { foo } from './foo';
Reproduce link
https://github.com/Jungzl/rslib-project-issue-demo/tree/issue/dts
Reproduce Steps
- pnpm build
- pnpm attw
🥴 Import found in a type declaration file failed to resolve. Either this indicates that runtime resolution errors will occur, or (more likely) the types misrepresent the contents of the
JavaScript files. Use -f json to see the imports that failed to resolve. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/InternalResolutionError.md
┌───────────────────┬──────────────────────────────┬──────────────────────────────┐
│ │ "rslib-project" │ "rslib-project/package.json" │
├───────────────────┼──────────────────────────────┼──────────────────────────────┤
│ node10 │ 🥴 Internal resolution error │ 🟢 (JSON) │
├───────────────────┼──────────────────────────────┼──────────────────────────────┤
│ node16 (from CJS) │ 🥴 Internal resolution error │ 🟢 (JSON) │
├───────────────────┼──────────────────────────────┼──────────────────────────────┤
│ node16 (from ESM) │ 🥴 Internal resolution error │ 🟢 (JSON) │
├───────────────────┼──────────────────────────────┼──────────────────────────────┤
│ bundler │ 🟢 │ 🟢 (JSON) │
└───────────────────┴──────────────────────────────┴──────────────────────────────┘
after manually add extensions from above:
No problems found 🌟
┌───────────────────┬─────────────────┬──────────────────────────────┐
│ │ "rslib-project" │ "rslib-project/package.json" │
├───────────────────┼─────────────────┼──────────────────────────────┤
│ node10 │ 🟢 │ 🟢 (JSON) │
├───────────────────┼─────────────────┼──────────────────────────────┤
│ node16 (from CJS) │ 🟢 (CJS) │ 🟢 (JSON) │
├───────────────────┼─────────────────┼──────────────────────────────┤
│ node16 (from ESM) │ 🟢 (ESM) │ 🟢 (JSON) │
├───────────────────┼─────────────────┼──────────────────────────────┤
│ bundler │ 🟢 │ 🟢 (JSON) │
└───────────────────┴─────────────────┴──────────────────────────────┘
Metadata
Assignees
Labels
No labels