DioxusLabs/dioxus · error · anyhow::Error
esbuild failed
Error message
esbuild failed: {stderr} What it means
Raised in run_esbuild (called from process_js) after spawning the esbuild binary on a JS/TS asset: the process ran but exited with a non-success status. This is an external tool failure — typically a syntax/type error in the source, an unresolvable import, or unsupported esbuild options — and esbuild's captured stderr is included to pinpoint the failing input.
Solutions
- esbuild failed. Fix the JavaScript error printed in its stderr output.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/cli/src/opt/js.rs:85 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23).
Data as JSON: /api/errors/036f2bb05aef5988.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/opt/js.rs:85
}
if lexer::js_is_module(js_options, source) {
cmd.arg("--bundle");
cmd.arg("--format=esm");
// Don't try to resolve URL-based imports at build time — let the
// browser fetch them at runtime. Without these externals, esbuild
// errors out on patterns like `import x from "https://cdn/lib.js"`.
cmd.arg("--external:https://*");
cmd.arg("--external:http://*");
}
tracing::debug!("Running esbuild: {:?}", cmd);
let output = cmd.output().context("Failed to run esbuild")?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
anyhow::bail!("esbuild failed: {stderr}");
}
Ok(())
}
pub(crate) fn hash_js(
_js_options: &JsAssetOptions,
source: &Path,
hasher: &mut impl std::hash::Hasher,
) -> anyhow::Result<()> {
hash_file_contents(source, hasher)
}
pub use lexer::*;
mod lexer {
//! Detect whether a JavaScript source file uses ES module syntax.
//!
//! This is a token-level scanner inspired by Guy Bedford's `es-module-lexer`View on GitHub (pinned to 24f6a829df)