Open JTRNS opened 2 weeks ago
Using serve
: Could you please check if the content on browser updates when you update the file, it should do, also the logs
// HMR File change detected! Restarting!
// deno serve: Listening on http://0.0.0.0:8000/
actually refresh when you update the TS file.
I believe that hmr-watch is functioning for both serve
and run
, the only difference is the logs.
The additional logs for run
:
// { path: "file:///home/jtrns/tmp/deno-hmr-serve/main.ts" }
// HMR Replaced changed module file:///home/jtrns/tmp/deno-hmr-serve/main.ts
I believe they're caused by some behavior only for run. I noticed that fn run
in cli/tools/run/hmr.rs is responsible for it.
@HasanAlrimawi Having some difficulty trying to understand exactly what you are asking. Obviously nothing changes in the browser in this simple server example, as (Vite like) HMR for the front-end, is a bit more complex than that.
It is not just the logs. The "watch" part, of --watch-hmr works fine. Or in other words, the file watcher that ensures a process restart on file changes works well. However HMR, which is different than a basic file watcher that restarts the process, without access to the path of the file that changed, would be somewhat useless.
Version: Deno 2.0.0-rc.2
The "hmr" event does not seem to get emitted when the
--watch-hmr
flag is used in combination withdeno serve
. In combination withdeno run
is works as expected.Example
Running the code below with
deno serve --watch-hmr main.ts
and making a change will log:Running the more or less equivalent code below with
deno run --watch-hmr --allow-net main.ts
will log: