diff --git a/Cargo.lock b/Cargo.lock index d006fd85fef8e..adf16f848a5b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -308,6 +308,16 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "console_error_panic_hook" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" +dependencies = [ + "cfg-if", + "wasm-bindgen", +] + [[package]] name = "convert_case" version = "0.6.0" @@ -1963,6 +1973,7 @@ dependencies = [ name = "oxc_wasm" version = "0.0.0" dependencies = [ + "console_error_panic_hook", "oxc", "oxc_index", "oxc_linter", diff --git a/crates/oxc_wasm/Cargo.toml b/crates/oxc_wasm/Cargo.toml index ff1998272805a..785e45155fe2e 100644 --- a/crates/oxc_wasm/Cargo.toml +++ b/crates/oxc_wasm/Cargo.toml @@ -29,3 +29,4 @@ serde = { workspace = true } wasm-bindgen = { workspace = true } serde-wasm-bindgen = { workspace = true } tsify = { workspace = true } +console_error_panic_hook = "0.1.7" diff --git a/crates/oxc_wasm/src/lib.rs b/crates/oxc_wasm/src/lib.rs index 8c5fe796279b7..10d4efa16ab54 100644 --- a/crates/oxc_wasm/src/lib.rs +++ b/crates/oxc_wasm/src/lib.rs @@ -135,6 +135,8 @@ impl Oxc { source_text: &str, options: OxcOptions, ) -> Result<(), serde_wasm_bindgen::Error> { + console_error_panic_hook::set_once(); + self.diagnostics = RefCell::default(); let OxcOptions {