2019-10-25 04:11:24 +03:00
|
|
|
use std::{path::Path, sync::Arc};
|
2020-07-31 12:49:07 +03:00
|
|
|
use swc::{self, config::Options};
|
|
|
|
use swc_common::{
|
|
|
|
errors::{ColorConfig, Handler},
|
|
|
|
SourceMap,
|
2019-10-25 04:11:24 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let cm = Arc::<SourceMap>::default();
|
2020-06-13 17:09:45 +03:00
|
|
|
let handler = Arc::new(Handler::with_tty_emitter(
|
|
|
|
ColorConfig::Auto,
|
|
|
|
true,
|
|
|
|
false,
|
|
|
|
Some(cm.clone()),
|
|
|
|
));
|
|
|
|
let c = swc::Compiler::new(cm.clone(), handler.clone());
|
2019-10-25 04:11:24 +03:00
|
|
|
|
|
|
|
let fm = cm
|
|
|
|
.load_file(Path::new("foo.js"))
|
|
|
|
.expect("failed to load file");
|
|
|
|
|
|
|
|
c.process_js_file(
|
|
|
|
fm,
|
2019-11-29 17:46:06 +03:00
|
|
|
&Options {
|
2019-10-25 04:11:24 +03:00
|
|
|
..Default::default()
|
|
|
|
},
|
2019-11-17 07:21:53 +03:00
|
|
|
)
|
|
|
|
.expect("failed to process file");
|
2019-10-25 04:11:24 +03:00
|
|
|
}
|