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

Watch mode not working on v8.3.4 / v8.3.5 #1245

Open paulcjy opened 4 weeks ago

paulcjy commented 4 weeks ago

It works until v8.3.0 but doesn't work on next releases v8.3.4 and v8.3.5.

v.8.3.0

There are two lines at the bottom and watch mode works well.

CLI Watching for changes in "."
CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"
image

v8.3.4 / v8.3.5

No messages for watch mode and watch mode doesn't work as well.

image

Upvote & Fund

Fund with Polar

ghiscoding commented 3 weeks ago

it might be, due to recent upgrade of Chokidar to v4 in PR #1211. Perhaps the new glob (from tinyglobby) should add the { dot: true } option? cc @SuperchupuDev

SuperchupuDev commented 3 weeks ago

could be, would have to check how chokidar v3 did globbing

r-rayns commented 1 week ago

I'm having the same issue. I had version 8.3.5 installed in a project which was running Express.

When I run the project I do not see the typical watch mode message, which looks something like:

CLI Watching for changes in "."
CLI Ignoring changes in "**/{.git,node_modules}/**" | "dist"

The project does not reload on changes.

However! If I stop my Express server from running:

// stop express server from running
// server.listen(8080, () => console.log('Server is live'))

Removing this line of code and restarting my app, I see the expected watch mode message and my project does reload on changes.

Downgrading to 8.3.0 works whether my Express server is running or not. So that is what I've done for now. Hope this extra bit of information helps!

methompson commented 1 day ago

I'm encountering the same issue, but it seems the onSuccess CLI option is what's causing the problem.

When I run npx tsup ./src/main.ts --watch from the terminal, I get the line CLI Watching for changes in "." and a compile event occurs on every save. Whereas, if I run npx tsup ./src/main.ts --watch --onsuccess="node dist/main.js", it doesn't have the watching changes line and does nothing further on save.

methompson commented 1 day ago

I've reviewed the source and I think I've found the cause. I added a bunch of log statements to the JS files in the node_modules dist folder and I found that there's a point where the code no longer progresses.

I'm pretty sure it's related to this line: https://github.com/egoist/tsup/blame/cd03e1e00ec2bd6676ae1837cbc7e618ab6a2362/src/index.ts#L357

Which, ultimately was updated with this PR which lines up with the timeframe for the last 2 versions not working correctly: https://github.com/egoist/tsup/commit/4dd5bfeb2f1973242e2f9700a3061aee9d8af988

If I comment this line out in my dist folder (which, unfortunately, is elsewhere, because it's been transpiled), watch runs as normal.

I will provide a PR soon as a band-aid solution. Even if it's NOT the solution, it would behoove us to figure out what that goal is for the await statement, considering it breaks the functionality as listed in the documentation

methompson commented 1 day ago

PR: https://github.com/egoist/tsup/pull/1253