oven-sh/bun · error · anyhow::Error
Failed to compile MDX
Error message
Failed to compile MDX: {:?} What it means
Wraps a failure of the mdxjs crate to compile a .mdx input in the bun-mdx-rs loader plugin (syntax error or unsupported MDX construct); the underlying error is stringified into an anyhow error returned to the plugin caller.
Solutions
- Reproduce with a minimal .mdx file to isolate the failing construct
- Check for MDX/JSX syntax unsupported by the mdxjs crate version in use
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at packages/bun-build-mdx-rs/src/lib.rs:20 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/e884d16c3af2e667.
Report an issue: GitHub.
Appendix: source
Thrown at packages/bun-build-mdx-rs/src/lib.rs:20
use mdxjs::{compile, Options as CompileOptions};
use napi_derive::napi;
define_bun_plugin!("bun-mdx-rs");
#[bun]
pub fn bun_mdx_rs(handle: &mut OnBeforeParse) -> Result<()> {
let source_str = handle.input_source_code()?;
let mut options = CompileOptions::gfm();
// Leave it as JSX for Bun to handle
options.jsx = true;
let path = handle.path()?;
options.filepath = Some(path.to_string());
let jsx = compile(&source_str, &options)
.map_err(|e| anyhow::anyhow!("Failed to compile MDX: {:?}", e))?;
handle.set_output_source_code(jsx, BunLoader::BUN_LOADER_JSX);
Ok(())
}
View on GitHub (pinned to 8c5296ac45)