-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
114 changed files
with
365 additions
and
363 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
# builds | ||
dist/ | ||
build/ | ||
publish/ | ||
temp/ | ||
target/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
use clap::Parser; | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct BuildCommand {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
use super::BuildCommand; | ||
|
||
pub fn main(command: BuildCommand) { | ||
println!("running build"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod main; | ||
mod config; | ||
|
||
pub use crate::cmd::build::main::*; | ||
pub use crate::cmd::build::config::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
use clap::Parser; | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct DevCommand {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use super::DevCommand; | ||
|
||
pub fn main(_command: DevCommand) { | ||
println!("Not implemented yet"); | ||
println!("Coming Soon"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod main; | ||
mod config; | ||
|
||
pub use crate::cmd::dev::main::*; | ||
pub use crate::cmd::dev::config::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub mod version; | ||
pub mod build; | ||
pub mod watch; | ||
pub mod dev; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
use clap::Parser; | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct VersionCommand {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use std::fs; | ||
|
||
use super::VersionCommand; | ||
|
||
#[allow(non_upper_case_globals)] | ||
const color_red: &str = "\x1B[31m"; | ||
#[allow(non_upper_case_globals)] | ||
const color_reset: &str = "\x1B[39m"; | ||
#[allow(non_upper_case_globals)] | ||
const style_bold: &str = "\x1B[1m"; | ||
#[allow(non_upper_case_globals)] | ||
const style_reset: &str = "\x1B[0m"; | ||
|
||
const DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); | ||
const VERSION: &str = env!("CARGO_PKG_VERSION"); | ||
const REPOSITORY: &str = env!("CARGO_PKG_REPOSITORY"); | ||
|
||
pub fn main(_command: VersionCommand) { | ||
print!(r#"{color_red}{style_bold}"#); | ||
println!(r#"___ ___ _ "#); | ||
println!(r#"| \/ | | | "#); | ||
println!(r#"| . . | __ _ ___| |__ "#); | ||
println!(r#"| |\/| |/ _` |/ __| '_ \ "#); | ||
println!(r#"| | | | (_| | (__| | | |"#); | ||
println!(r#"\_| |_/\__,_|\___|_| |_|"#); | ||
print!(r#"{color_reset}{style_reset}"#); | ||
println!(r#""#); | ||
println!(r#"{style_bold}Description{style_reset} {DESCRIPTION}"#); | ||
println!(r#"{style_bold}Repository{style_reset} {REPOSITORY}"#); | ||
println!(r#"{style_bold}Version{style_reset} {VERSION}"#); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod main; | ||
mod config; | ||
|
||
pub use crate::cmd::version::main::*; | ||
pub use crate::cmd::version::config::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
use clap::Parser; | ||
|
||
#[derive(Parser, Debug)] | ||
pub struct WatchCommand {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
use super::WatchCommand; | ||
|
||
pub fn main(_command: WatchCommand) { | ||
println!("Not implemented yet"); | ||
println!("Coming Soon"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mod main; | ||
mod config; | ||
|
||
pub use crate::cmd::watch::main::*; | ||
pub use crate::cmd::watch::config::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub mod hash; | ||
|
||
pub use crate::kit::hash::hash::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod hash; | ||
pub mod swc; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#![allow(dead_code)] | ||
#![allow(unused_imports)] | ||
|
||
mod convert; | ||
mod lookup_property_access; | ||
mod parse_module; | ||
mod parse_program; | ||
mod parse_script; | ||
mod render_module; | ||
mod render_program; | ||
mod render_script; | ||
mod render_stmts; | ||
|
||
pub use crate::kit::swc::convert::*; | ||
pub use crate::kit::swc::lookup_property_access::*; | ||
pub use crate::kit::swc::parse_module::*; | ||
pub use crate::kit::swc::parse_program::*; | ||
pub use crate::kit::swc::parse_script::*; | ||
pub use crate::kit::swc::render_module::*; | ||
pub use crate::kit::swc::render_program::*; | ||
pub use crate::kit::swc::render_script::*; | ||
pub use crate::kit::swc::render_stmts::*; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,136 +1,41 @@ | ||
mod adapters; | ||
mod args; | ||
mod bundling; | ||
mod config; | ||
mod emit; | ||
mod packaging; | ||
mod platform; | ||
mod plugins; | ||
mod public; | ||
mod transformation; | ||
|
||
use std::sync::Arc; | ||
|
||
use crate::adapters::node_js::NodeAdapter; | ||
use crate::bundling::bundle; | ||
use crate::config::parse_config; | ||
use crate::emit::emit; | ||
use crate::packaging::package; | ||
use crate::plugins::load_plugins; | ||
use crate::public::AssetGraph; | ||
use crate::public::AssetMap; | ||
use crate::public::BundleGraph; | ||
use crate::public::Bundles; | ||
use crate::public::Config; | ||
use crate::public::DependencyMap; | ||
use crate::public::Packages; | ||
use crate::transformation::transform; | ||
|
||
async fn main_async(config: Config) { | ||
// Bundle state | ||
let mut asset_map = AssetMap::new(); | ||
let mut dependency_map = DependencyMap::new(); | ||
let mut asset_graph = AssetGraph::new(); | ||
let mut bundles = Bundles::new(); | ||
let mut bundle_graph = BundleGraph::new(); | ||
let mut packages = Packages::new(); | ||
|
||
// Adapters | ||
let node_adapter = Arc::new(NodeAdapter::new(config.node_workers).await); | ||
|
||
// TODO move this into a "reporter" plugin | ||
println!("Entry: {}", config.entry_point.to_str().unwrap()); | ||
println!("Root: {}", config.project_root.to_str().unwrap()); | ||
if !&config.machrc.is_default { | ||
println!( | ||
"Mach Config: {}", | ||
config.machrc.file_path.to_str().unwrap() | ||
); | ||
} else { | ||
println!("Mach Config: Default"); | ||
} | ||
println!("Out Dir: {}", config.dist_dir.to_str().unwrap()); | ||
println!("Optimize: {}", config.optimize); | ||
println!("Threads: {}", config.threads); | ||
println!("Node Workers: {}", config.node_workers); | ||
|
||
// Initialize plugins | ||
let Ok(plugins) = load_plugins(&config.machrc, node_adapter.clone()).await else { | ||
panic!("Unable to initialize plugins"); | ||
}; | ||
|
||
// This phase reads source files and transforms them. New imports | ||
// are discovered as files are parsed, looping until no more imports exist | ||
if let Err(err) = transform( | ||
&config, | ||
&mut asset_map, | ||
&mut dependency_map, | ||
&mut asset_graph, | ||
&plugins, | ||
) | ||
.await | ||
{ | ||
println!("Transformation Error"); | ||
println!("{}", err); | ||
return; | ||
} | ||
|
||
println!("Assets: {}", asset_map.len()); | ||
|
||
// dbg!(&asset_map); | ||
// dbg!(&asset_graph); | ||
// dbg!(&dependency_map); | ||
|
||
if let Err(err) = bundle( | ||
&config, | ||
&mut asset_map, | ||
&mut dependency_map, | ||
&mut asset_graph, | ||
&mut bundles, | ||
&mut bundle_graph, | ||
) { | ||
println!("Bundling Error"); | ||
println!("{}", err); | ||
return; | ||
} | ||
|
||
// dbg!(&bundles); | ||
// dbg!(&bundle_graph); | ||
|
||
if let Err(err) = package( | ||
&config, | ||
&mut asset_map, | ||
&mut dependency_map, | ||
&mut asset_graph, | ||
&mut bundles, | ||
&mut bundle_graph, | ||
&mut packages, | ||
) { | ||
println!("Packaging Error"); | ||
println!("{}", err); | ||
return; | ||
} | ||
|
||
// dbg!(&packages); | ||
|
||
if let Err(err) = emit(&config, &mut bundles, &mut packages) { | ||
println!("Packaging Error"); | ||
println!("{}", err); | ||
return; | ||
} | ||
mod cmd; | ||
|
||
use clap::Subcommand; | ||
use clap::Parser; | ||
use cmd::build::BuildCommand; | ||
use cmd::dev::DevCommand; | ||
use cmd::watch::WatchCommand; | ||
use cmd::version::VersionCommand; | ||
|
||
#[derive(Debug, Subcommand)] | ||
pub enum CommandType { | ||
Build(BuildCommand), | ||
Dev(DevCommand), | ||
Watch(WatchCommand), | ||
Version(VersionCommand), | ||
} | ||
|
||
println!( | ||
"Finished in: {:.3}s", | ||
config.start_time.elapsed().unwrap().as_nanos() as f64 / 1_000_000 as f64 / 1000 as f64 | ||
); | ||
#[derive(Parser, Debug)] | ||
struct Commands { | ||
#[clap(subcommand)] | ||
command: CommandType | ||
} | ||
|
||
fn main() { | ||
let config = parse_config().expect("Could not parse CLI args"); | ||
tokio::runtime::Builder::new_multi_thread() | ||
.worker_threads(config.threads) | ||
.enable_all() | ||
.build() | ||
.unwrap() | ||
.block_on(main_async(config)); | ||
} | ||
let command = Commands::parse(); | ||
|
||
match command.command { | ||
CommandType::Build(command) => { | ||
cmd::build::main(command); | ||
}, | ||
CommandType::Dev(command) => { | ||
cmd::dev::main(command); | ||
}, | ||
CommandType::Watch(command) => { | ||
cmd::watch::main(command); | ||
}, | ||
CommandType::Version(command) => { | ||
cmd::version::main(command); | ||
}, | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
mod node_adapter; | ||
mod node_worker; | ||
pub mod requests; | ||
mod resolve; | ||
mod spawn; | ||
|
||
pub use crate::platform::adapters::node_js::node_adapter::*; | ||
pub use crate::platform::adapters::node_js::node_worker::*; | ||
pub use crate::platform::adapters::node_js::resolve::*; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
Oops, something went wrong.