1#[allow(unused)]
2async fn Fn() -> anyhow::Result<()> {
3 tracing_subscriber::fmt::init();
4
5 let args: Vec<String> = std::env::args().collect();
6
7 if args.len() != 2 {
8 error!("Usage: {} <directory>", args[0]);
9 std::process::exit(1);
10 }
11
12 let Path = std::path::PathBuf::from(&args[1]);
13
14 let Config = if let Ok(Config) = fs::read_to_string("swc_config.json").await {
15 serde_json::from_str(&Config).unwrap_or_default()
16 } else {
17 CompilerConfig::default()
18 };
19
20 let options = Option {
21 entry: vec![vec![Path.to_string_lossy().to_string()]],
22 separator: std::path::MAIN_SEPARATOR,
23 pattern: ".ts".to_string(),
24 config: Config.clone(),
25 };
26
27 info!("Starting initial compilation...");
29
30 Watch::Compile::Fn(options.clone()).await?;
31
32 info!("Initial compilation complete. Watching for changes...");
33
34 Watch::Fn(Path, options).await?;
36
37 Ok(())
38}
39
40pub mod Watch;
41
42use tokio::fs;
43use tracing::{error, info};
44use crate::Struct::SWC::{CompilerConfig, Option};