fix(bundle): properly display error on invalid config in watch mode (#30621)
Some checks are pending
ci / build libs (push) Blocked by required conditions
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / pre-build (push) Waiting to run
ci / publish canary (push) Blocked by required conditions

Fixes https://github.com/denoland/deno/issues/30617
This commit is contained in:
Nathan Whitaker 2025-09-04 19:21:59 -07:00 committed by GitHub
parent db263a14d4
commit 6d0692e00a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 5 deletions

View file

@ -184,6 +184,16 @@ pub async fn bundle(
let duration = end.duration_since(start);
if bundle_flags.watch {
if !response.errors.is_empty() || !response.warnings.is_empty() {
handle_esbuild_errors_and_warnings(
&response,
&init_cwd,
&bundler.plugin_handler.take_deferred_resolve_errors(),
);
if !response.errors.is_empty() {
deno_core::anyhow::bail!("bundling failed");
}
}
return bundle_watch(
flags,
bundler,
@ -400,7 +410,8 @@ impl EsbuildBundler {
.client
.send_build_request(self.make_build_request())
.await
.unwrap();
.unwrap()
.map_err(|e| message_to_error(&e, &self.cwd))?;
Ok(response)
}
@ -411,7 +422,13 @@ impl EsbuildBundler {
panic!("rebuild not supported for one-shot mode")
}
BundlingMode::Watch => {
let _response = self.client.send_rebuild_request(0).await.unwrap();
log::trace!("sending rebuild request");
let _response = self
.client
.send_rebuild_request(0)
.await
.unwrap()
.map_err(|e| message_to_error(&e, &self.cwd))?;
let response = self.on_end_rx.recv().await.unwrap();
Ok(response.into())
}
@ -419,6 +436,13 @@ impl EsbuildBundler {
}
}
fn message_to_error(
message: &esbuild_client::protocol::Message,
current_dir: &Path,
) -> AnyError {
deno_core::anyhow::anyhow!("{}", format_message(message, current_dir))
}
// TODO(nathanwhit): MASSIVE HACK
// See tests::specs::bundle::requires_node_builtin for why this is needed.
// Without this hack, that test would fail with "Dynamic require of "util" is not supported"