mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 20:38:55 +00:00
fix(serve): support serve hmr (#26078)
This PR addresses issue #25600 Changes: Updated `fn has_hmr` to check `serve` subcommand and return its hmr value if found, in order to run the worker in serve mode with hmr_runner. Thus the hmr event can be dispatched upon changes on the file served.
This commit is contained in:
parent
1431ffa9f8
commit
5f5ac40631
@ -1452,6 +1452,12 @@ impl CliOptions {
|
||||
watch: Some(WatchFlagsWithPaths { hmr, .. }),
|
||||
..
|
||||
}) = &self.flags.subcommand
|
||||
{
|
||||
*hmr
|
||||
} else if let DenoSubcommand::Serve(ServeFlags {
|
||||
watch: Some(WatchFlagsWithPaths { hmr, .. }),
|
||||
..
|
||||
}) = &self.flags.subcommand
|
||||
{
|
||||
*hmr
|
||||
} else {
|
||||
|
@ -44,12 +44,15 @@ pub async fn serve(
|
||||
maybe_npm_install(&factory).await?;
|
||||
|
||||
let worker_factory = factory.create_cli_main_worker_factory().await?;
|
||||
|
||||
let hmr = serve_flags
|
||||
.watch
|
||||
.map(|watch_flags| watch_flags.hmr)
|
||||
.unwrap_or(false);
|
||||
do_serve(
|
||||
worker_factory,
|
||||
main_module.clone(),
|
||||
serve_flags.worker_count,
|
||||
false,
|
||||
hmr,
|
||||
)
|
||||
.await
|
||||
}
|
||||
@ -109,8 +112,6 @@ async fn do_serve(
|
||||
}
|
||||
}
|
||||
Ok(exit_code)
|
||||
|
||||
// main.await?
|
||||
}
|
||||
|
||||
async fn run_worker(
|
||||
@ -119,7 +120,7 @@ async fn run_worker(
|
||||
main_module: ModuleSpecifier,
|
||||
hmr: bool,
|
||||
) -> Result<i32, AnyError> {
|
||||
let mut worker = worker_factory
|
||||
let mut worker: crate::worker::CliMainWorker = worker_factory
|
||||
.create_main_worker(
|
||||
deno_runtime::WorkerExecutionMode::Serve {
|
||||
is_main: false,
|
||||
|
Loading…
Reference in New Issue
Block a user