summaryrefslogtreecommitdiff
path: root/cli/worker.rs
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2024-08-14 15:21:11 +0200
committerGitHub <noreply@github.com>2024-08-14 15:21:11 +0200
commit130a2592f1e946be563c7f167d7127f49a1014d1 (patch)
treea63627f8e153269b97c70bf4fc0445e6055dd1bd /cli/worker.rs
parent533d31bc4e9c0cae2b9047850c39c68bf494595e (diff)
fix(cli): support --watch when running cjs npm packages (#25038)
Diffstat (limited to 'cli/worker.rs')
-rw-r--r--cli/worker.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/cli/worker.rs b/cli/worker.rs
index 8673804ab..82051da6c 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -280,7 +280,22 @@ impl CliMainWorker {
/// Execute the given main module emitting load and unload events before and after execution
/// respectively.
pub async fn execute(&mut self) -> Result<(), AnyError> {
- self.inner.execute_main_module_possibly_with_npm().await?;
+ if self.inner.is_main_cjs {
+ deno_node::load_cjs_module(
+ &mut self.inner.worker.js_runtime,
+ &self
+ .inner
+ .main_module
+ .to_file_path()
+ .unwrap()
+ .to_string_lossy(),
+ true,
+ self.inner.shared.options.inspect_brk,
+ )?;
+ } else {
+ self.inner.execute_main_module_possibly_with_npm().await?;
+ }
+
self.inner.worker.dispatch_load_event()?;
self.pending_unload = true;