swc/examples/usage.rs
Jasper De Sutter 716bfe05b2 Cleanup (#448)
- cargo fix
- update all crates to 2018 edition
2019-11-17 13:21:53 +09:00

29 lines
604 B
Rust

use swc;
use std::{path::Path, sync::Arc};
use swc::{
common::{
errors::{ColorConfig, Handler},
SourceMap,
},
config::Options,
};
fn main() {
let cm = Arc::<SourceMap>::default();
let handler = Handler::with_tty_emitter(ColorConfig::Auto, true, false, Some(cm.clone()));
let c = swc::Compiler::new(cm.clone(), handler);
let fm = cm
.load_file(Path::new("foo.js"))
.expect("failed to load file");
c.process_js_file(
fm,
Options {
..Default::default()
},
)
.expect("failed to process file");
}