fix rewriter

This commit is contained in:
velzie 2024-07-15 08:12:45 -04:00
parent f53bc623ff
commit 3462785c39
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
3 changed files with 89 additions and 8 deletions

31
rewriter/src/main.rs Normal file
View file

@ -0,0 +1,31 @@
#![allow(clippy::print_stdout)]
use std::{env, path::Path};
use oxc_allocator::Allocator;
use oxc_ast::{
ast::{AssignmentTarget, Class, Function, IdentifierReference, MemberExpression, TSImportType},
visit::walk,
Visit,
};
use oxc_parser::Parser;
use oxc_span::{SourceType, Span};
use oxc_syntax::scope::ScopeFlags;
pub mod rewrite;
use rewrite::rewrite;
// Instruction:
// create a `test.js`,
// run `cargo run -p oxc_parser --example visitor`
// or `cargo watch -x "run -p oxc_parser --example visitor"`
fn main() -> std::io::Result<()> {
let name = env::args().nth(1).unwrap_or_else(|| "test.js".to_string());
let path = Path::new(&name);
let source_text = std::fs::read_to_string(path)?;
println!("{}", rewrite(&source_text));
Ok(())
}