mirror of
https://github.com/swc-project/swc.git
synced 2024-12-04 19:46:22 +03:00
0ac55ae68b
testing: - Remove dependency on relative_path swc_common: - Span's byte positions are now self-contained and `GLOBALS` is not required while parsing. - Changed `Comments` into a trait. - Provide single-threaded implementation of `Comments` - Cargo feature `tty-emiiter` (To remove tty related stuffs ) - Cargo feature `sourcemap` (To remove sourcemap for web assets) - Removed dependency on dashmap swc_ecma_parser: - No duplicated comments. - Removed dependency on once_cell and regex - Add a test suite to visualize and test span of nodes. swc_ecma_utils: - Removed dependency on parser swc: - Remove dependency on derive_more and path-clean - Add multi-threaded implementation of `Comments` swc_ecmascript: - A new crate contains `ast`, `codegen`, `parser`, `utils`, `visit`.
30 lines
643 B
Rust
30 lines
643 B
Rust
use std::{path::Path, sync::Arc};
|
|
use swc::{self, config::Options};
|
|
use swc_common::{
|
|
errors::{ColorConfig, Handler},
|
|
SourceMap,
|
|
};
|
|
|
|
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");
|
|
}
|