1 unstable release

Uses new Rust 2024

new 0.0.0 Apr 17, 2025

#34 in #rsx

Download history 100/week @ 2025-04-12

100 downloads per month

MPL-2.0 license

27KB
642 lines

RJS to JS

fn main() -> Result<()> {
    let here = Path::new(env!("CARGO_MANIFEST_DIR"));

    let js = RustCompiler::compile_file(
        &here.join("input.rs").canonicalize().unwrap(),
        &here.join("output.ts.map").canonicalize().unwrap(),
    )?;
    let mut generator = TsGenerator::new();

    let (generated_code, source_map) = generator.generate(&js)?;

    println!("\n--- Generated Code ---");
    println!("{}", generated_code);
    let mut js_output = File::create("tests/struct/output.ts")?;
    js_output.write_all(generated_code.as_bytes())?;

    println!("\n--- Source Map ---");
    let sm_json = source_map.to_json_string();
    println!("{}", sm_json);

    let mut sm_output = File::create("tests/struct/output.ts.map")?;
    sm_output.write_all(sm_json.as_bytes())?;
    Ok(())
}

Dependencies

~3.5–5MB
~90K SLoC