mirror of
https://github.com/swc-project/swc.git
synced 2024-12-18 11:11:30 +03:00
fcef201695
Version is alpha as it's not complete
33 lines
662 B
Rust
33 lines
662 B
Rust
use std::{path::Path, sync::Arc};
|
|
use swc::{
|
|
self,
|
|
common::{
|
|
errors::{ColorConfig, Handler},
|
|
SourceMap,
|
|
},
|
|
config::Options,
|
|
};
|
|
|
|
fn main() {
|
|
let cm = Arc::<SourceMap>::default();
|
|
let handler = Arc::new(Handler::with_tty_emitter(
|
|
ColorConfig::Auto,
|
|
true,
|
|
false,
|
|
Some(cm.clone()),
|
|
));
|
|
let c = swc::Compiler::new(cm.clone(), handler.clone());
|
|
|
|
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");
|
|
}
|