Closed rayzr522 closed 1 year ago
(the original bug report was actually inaccurate as I misunderstood the reproduction steps -- please see new report below)
the title is a bit long winded, wasn't sure exactly how to best describe the issue. but tl;dr, if I import a const from a file, take the type of it, and then export that and then re-export it in my entry file, watch mode behaves as expected. however, if I take that initially imported const, reassign it to a new variable, and then take the type of it, the file it was originally imported from is no longer watched.
I've updated the repo repo here with a more minimal repro: https://github.com/rayzr522/tsup-watch-type-imports-bug
and here's a demo video of the issue:
I have been digging around in the codebase a bit trying to repro, but I can't quite tell where the issue is.
p.s.: in case you were wondering, I did try repro'ing this without the in-between file and the re-export in my entry, and doing the typeof
directly in my entry file and I couldn't reproduce it; watching always worked correctly:
damn. i repro'd the issue w just rollup & rollup-plugin-dts, so it's a rollup-plugin-dts
issue it seems. I'll go open an issue over there!
thanks for the amazing lib :)
in case anyone stumbles across this and wants to know what came of this issue, you can follow the corresponding rollup-plugin-dts issue here: https://github.com/Swatinem/rollup-plugin-dts/issues/248
it looks like tsup doesn't actually watch files that are only imported for their types
this is a huge DX issue when dealing with tRPC, because in order to avoid including a bunch of server-only dependencies in my client package that I'm building, I have to reference & export only the type of my routers, but not the actual router itself
here's a minimal reproduction repro along w a video demonstrating the issue: https://github.com/rayzr522/tsup-watch-type-imports-bug
https://user-images.githubusercontent.com/15263431/218244417-6be2a6cf-0300-47bd-8b23-c35eb2599d02.mp4
EDIT: I just realized the bug wasn't exactly what I thought it was, and am having a hard time reproducing the issue in my MVP repo. I will post an update here once I've figured it out, so sorry for the confusion!