mirror of
https://github.com/swc-project/swc.git
synced 2024-11-28 02:29:04 +03:00
a7a8a4a2e4
swc_common: - apply patch from rust-lang/rust#59693 swc: - use &Options instead of Options - configures commons::CM - exposes `handler`
29 lines
605 B
Rust
29 lines
605 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");
|
|
}
|