This commit is contained in:
Michael Zhang 2023-05-18 15:25:23 -05:00
parent b5760b09a5
commit a652e3e43a
4 changed files with 18 additions and 7 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/target
.direnv
node_modules

1
src/html.rs Normal file
View file

@ -0,0 +1 @@

1
src/index.rs Normal file
View file

@ -0,0 +1 @@

View file

@ -1,3 +1,5 @@
pub mod html;
pub mod index;
pub mod progress_bar;
pub mod walkdir;
@ -14,7 +16,7 @@ use indicatif::{ProgressBar, ProgressStyle};
use swc_common::errors::ColorConfig;
use swc_common::{errors::Handler, sync::Lrc};
use swc_common::{FileName, SourceMap};
use swc_ecma_ast::ModuleDecl;
use swc_ecma_ast::{Decl, FnDecl, ModuleDecl};
use swc_ecma_parser::TsConfig;
use swc_ecma_parser::{
lexer::Lexer as EcmaLexer, Parser as EcmaParser, StringInput, Syntax,
@ -168,22 +170,28 @@ async fn handle_data(
})
.expect("failed to parser module");
tx.send(BarAction::Print(format!("Parsed module. {}", path_display)))?;
for item in module.body.iter() {
tx.send(BarAction::Print(format!("SHIET {item:?}")))?;
let decl = match item.as_module_decl() {
Some(v) => v,
None => continue,
};
match decl {
ModuleDecl::ExportDecl(decl) => {
tx.send(BarAction::Print(format!("SHIET {decl:?}")))?;
}
ModuleDecl::ExportDecl(decl) => match &decl.decl {
Decl::Fn(fn_decl) => {
let name = fn_decl.ident.to_string();
tx.send(BarAction::Print(format!("SHIET {name}")))?;
}
_ => {}
},
_ => {}
}
}
tx.send(BarAction::Print(format!(
"Processed module {}.",
path_display
)))?;
Ok(())
}