egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
9.29k stars 223 forks source link

`experimentalDts` does not work with `Node16` and `NodeNext` module resolution #1224

Closed aryaemami59 closed 1 month ago

aryaemami59 commented 2 months ago

Overview

Currently experimentalDts does not emit the correct type definitions when moduleResolution is set to either Node16 or NodeNext. The _tsup-dts-rollup.d.ts file is trying to import from the index.d.ts file which causes a circular reference.

_tsup-dts-rollup.d.ts

![rollup](https://github.com/user-attachments/assets/a9b58ea7-6471-487a-a166-7d012698da1b)

index.d.ts

![index-circular](https://github.com/user-attachments/assets/5e4b966e-8d21-416d-b538-dd93e7b56238)

Reproduction

  1. Clone the branch containing the reproduction by running:
git clone -b experimentalDts-NodeNext https://github.com/aryaemami59/repros
  1. Install the dependencies:
yarn install
  1. Run the following command:
yarn run build:node-next
  1. Inspect the output in the dist directory.

I will submit a PR for the fix.