vite icon indicating copy to clipboard operation
vite copied to clipboard

feat(server)!: use parcel watcher

Open bluwy opened this issue 2 years ago • 2 comments

Description

Decided to give https://github.com/vitejs/vite/issues/13593 another shot before deciding if we should fit it into Vite 5. But with the state of the implementation, I don't think it's feasible (for now).

This PR implements a hybrid @parcel/watcher + fs.watch approach, where the former is used for root recursive watching, and the latter for non-recursive watching. https://github.com/parcel-bundler/watcher/issues/92

It also implements chokidar's watcher interface for better compatibility. Ultimately it feels like I'm re-implementing chokidar and would be better as a standalone library, but it's easier to test this way for now.

Additional context

WIP TODO:

  • Implement unfinished API
  • Make sure it's compatible with chokidar
    • getWatched compatible
    • unwatch and add on the same path should continue watching
    • unlinkDir not correctly detected
  • Make tests pass
  • Update docs

What is the purpose of this pull request?

  • [ ] Bug fix
  • [x] New Feature
  • [ ] Documentation update
  • [ ] Other

bluwy avatar Oct 23 '23 06:10 bluwy

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Short FYI that also a polling solution is important (what Chokidar does with CHOKIDAR_USEPOLLING=1). I faced this again this week, running development under a VM with mounts to my desktop account. Such mounts don't usually pass change notifications, but the said env.var. has worked nice.

lure23 avatar Apr 19 '24 15:04 lure23

Closing this for now as I haven't got to finishing this and requires a large rebase. It would still be helpful for others who like to bring this across the line though. My notes about parcel watcher at https://github.com/vitejs/vite/issues/13593#issuecomment-1776906216 still remain.

bluwy avatar May 18 '24 06:05 bluwy