When using tsup
to bundle typescript and generate sourcemaps, it will not generate accurate map files if the target map file already exists in the output directory. It will instead copy the sourcesContent
from the existing map file, even if it is completely outdated and incorrect. The built javascript file is updated and correct, only the map file is wrong.
To avoid this currently, clean
option must be set to delete the map file, then generate a fresh map.
tsup index.ts --sourcemap
index.ts
tsup index.ts --sourcemap
againindex.ts.map
does not have the correct sourcesContent
There are other ways to show the issue, i.e. using --watch
and not having map files updated, or even manually editing the index.js.map
file to have incorrect sourcesContent
, and running build again to see that it is not changed.
https://github.com/garikkh/tsup-sourcemaps-demo/tree/main
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too