forked from swc-project/swc
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlib.rs
More file actions
31 lines (24 loc) · 688 Bytes
/
lib.rs
File metadata and controls
31 lines (24 loc) · 688 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#![recursion_limit = "2048"]
#![allow(dead_code)]
#[macro_use]
extern crate napi_derive;
extern crate swc_malloc;
use std::{env, panic::set_hook};
use backtrace::Backtrace;
mod support;
#[napi_derive::module_init]
fn init() {
if cfg!(debug_assertions) || env::var("SWC_DEBUG").unwrap_or_default() == "1" {
set_hook(Box::new(|panic_info| {
let backtrace = Backtrace::new();
println!("Panic: {panic_info:?}\nBacktrace: {backtrace:?}");
}));
}
}
/// Output returned by the native React Compiler binding.
#[napi(object)]
pub struct TransformOutput {
pub code: String,
pub map: Option<String>,
pub diagnostics: Vec<String>,
}