qmhc / vite-plugin-dts

A Vite plugin for generating `.d.ts` files.
MIT License
1.22k stars 84 forks source link

Declaration map d.ts.map files do not match transformed d.ts files #356

Closed ruscoder closed 1 month ago

ruscoder commented 1 month ago

Describe the bug

I found that d.ts.map does not match d.ts file after some transformations from vite-plugin-dts. It leads to issues with debugging and navigation in IDE.

Original (after tsc): https://stackblitz.com/edit/vitejs-vite-jeijwx?file=tscdist%2Fb.d.ts

Transformed d.ts (after vite-plugin-dts): https://stackblitz.com/edit/vitejs-vite-jeijwx?file=dist%2Fb.d.ts

And d.ts.map are the same https://stackblitz.com/edit/vitejs-vite-jeijwx?file=dist%2Fb.d.ts.map https://stackblitz.com/edit/vitejs-vite-jeijwx?file=tscdist%2Fb.d.ts.map

Reproduction

https://stackblitz.com/edit/vitejs-vite-jeijwx?file=dist%2Fb.d.ts

Steps to reproduce

No response

System Info

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M1 Pro
    Memory: 83.36 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.8.1 - /opt/homebrew/bin/npm
    pnpm: 8.6.10 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 126.0.6478.185
    Safari: 17.5
  npmPackages:
    @vitejs/plugin-react: ^4.0.0 => 4.0.3
    vite: ^4.1.5 => 4.1.5
    vite-plugin-dts: ^4.0.0-beta.1 => 4.0.0-beta.1

Validations

ruscoder commented 1 month ago

I started working on fixing the particular issue with an extra new line, but it is not a solution for the issue in general. https://github.com/beda-software/vite-plugin-dts/tree/patch-356

The transformation that vite-plugin-dts makes, might change d.ts file significantly, so, maps files won't be accurate in some cases.