You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working on writing a copy plugin for esbuild (yeah, yet another one, the existing ones unfortunately don't cover my use cases...). I want to be able to properly watch files when using watch mode, and so far, almost everything works kind of nicely. I just encountered a small problem: I can't find a way to have the plugin react to watch mode being stopped (.stop() being called on the BuildResult). But this is needed to do cleanup, i.e. stop the chokidar file watcher. When running esbuild regularly, not doing the cleanup probably is not an issue, but in unit tests (with jest), if the cleanup is not done, the tests start interfering with each other because the chokidar watcher outlives the individual test cases.
It seems like there is no way to do this because stop is synchronous, but the cleanup of the chokidar file watcher needs to be asynchronous. But I thought, I'd ask anyways, so is there a way to do this? Other copy plugins that handle watching simply seem to ignore this problem (e.g. https://github.com/tinchoz49/esbuild-plugin-copy-watch).
If there is no way to do this, how would you handle this kind of thing instead?
The text was updated successfully, but these errors were encountered:
Hey there,
I am currently working on writing a copy plugin for esbuild (yeah, yet another one, the existing ones unfortunately don't cover my use cases...). I want to be able to properly watch files when using watch mode, and so far, almost everything works kind of nicely. I just encountered a small problem: I can't find a way to have the plugin react to watch mode being stopped (
.stop()
being called on theBuildResult
). But this is needed to do cleanup, i.e. stop the chokidar file watcher. When running esbuild regularly, not doing the cleanup probably is not an issue, but in unit tests (with jest), if the cleanup is not done, the tests start interfering with each other because the chokidar watcher outlives the individual test cases.It seems like there is no way to do this because
stop
is synchronous, but the cleanup of the chokidar file watcher needs to be asynchronous. But I thought, I'd ask anyways, so is there a way to do this? Other copy plugins that handle watching simply seem to ignore this problem (e.g. https://github.com/tinchoz49/esbuild-plugin-copy-watch).If there is no way to do this, how would you handle this kind of thing instead?
The text was updated successfully, but these errors were encountered: