mirror of
https://github.com/swc-project/swc.git
synced 2024-12-04 19:46:22 +03:00
ae3326cd9d
- Expose high-level compiler apis (#431) - Support multiple entries in .swcrc (#414)
28 lines
575 B
Rust
28 lines
575 B
Rust
extern crate 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()
|
|
},
|
|
);
|
|
}
|