From 07e5356b4e73b80136553c2d7241ae5dcb0a133d Mon Sep 17 00:00:00 2001 From: David Alsh Date: Sat, 2 Mar 2024 12:34:58 +1100 Subject: [PATCH] added CLI commands --- .github/scripts/cmd/run.mjs | 7 +- .gitignore | 1 - crates/mach/Cargo.toml | 4 +- crates/mach/src/adapters/node_js/mod.rs | 9 - crates/mach/src/bundling/mod.rs | 3 - crates/mach/src/cmd/build/config.rs | 4 + crates/mach/src/cmd/build/main.rs | 5 + crates/mach/src/cmd/build/mod.rs | 5 + crates/mach/src/cmd/dev/config.rs | 4 + crates/mach/src/cmd/dev/main.rs | 6 + crates/mach/src/cmd/dev/mod.rs | 5 + crates/mach/src/cmd/mod.rs | 4 + crates/mach/src/cmd/version/config.rs | 4 + crates/mach/src/cmd/version/main.rs | 31 ++++ crates/mach/src/cmd/version/mod.rs | 5 + crates/mach/src/cmd/watch/config.rs | 4 + crates/mach/src/cmd/watch/main.rs | 6 + crates/mach/src/cmd/watch/mod.rs | 5 + crates/mach/src/config.rs | 4 +- .../mach/src/{platform => kit}/hash/hash.rs | 0 crates/mach/src/kit/hash/mod.rs | 3 + crates/mach/src/kit/mod.rs | 2 + .../mach/src/{platform => kit}/swc/convert.rs | 0 .../swc/lookup_property_access.rs | 0 crates/mach/src/kit/swc/mod.rs | 22 +++ .../src/{platform => kit}/swc/parse_module.rs | 0 .../{platform => kit}/swc/parse_program.rs | 0 .../src/{platform => kit}/swc/parse_script.rs | 0 .../{platform => kit}/swc/render_module.rs | 0 .../{platform => kit}/swc/render_program.rs | 0 .../{platform => kit}/swc/render_script.rs | 0 .../src/{platform => kit}/swc/render_stmts.rs | 0 crates/mach/src/main.rs | 169 ++++-------------- .../mach/src/{ => platform}/adapters/mod.rs | 0 .../adapters/node_js/js/jsconfig.json | 0 .../adapters/node_js/js/main.js | 0 .../adapters/node_js/js/package.json | 0 .../adapters/node_js/js/worker.js | 0 .../mach/src/platform/adapters/node_js/mod.rs | 9 + .../adapters/node_js/node_adapter.rs | 0 .../adapters/node_js/node_worker.rs | 0 .../adapters/node_js/requests.rs | 6 +- .../adapters/node_js/resolve.rs | 0 .../{ => platform}/adapters/node_js/spawn.rs | 0 .../src/{ => platform}/bundling/bundle.rs | 18 +- crates/mach/src/platform/bundling/mod.rs | 3 + crates/mach/src/{ => platform}/emit/mod.rs | 8 +- crates/mach/src/platform/hash/mod.rs | 3 - crates/mach/src/platform/mod.rs | 9 +- .../packaging/js_runtime/default_decl.rs | 0 .../packaging/js_runtime/js_runtime.rs | 16 +- .../packaging/js_runtime/mod.rs | 0 .../packaging/js_runtime/read_exports.rs | 0 .../js_runtime/read_exports_named.rs | 2 +- .../js_runtime/read_import_assignments.rs | 2 +- .../mach/src/{ => platform}/packaging/mod.rs | 2 +- .../src/{ => platform}/packaging/package.rs | 20 +-- .../runtime_factory/js/define_export.js | 0 .../js/import_script_classic.js | 0 .../runtime_factory/js/import_script_esm.js | 0 .../runtime_factory/js/mach_require.js | 0 .../packaging/runtime_factory/js/manifest.js | 0 .../packaging/runtime_factory/js/module.js | 0 .../packaging/runtime_factory/js/prelude.js | 0 .../runtime_factory/js/prelude_require.js | 0 .../packaging/runtime_factory/js/wrapper.js | 0 .../packaging/runtime_factory/mod.rs | 2 +- .../packaging/runtime_factory/scratch.rs | 0 .../src/{ => platform}/plugins/builtin/mod.rs | 0 .../platform/plugins/builtin/resolver/mod.rs | 5 + .../plugins/builtin/resolver/resolve.rs | 0 .../plugins/builtin/resolver/resolver.rs | 6 +- .../plugins/builtin/resolver_node_js/mod.rs | 3 + .../builtin/resolver_node_js/resolver.rs | 14 +- .../plugins/builtin/transformer_css/mod.rs | 3 + .../builtin/transformer_css/transformer.rs | 6 +- .../builtin/transformer_javascript/mod.rs | 7 + .../node_env_replacer.rs | 0 .../transformer_javascript/read_imports.rs | 6 +- .../transformer_javascript/transformer.rs | 14 +- .../builtin/transformer_node_js/mod.rs | 3 + .../transformer_node_js/transformer.rs | 14 +- .../plugins/builtin/transformer_noop/mod.rs | 3 + .../builtin/transformer_noop/transformer.rs | 28 +++ .../{ => platform}/plugins/load_plugins.rs | 8 +- crates/mach/src/platform/plugins/mod.rs | 6 + .../plugins/plugin_container.rs | 4 +- .../mach/src/{ => platform}/public/asset.rs | 0 .../src/{ => platform}/public/asset_graph.rs | 0 .../src/{ => platform}/public/asset_store.rs | 0 .../mach/src/{ => platform}/public/bundle.rs | 4 +- .../mach/src/{ => platform}/public/config.rs | 0 .../src/{ => platform}/public/constants.rs | 0 .../src/{ => platform}/public/dependency.rs | 0 .../{ => platform}/public/dependency_graph.rs | 4 +- .../mach/src/{ => platform}/public/machrc.rs | 0 crates/mach/src/platform/public/mod.rs | 25 +++ .../src/{ => platform}/public/packages.rs | 0 .../src/{ => platform}/public/resolver.rs | 2 +- .../src/{ => platform}/public/transformer.rs | 4 +- crates/mach/src/platform/swc/mod.rs | 22 --- .../mach/src/platform/transformation/mod.rs | 3 + .../transformation/transform.rs | 22 +-- .../mach/src/plugins/builtin/resolver/mod.rs | 5 - .../plugins/builtin/resolver_node_js/mod.rs | 3 - .../plugins/builtin/transformer_css/mod.rs | 3 - .../builtin/transformer_javascript/mod.rs | 7 - .../builtin/transformer_node_js/mod.rs | 3 - .../plugins/builtin/transformer_noop/mod.rs | 3 - .../builtin/transformer_noop/transformer.rs | 28 --- crates/mach/src/plugins/mod.rs | 6 - crates/mach/src/public/mod.rs | 25 --- crates/mach/src/transformation/mod.rs | 3 - pnpm-lock.yaml | 14 +- 114 files changed, 365 insertions(+), 363 deletions(-) delete mode 100644 crates/mach/src/adapters/node_js/mod.rs delete mode 100644 crates/mach/src/bundling/mod.rs create mode 100644 crates/mach/src/cmd/build/config.rs create mode 100644 crates/mach/src/cmd/build/main.rs create mode 100644 crates/mach/src/cmd/build/mod.rs create mode 100644 crates/mach/src/cmd/dev/config.rs create mode 100644 crates/mach/src/cmd/dev/main.rs create mode 100644 crates/mach/src/cmd/dev/mod.rs create mode 100644 crates/mach/src/cmd/mod.rs create mode 100644 crates/mach/src/cmd/version/config.rs create mode 100644 crates/mach/src/cmd/version/main.rs create mode 100644 crates/mach/src/cmd/version/mod.rs create mode 100644 crates/mach/src/cmd/watch/config.rs create mode 100644 crates/mach/src/cmd/watch/main.rs create mode 100644 crates/mach/src/cmd/watch/mod.rs rename crates/mach/src/{platform => kit}/hash/hash.rs (100%) create mode 100644 crates/mach/src/kit/hash/mod.rs create mode 100644 crates/mach/src/kit/mod.rs rename crates/mach/src/{platform => kit}/swc/convert.rs (100%) rename crates/mach/src/{platform => kit}/swc/lookup_property_access.rs (100%) create mode 100644 crates/mach/src/kit/swc/mod.rs rename crates/mach/src/{platform => kit}/swc/parse_module.rs (100%) rename crates/mach/src/{platform => kit}/swc/parse_program.rs (100%) rename crates/mach/src/{platform => kit}/swc/parse_script.rs (100%) rename crates/mach/src/{platform => kit}/swc/render_module.rs (100%) rename crates/mach/src/{platform => kit}/swc/render_program.rs (100%) rename crates/mach/src/{platform => kit}/swc/render_script.rs (100%) rename crates/mach/src/{platform => kit}/swc/render_stmts.rs (100%) rename crates/mach/src/{ => platform}/adapters/mod.rs (100%) rename crates/mach/src/{ => platform}/adapters/node_js/js/jsconfig.json (100%) rename crates/mach/src/{ => platform}/adapters/node_js/js/main.js (100%) rename crates/mach/src/{ => platform}/adapters/node_js/js/package.json (100%) rename crates/mach/src/{ => platform}/adapters/node_js/js/worker.js (100%) create mode 100644 crates/mach/src/platform/adapters/node_js/mod.rs rename crates/mach/src/{ => platform}/adapters/node_js/node_adapter.rs (100%) rename crates/mach/src/{ => platform}/adapters/node_js/node_worker.rs (100%) rename crates/mach/src/{ => platform}/adapters/node_js/requests.rs (85%) rename crates/mach/src/{ => platform}/adapters/node_js/resolve.rs (100%) rename crates/mach/src/{ => platform}/adapters/node_js/spawn.rs (100%) rename crates/mach/src/{ => platform}/bundling/bundle.rs (92%) create mode 100644 crates/mach/src/platform/bundling/mod.rs rename crates/mach/src/{ => platform}/emit/mod.rs (81%) delete mode 100644 crates/mach/src/platform/hash/mod.rs rename crates/mach/src/{ => platform}/packaging/js_runtime/default_decl.rs (100%) rename crates/mach/src/{ => platform}/packaging/js_runtime/js_runtime.rs (97%) rename crates/mach/src/{ => platform}/packaging/js_runtime/mod.rs (100%) rename crates/mach/src/{ => platform}/packaging/js_runtime/read_exports.rs (100%) rename crates/mach/src/{ => platform}/packaging/js_runtime/read_exports_named.rs (97%) rename crates/mach/src/{ => platform}/packaging/js_runtime/read_import_assignments.rs (97%) rename crates/mach/src/{ => platform}/packaging/mod.rs (53%) rename crates/mach/src/{ => platform}/packaging/package.rs (91%) rename crates/mach/src/{ => platform}/packaging/runtime_factory/js/define_export.js (100%) rename crates/mach/src/{ => platform}/packaging/runtime_factory/js/import_script_classic.js (100%) rename crates/mach/src/{ => platform}/packaging/runtime_factory/js/import_script_esm.js (100%) rename crates/mach/src/{ => platform}/packaging/runtime_factory/js/mach_require.js (100%) rename crates/mach/src/{ => platform}/packaging/runtime_factory/js/manifest.js (100%) rename crates/mach/src/{ => platform}/packaging/runtime_factory/js/module.js (100%) rename crates/mach/src/{ => platform}/packaging/runtime_factory/js/prelude.js (100%) rename crates/mach/src/{ => platform}/packaging/runtime_factory/js/prelude_require.js (100%) rename crates/mach/src/{ => platform}/packaging/runtime_factory/js/wrapper.js (100%) rename crates/mach/src/{ => platform}/packaging/runtime_factory/mod.rs (99%) rename crates/mach/src/{ => platform}/packaging/runtime_factory/scratch.rs (100%) rename crates/mach/src/{ => platform}/plugins/builtin/mod.rs (100%) create mode 100644 crates/mach/src/platform/plugins/builtin/resolver/mod.rs rename crates/mach/src/{ => platform}/plugins/builtin/resolver/resolve.rs (100%) rename crates/mach/src/{ => platform}/plugins/builtin/resolver/resolver.rs (79%) create mode 100644 crates/mach/src/platform/plugins/builtin/resolver_node_js/mod.rs rename crates/mach/src/{ => platform}/plugins/builtin/resolver_node_js/resolver.rs (77%) create mode 100644 crates/mach/src/platform/plugins/builtin/transformer_css/mod.rs rename crates/mach/src/{ => platform}/plugins/builtin/transformer_css/transformer.rs (70%) create mode 100644 crates/mach/src/platform/plugins/builtin/transformer_javascript/mod.rs rename crates/mach/src/{ => platform}/plugins/builtin/transformer_javascript/node_env_replacer.rs (100%) rename crates/mach/src/{ => platform}/plugins/builtin/transformer_javascript/read_imports.rs (98%) rename crates/mach/src/{ => platform}/plugins/builtin/transformer_javascript/transformer.rs (91%) create mode 100644 crates/mach/src/platform/plugins/builtin/transformer_node_js/mod.rs rename crates/mach/src/{ => platform}/plugins/builtin/transformer_node_js/transformer.rs (80%) create mode 100644 crates/mach/src/platform/plugins/builtin/transformer_noop/mod.rs create mode 100644 crates/mach/src/platform/plugins/builtin/transformer_noop/transformer.rs rename crates/mach/src/{ => platform}/plugins/load_plugins.rs (94%) create mode 100644 crates/mach/src/platform/plugins/mod.rs rename crates/mach/src/{ => platform}/plugins/plugin_container.rs (96%) rename crates/mach/src/{ => platform}/public/asset.rs (100%) rename crates/mach/src/{ => platform}/public/asset_graph.rs (100%) rename crates/mach/src/{ => platform}/public/asset_store.rs (100%) rename crates/mach/src/{ => platform}/public/bundle.rs (95%) rename crates/mach/src/{ => platform}/public/config.rs (100%) rename crates/mach/src/{ => platform}/public/constants.rs (100%) rename crates/mach/src/{ => platform}/public/dependency.rs (100%) rename crates/mach/src/{ => platform}/public/dependency_graph.rs (96%) rename crates/mach/src/{ => platform}/public/machrc.rs (100%) create mode 100644 crates/mach/src/platform/public/mod.rs rename crates/mach/src/{ => platform}/public/packages.rs (100%) rename crates/mach/src/{ => platform}/public/resolver.rs (89%) rename crates/mach/src/{ => platform}/public/transformer.rs (94%) delete mode 100644 crates/mach/src/platform/swc/mod.rs create mode 100644 crates/mach/src/platform/transformation/mod.rs rename crates/mach/src/{ => platform}/transformation/transform.rs (88%) delete mode 100644 crates/mach/src/plugins/builtin/resolver/mod.rs delete mode 100644 crates/mach/src/plugins/builtin/resolver_node_js/mod.rs delete mode 100644 crates/mach/src/plugins/builtin/transformer_css/mod.rs delete mode 100644 crates/mach/src/plugins/builtin/transformer_javascript/mod.rs delete mode 100644 crates/mach/src/plugins/builtin/transformer_node_js/mod.rs delete mode 100644 crates/mach/src/plugins/builtin/transformer_noop/mod.rs delete mode 100644 crates/mach/src/plugins/builtin/transformer_noop/transformer.rs delete mode 100644 crates/mach/src/plugins/mod.rs delete mode 100644 crates/mach/src/public/mod.rs delete mode 100644 crates/mach/src/transformation/mod.rs diff --git a/.github/scripts/cmd/run.mjs b/.github/scripts/cmd/run.mjs index bedd0a06..2202cd9b 100644 --- a/.github/scripts/cmd/run.mjs +++ b/.github/scripts/cmd/run.mjs @@ -9,11 +9,12 @@ export function main(args) { const FIXTURE_DIR = path.join(Paths.Fixtures, FIXTURE) const [CARGO_ARGS] = args._raw.replace(FIXTURE, '').split(' -- ') - const [,MACH_ARGS] = process.argv.join(' ').split(' -- ') + const [,MACH_ARGS = ''] = process.argv.join(' ').split(' -- ') const { binary_path } = build(parse(CARGO_ARGS.split(' '))) try { - child_process.execSync(`${binary_path} ${MACH_ARGS}`, { cwd: FIXTURE_DIR, stdio: 'inherit' }) - } catch (error) {} + child_process.execSync(`${binary_path} ${MACH_ARGS || ''}`, { cwd: FIXTURE_DIR, stdio: 'inherit' }) + } catch (error) { + } } \ No newline at end of file diff --git a/.gitignore b/.gitignore index 89f25bc2..1d6a35f7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ # builds dist/ -build/ publish/ temp/ target/ diff --git a/crates/mach/Cargo.toml b/crates/mach/Cargo.toml index fb5a2c10..3ecb08e1 100644 --- a/crates/mach/Cargo.toml +++ b/crates/mach/Cargo.toml @@ -1,7 +1,9 @@ [package] name = "mach" version = "0.0.0-local" -description = "mustang" +repository = "https://github.com/alshdavid/mach" +bugreports = "test" +description = "Bundler For The Modern Web" edition = "2021" [dependencies] diff --git a/crates/mach/src/adapters/node_js/mod.rs b/crates/mach/src/adapters/node_js/mod.rs deleted file mode 100644 index 7febf4bc..00000000 --- a/crates/mach/src/adapters/node_js/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -mod node_adapter; -mod node_worker; -pub mod requests; -mod resolve; -mod spawn; - -pub use crate::adapters::node_js::node_adapter::*; -pub use crate::adapters::node_js::node_worker::*; -pub use crate::adapters::node_js::resolve::*; diff --git a/crates/mach/src/bundling/mod.rs b/crates/mach/src/bundling/mod.rs deleted file mode 100644 index bcd30807..00000000 --- a/crates/mach/src/bundling/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod bundle; - -pub use crate::bundling::bundle::*; diff --git a/crates/mach/src/cmd/build/config.rs b/crates/mach/src/cmd/build/config.rs new file mode 100644 index 00000000..84ffb7ca --- /dev/null +++ b/crates/mach/src/cmd/build/config.rs @@ -0,0 +1,4 @@ +use clap::Parser; + +#[derive(Parser, Debug)] +pub struct BuildCommand {} \ No newline at end of file diff --git a/crates/mach/src/cmd/build/main.rs b/crates/mach/src/cmd/build/main.rs new file mode 100644 index 00000000..647c10b5 --- /dev/null +++ b/crates/mach/src/cmd/build/main.rs @@ -0,0 +1,5 @@ +use super::BuildCommand; + +pub fn main(command: BuildCommand) { + println!("running build"); +} diff --git a/crates/mach/src/cmd/build/mod.rs b/crates/mach/src/cmd/build/mod.rs new file mode 100644 index 00000000..d2096659 --- /dev/null +++ b/crates/mach/src/cmd/build/mod.rs @@ -0,0 +1,5 @@ +mod main; +mod config; + +pub use crate::cmd::build::main::*; +pub use crate::cmd::build::config::*; diff --git a/crates/mach/src/cmd/dev/config.rs b/crates/mach/src/cmd/dev/config.rs new file mode 100644 index 00000000..b386d6ac --- /dev/null +++ b/crates/mach/src/cmd/dev/config.rs @@ -0,0 +1,4 @@ +use clap::Parser; + +#[derive(Parser, Debug)] +pub struct DevCommand {} \ No newline at end of file diff --git a/crates/mach/src/cmd/dev/main.rs b/crates/mach/src/cmd/dev/main.rs new file mode 100644 index 00000000..0a9a2abc --- /dev/null +++ b/crates/mach/src/cmd/dev/main.rs @@ -0,0 +1,6 @@ +use super::DevCommand; + +pub fn main(_command: DevCommand) { + println!("Not implemented yet"); + println!("Coming Soon"); +} diff --git a/crates/mach/src/cmd/dev/mod.rs b/crates/mach/src/cmd/dev/mod.rs new file mode 100644 index 00000000..7c292001 --- /dev/null +++ b/crates/mach/src/cmd/dev/mod.rs @@ -0,0 +1,5 @@ +mod main; +mod config; + +pub use crate::cmd::dev::main::*; +pub use crate::cmd::dev::config::*; diff --git a/crates/mach/src/cmd/mod.rs b/crates/mach/src/cmd/mod.rs new file mode 100644 index 00000000..1b8d18d0 --- /dev/null +++ b/crates/mach/src/cmd/mod.rs @@ -0,0 +1,4 @@ +pub mod version; +pub mod build; +pub mod watch; +pub mod dev; diff --git a/crates/mach/src/cmd/version/config.rs b/crates/mach/src/cmd/version/config.rs new file mode 100644 index 00000000..68f95a36 --- /dev/null +++ b/crates/mach/src/cmd/version/config.rs @@ -0,0 +1,4 @@ +use clap::Parser; + +#[derive(Parser, Debug)] +pub struct VersionCommand {} diff --git a/crates/mach/src/cmd/version/main.rs b/crates/mach/src/cmd/version/main.rs new file mode 100644 index 00000000..704980e7 --- /dev/null +++ b/crates/mach/src/cmd/version/main.rs @@ -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}"#); +} diff --git a/crates/mach/src/cmd/version/mod.rs b/crates/mach/src/cmd/version/mod.rs new file mode 100644 index 00000000..70b2ebac --- /dev/null +++ b/crates/mach/src/cmd/version/mod.rs @@ -0,0 +1,5 @@ +mod main; +mod config; + +pub use crate::cmd::version::main::*; +pub use crate::cmd::version::config::*; diff --git a/crates/mach/src/cmd/watch/config.rs b/crates/mach/src/cmd/watch/config.rs new file mode 100644 index 00000000..c80ec3c3 --- /dev/null +++ b/crates/mach/src/cmd/watch/config.rs @@ -0,0 +1,4 @@ +use clap::Parser; + +#[derive(Parser, Debug)] +pub struct WatchCommand {} diff --git a/crates/mach/src/cmd/watch/main.rs b/crates/mach/src/cmd/watch/main.rs new file mode 100644 index 00000000..92fe6417 --- /dev/null +++ b/crates/mach/src/cmd/watch/main.rs @@ -0,0 +1,6 @@ +use super::WatchCommand; + +pub fn main(_command: WatchCommand) { + println!("Not implemented yet"); + println!("Coming Soon"); +} diff --git a/crates/mach/src/cmd/watch/mod.rs b/crates/mach/src/cmd/watch/mod.rs new file mode 100644 index 00000000..499e559b --- /dev/null +++ b/crates/mach/src/cmd/watch/mod.rs @@ -0,0 +1,5 @@ +mod main; +mod config; + +pub use crate::cmd::watch::main::*; +pub use crate::cmd::watch::config::*; diff --git a/crates/mach/src/config.rs b/crates/mach/src/config.rs index 3f0a03c9..e1e82ca4 100644 --- a/crates/mach/src/config.rs +++ b/crates/mach/src/config.rs @@ -7,8 +7,8 @@ use clap::Parser; use normalize_path::NormalizePath; use crate::args::Args; -use crate::public::Config; -use crate::public::Machrc; +use crate::platform::public::Config; +use crate::platform::public::Machrc; type FileIndex = HashMap>; diff --git a/crates/mach/src/platform/hash/hash.rs b/crates/mach/src/kit/hash/hash.rs similarity index 100% rename from crates/mach/src/platform/hash/hash.rs rename to crates/mach/src/kit/hash/hash.rs diff --git a/crates/mach/src/kit/hash/mod.rs b/crates/mach/src/kit/hash/mod.rs new file mode 100644 index 00000000..a07ea145 --- /dev/null +++ b/crates/mach/src/kit/hash/mod.rs @@ -0,0 +1,3 @@ +pub mod hash; + +pub use crate::kit::hash::hash::*; diff --git a/crates/mach/src/kit/mod.rs b/crates/mach/src/kit/mod.rs new file mode 100644 index 00000000..fd2ef2fa --- /dev/null +++ b/crates/mach/src/kit/mod.rs @@ -0,0 +1,2 @@ +pub mod hash; +pub mod swc; diff --git a/crates/mach/src/platform/swc/convert.rs b/crates/mach/src/kit/swc/convert.rs similarity index 100% rename from crates/mach/src/platform/swc/convert.rs rename to crates/mach/src/kit/swc/convert.rs diff --git a/crates/mach/src/platform/swc/lookup_property_access.rs b/crates/mach/src/kit/swc/lookup_property_access.rs similarity index 100% rename from crates/mach/src/platform/swc/lookup_property_access.rs rename to crates/mach/src/kit/swc/lookup_property_access.rs diff --git a/crates/mach/src/kit/swc/mod.rs b/crates/mach/src/kit/swc/mod.rs new file mode 100644 index 00000000..a339d217 --- /dev/null +++ b/crates/mach/src/kit/swc/mod.rs @@ -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::*; diff --git a/crates/mach/src/platform/swc/parse_module.rs b/crates/mach/src/kit/swc/parse_module.rs similarity index 100% rename from crates/mach/src/platform/swc/parse_module.rs rename to crates/mach/src/kit/swc/parse_module.rs diff --git a/crates/mach/src/platform/swc/parse_program.rs b/crates/mach/src/kit/swc/parse_program.rs similarity index 100% rename from crates/mach/src/platform/swc/parse_program.rs rename to crates/mach/src/kit/swc/parse_program.rs diff --git a/crates/mach/src/platform/swc/parse_script.rs b/crates/mach/src/kit/swc/parse_script.rs similarity index 100% rename from crates/mach/src/platform/swc/parse_script.rs rename to crates/mach/src/kit/swc/parse_script.rs diff --git a/crates/mach/src/platform/swc/render_module.rs b/crates/mach/src/kit/swc/render_module.rs similarity index 100% rename from crates/mach/src/platform/swc/render_module.rs rename to crates/mach/src/kit/swc/render_module.rs diff --git a/crates/mach/src/platform/swc/render_program.rs b/crates/mach/src/kit/swc/render_program.rs similarity index 100% rename from crates/mach/src/platform/swc/render_program.rs rename to crates/mach/src/kit/swc/render_program.rs diff --git a/crates/mach/src/platform/swc/render_script.rs b/crates/mach/src/kit/swc/render_script.rs similarity index 100% rename from crates/mach/src/platform/swc/render_script.rs rename to crates/mach/src/kit/swc/render_script.rs diff --git a/crates/mach/src/platform/swc/render_stmts.rs b/crates/mach/src/kit/swc/render_stmts.rs similarity index 100% rename from crates/mach/src/platform/swc/render_stmts.rs rename to crates/mach/src/kit/swc/render_stmts.rs diff --git a/crates/mach/src/main.rs b/crates/mach/src/main.rs index ace306c9..06e94395 100644 --- a/crates/mach/src/main.rs +++ b/crates/mach/src/main.rs @@ -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); + }, + } +} \ No newline at end of file diff --git a/crates/mach/src/adapters/mod.rs b/crates/mach/src/platform/adapters/mod.rs similarity index 100% rename from crates/mach/src/adapters/mod.rs rename to crates/mach/src/platform/adapters/mod.rs diff --git a/crates/mach/src/adapters/node_js/js/jsconfig.json b/crates/mach/src/platform/adapters/node_js/js/jsconfig.json similarity index 100% rename from crates/mach/src/adapters/node_js/js/jsconfig.json rename to crates/mach/src/platform/adapters/node_js/js/jsconfig.json diff --git a/crates/mach/src/adapters/node_js/js/main.js b/crates/mach/src/platform/adapters/node_js/js/main.js similarity index 100% rename from crates/mach/src/adapters/node_js/js/main.js rename to crates/mach/src/platform/adapters/node_js/js/main.js diff --git a/crates/mach/src/adapters/node_js/js/package.json b/crates/mach/src/platform/adapters/node_js/js/package.json similarity index 100% rename from crates/mach/src/adapters/node_js/js/package.json rename to crates/mach/src/platform/adapters/node_js/js/package.json diff --git a/crates/mach/src/adapters/node_js/js/worker.js b/crates/mach/src/platform/adapters/node_js/js/worker.js similarity index 100% rename from crates/mach/src/adapters/node_js/js/worker.js rename to crates/mach/src/platform/adapters/node_js/js/worker.js diff --git a/crates/mach/src/platform/adapters/node_js/mod.rs b/crates/mach/src/platform/adapters/node_js/mod.rs new file mode 100644 index 00000000..99a637ea --- /dev/null +++ b/crates/mach/src/platform/adapters/node_js/mod.rs @@ -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::*; diff --git a/crates/mach/src/adapters/node_js/node_adapter.rs b/crates/mach/src/platform/adapters/node_js/node_adapter.rs similarity index 100% rename from crates/mach/src/adapters/node_js/node_adapter.rs rename to crates/mach/src/platform/adapters/node_js/node_adapter.rs diff --git a/crates/mach/src/adapters/node_js/node_worker.rs b/crates/mach/src/platform/adapters/node_js/node_worker.rs similarity index 100% rename from crates/mach/src/adapters/node_js/node_worker.rs rename to crates/mach/src/platform/adapters/node_js/node_worker.rs diff --git a/crates/mach/src/adapters/node_js/requests.rs b/crates/mach/src/platform/adapters/node_js/requests.rs similarity index 85% rename from crates/mach/src/adapters/node_js/requests.rs rename to crates/mach/src/platform/adapters/node_js/requests.rs index 0c1173c7..19017ba7 100644 --- a/crates/mach/src/adapters/node_js/requests.rs +++ b/crates/mach/src/platform/adapters/node_js/requests.rs @@ -3,9 +3,9 @@ use std::path::PathBuf; use serde::Deserialize; use serde::Serialize; -use crate::public::Config; -use crate::public::Dependency; -use crate::public::DependencyOptions; +use crate::platform::public::Config; +use crate::platform::public::Dependency; +use crate::platform::public::DependencyOptions; #[derive(Serialize, Clone, Debug)] pub struct LoadPluginRequest { diff --git a/crates/mach/src/adapters/node_js/resolve.rs b/crates/mach/src/platform/adapters/node_js/resolve.rs similarity index 100% rename from crates/mach/src/adapters/node_js/resolve.rs rename to crates/mach/src/platform/adapters/node_js/resolve.rs diff --git a/crates/mach/src/adapters/node_js/spawn.rs b/crates/mach/src/platform/adapters/node_js/spawn.rs similarity index 100% rename from crates/mach/src/adapters/node_js/spawn.rs rename to crates/mach/src/platform/adapters/node_js/spawn.rs diff --git a/crates/mach/src/bundling/bundle.rs b/crates/mach/src/platform/bundling/bundle.rs similarity index 92% rename from crates/mach/src/bundling/bundle.rs rename to crates/mach/src/platform/bundling/bundle.rs index 288c95ad..85462634 100644 --- a/crates/mach/src/bundling/bundle.rs +++ b/crates/mach/src/platform/bundling/bundle.rs @@ -1,14 +1,14 @@ use std::path::PathBuf; -use crate::public; -use crate::public::AssetGraph; -use crate::public::AssetMap; -use crate::public::Bundle; -use crate::public::BundleGraph; -use crate::public::Bundles; -use crate::public::DependencyMap; -use crate::public::ENTRY_ASSET; -use crate::public::NO_ASSET; +use crate::platform::public; +use crate::platform::public::AssetGraph; +use crate::platform::public::AssetMap; +use crate::platform::public::Bundle; +use crate::platform::public::BundleGraph; +use crate::platform::public::Bundles; +use crate::platform::public::DependencyMap; +use crate::platform::public::ENTRY_ASSET; +use crate::platform::public::NO_ASSET; pub fn bundle( _config: &public::Config, diff --git a/crates/mach/src/platform/bundling/mod.rs b/crates/mach/src/platform/bundling/mod.rs new file mode 100644 index 00000000..0bb6443d --- /dev/null +++ b/crates/mach/src/platform/bundling/mod.rs @@ -0,0 +1,3 @@ +mod bundle; + +pub use crate::platform::bundling::bundle::*; diff --git a/crates/mach/src/emit/mod.rs b/crates/mach/src/platform/emit/mod.rs similarity index 81% rename from crates/mach/src/emit/mod.rs rename to crates/mach/src/platform/emit/mod.rs index c333e883..af645bc4 100644 --- a/crates/mach/src/emit/mod.rs +++ b/crates/mach/src/platform/emit/mod.rs @@ -1,9 +1,9 @@ use std::fs; -use crate::platform::swc::render_module; -use crate::public::Bundles; -use crate::public::Packages; -use crate::public::{self}; +use crate::kit::swc::render_module; +use crate::platform::public::Bundles; +use crate::platform::public::Packages; +use crate::platform::public::{self}; pub fn emit( config: &public::Config, diff --git a/crates/mach/src/platform/hash/mod.rs b/crates/mach/src/platform/hash/mod.rs deleted file mode 100644 index 1117f942..00000000 --- a/crates/mach/src/platform/hash/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod hash; - -pub use crate::platform::hash::hash::*; diff --git a/crates/mach/src/platform/mod.rs b/crates/mach/src/platform/mod.rs index fd2ef2fa..d7eb97cc 100644 --- a/crates/mach/src/platform/mod.rs +++ b/crates/mach/src/platform/mod.rs @@ -1,2 +1,7 @@ -pub mod hash; -pub mod swc; +pub mod adapters; +pub mod bundling; +pub mod emit; +pub mod packaging; +pub mod plugins; +pub mod public; +pub mod transformation; diff --git a/crates/mach/src/packaging/js_runtime/default_decl.rs b/crates/mach/src/platform/packaging/js_runtime/default_decl.rs similarity index 100% rename from crates/mach/src/packaging/js_runtime/default_decl.rs rename to crates/mach/src/platform/packaging/js_runtime/default_decl.rs diff --git a/crates/mach/src/packaging/js_runtime/js_runtime.rs b/crates/mach/src/platform/packaging/js_runtime/js_runtime.rs similarity index 97% rename from crates/mach/src/packaging/js_runtime/js_runtime.rs rename to crates/mach/src/platform/packaging/js_runtime/js_runtime.rs index 665d38d0..c2fff5b3 100644 --- a/crates/mach/src/packaging/js_runtime/js_runtime.rs +++ b/crates/mach/src/platform/packaging/js_runtime/js_runtime.rs @@ -6,14 +6,14 @@ use swc_core::ecma::ast::*; use swc_core::ecma::visit::Fold; use swc_core::ecma::visit::FoldWith; -use crate::packaging::runtime_factory::ExportNamed; -use crate::packaging::runtime_factory::ImportNamed; -use crate::platform::swc::lookup_property_access; -use crate::platform::swc::stmt_to_module_item; -use crate::platform::swc::PropAccessType; -use crate::public::AssetGraph; -use crate::public::BundleGraph; -use crate::public::DependencyMap; +use crate::platform::packaging::runtime_factory::ExportNamed; +use crate::platform::packaging::runtime_factory::ImportNamed; +use crate::kit::swc::lookup_property_access; +use crate::kit::swc::stmt_to_module_item; +use crate::kit::swc::PropAccessType; +use crate::platform::public::AssetGraph; +use crate::platform::public::BundleGraph; +use crate::platform::public::DependencyMap; use super::super::runtime_factory::RuntimeFactory; use super::read_exports::read_exports; diff --git a/crates/mach/src/packaging/js_runtime/mod.rs b/crates/mach/src/platform/packaging/js_runtime/mod.rs similarity index 100% rename from crates/mach/src/packaging/js_runtime/mod.rs rename to crates/mach/src/platform/packaging/js_runtime/mod.rs diff --git a/crates/mach/src/packaging/js_runtime/read_exports.rs b/crates/mach/src/platform/packaging/js_runtime/read_exports.rs similarity index 100% rename from crates/mach/src/packaging/js_runtime/read_exports.rs rename to crates/mach/src/platform/packaging/js_runtime/read_exports.rs diff --git a/crates/mach/src/packaging/js_runtime/read_exports_named.rs b/crates/mach/src/platform/packaging/js_runtime/read_exports_named.rs similarity index 97% rename from crates/mach/src/packaging/js_runtime/read_exports_named.rs rename to crates/mach/src/platform/packaging/js_runtime/read_exports_named.rs index 28e22d66..3ed258ae 100644 --- a/crates/mach/src/packaging/js_runtime/read_exports_named.rs +++ b/crates/mach/src/platform/packaging/js_runtime/read_exports_named.rs @@ -1,6 +1,6 @@ use swc_core::ecma::ast::*; -use crate::packaging::runtime_factory::ExportNamed; +use crate::platform::packaging::runtime_factory::ExportNamed; /* const foo = ''; export { foo } diff --git a/crates/mach/src/packaging/js_runtime/read_import_assignments.rs b/crates/mach/src/platform/packaging/js_runtime/read_import_assignments.rs similarity index 97% rename from crates/mach/src/packaging/js_runtime/read_import_assignments.rs rename to crates/mach/src/platform/packaging/js_runtime/read_import_assignments.rs index eabab64c..db072e5f 100644 --- a/crates/mach/src/packaging/js_runtime/read_import_assignments.rs +++ b/crates/mach/src/platform/packaging/js_runtime/read_import_assignments.rs @@ -1,6 +1,6 @@ use swc_core::ecma::ast::*; -use crate::packaging::runtime_factory::ImportNamed; +use crate::platform::packaging::runtime_factory::ImportNamed; /// ImportAssignment looks at the variables assigned within an import statement /// import { a, b } from './foo' diff --git a/crates/mach/src/packaging/mod.rs b/crates/mach/src/platform/packaging/mod.rs similarity index 53% rename from crates/mach/src/packaging/mod.rs rename to crates/mach/src/platform/packaging/mod.rs index 0c8e655e..e7b8d192 100644 --- a/crates/mach/src/packaging/mod.rs +++ b/crates/mach/src/platform/packaging/mod.rs @@ -2,4 +2,4 @@ mod js_runtime; mod package; pub mod runtime_factory; -pub use crate::packaging::package::*; +pub use crate::platform::packaging::package::*; diff --git a/crates/mach/src/packaging/package.rs b/crates/mach/src/platform/packaging/package.rs similarity index 91% rename from crates/mach/src/packaging/package.rs rename to crates/mach/src/platform/packaging/package.rs index 76bfb304..6d16ed61 100644 --- a/crates/mach/src/packaging/package.rs +++ b/crates/mach/src/platform/packaging/package.rs @@ -9,16 +9,16 @@ use swc_core::common::Span; use swc_core::ecma::ast::*; use swc_core::ecma::visit::FoldWith; -use crate::platform::swc::module_item_to_stmt; -use crate::platform::swc::parse_program; -use crate::public; -use crate::public::AssetGraph; -use crate::public::AssetMap; -use crate::public::BundleGraph; -use crate::public::Bundles; -use crate::public::DependencyMap; -use crate::public::PackageType; -use crate::public::Packages; +use crate::kit::swc::module_item_to_stmt; +use crate::kit::swc::parse_program; +use crate::platform::public; +use crate::platform::public::AssetGraph; +use crate::platform::public::AssetMap; +use crate::platform::public::BundleGraph; +use crate::platform::public::Bundles; +use crate::platform::public::DependencyMap; +use crate::platform::public::PackageType; +use crate::platform::public::Packages; use super::js_runtime::js_runtime::JavaScriptRuntime; use super::runtime_factory::RuntimeFactory; diff --git a/crates/mach/src/packaging/runtime_factory/js/define_export.js b/crates/mach/src/platform/packaging/runtime_factory/js/define_export.js similarity index 100% rename from crates/mach/src/packaging/runtime_factory/js/define_export.js rename to crates/mach/src/platform/packaging/runtime_factory/js/define_export.js diff --git a/crates/mach/src/packaging/runtime_factory/js/import_script_classic.js b/crates/mach/src/platform/packaging/runtime_factory/js/import_script_classic.js similarity index 100% rename from crates/mach/src/packaging/runtime_factory/js/import_script_classic.js rename to crates/mach/src/platform/packaging/runtime_factory/js/import_script_classic.js diff --git a/crates/mach/src/packaging/runtime_factory/js/import_script_esm.js b/crates/mach/src/platform/packaging/runtime_factory/js/import_script_esm.js similarity index 100% rename from crates/mach/src/packaging/runtime_factory/js/import_script_esm.js rename to crates/mach/src/platform/packaging/runtime_factory/js/import_script_esm.js diff --git a/crates/mach/src/packaging/runtime_factory/js/mach_require.js b/crates/mach/src/platform/packaging/runtime_factory/js/mach_require.js similarity index 100% rename from crates/mach/src/packaging/runtime_factory/js/mach_require.js rename to crates/mach/src/platform/packaging/runtime_factory/js/mach_require.js diff --git a/crates/mach/src/packaging/runtime_factory/js/manifest.js b/crates/mach/src/platform/packaging/runtime_factory/js/manifest.js similarity index 100% rename from crates/mach/src/packaging/runtime_factory/js/manifest.js rename to crates/mach/src/platform/packaging/runtime_factory/js/manifest.js diff --git a/crates/mach/src/packaging/runtime_factory/js/module.js b/crates/mach/src/platform/packaging/runtime_factory/js/module.js similarity index 100% rename from crates/mach/src/packaging/runtime_factory/js/module.js rename to crates/mach/src/platform/packaging/runtime_factory/js/module.js diff --git a/crates/mach/src/packaging/runtime_factory/js/prelude.js b/crates/mach/src/platform/packaging/runtime_factory/js/prelude.js similarity index 100% rename from crates/mach/src/packaging/runtime_factory/js/prelude.js rename to crates/mach/src/platform/packaging/runtime_factory/js/prelude.js diff --git a/crates/mach/src/packaging/runtime_factory/js/prelude_require.js b/crates/mach/src/platform/packaging/runtime_factory/js/prelude_require.js similarity index 100% rename from crates/mach/src/packaging/runtime_factory/js/prelude_require.js rename to crates/mach/src/platform/packaging/runtime_factory/js/prelude_require.js diff --git a/crates/mach/src/packaging/runtime_factory/js/wrapper.js b/crates/mach/src/platform/packaging/runtime_factory/js/wrapper.js similarity index 100% rename from crates/mach/src/packaging/runtime_factory/js/wrapper.js rename to crates/mach/src/platform/packaging/runtime_factory/js/wrapper.js diff --git a/crates/mach/src/packaging/runtime_factory/mod.rs b/crates/mach/src/platform/packaging/runtime_factory/mod.rs similarity index 99% rename from crates/mach/src/packaging/runtime_factory/mod.rs rename to crates/mach/src/platform/packaging/runtime_factory/mod.rs index 1cd66535..ba905f73 100644 --- a/crates/mach/src/packaging/runtime_factory/mod.rs +++ b/crates/mach/src/platform/packaging/runtime_factory/mod.rs @@ -6,7 +6,7 @@ use swc_core::common::SourceMap; use swc_core::common::Span; use swc_core::ecma::ast::*; -use crate::platform::swc::parse_script; +use crate::kit::swc::parse_script; const JS_DEFINE_EXPORT: &str = include_str!("./js/define_export.js"); const JS_IMPORT_SCRIPT_CLASSIC: &str = include_str!("./js/import_script_classic.js"); diff --git a/crates/mach/src/packaging/runtime_factory/scratch.rs b/crates/mach/src/platform/packaging/runtime_factory/scratch.rs similarity index 100% rename from crates/mach/src/packaging/runtime_factory/scratch.rs rename to crates/mach/src/platform/packaging/runtime_factory/scratch.rs diff --git a/crates/mach/src/plugins/builtin/mod.rs b/crates/mach/src/platform/plugins/builtin/mod.rs similarity index 100% rename from crates/mach/src/plugins/builtin/mod.rs rename to crates/mach/src/platform/plugins/builtin/mod.rs diff --git a/crates/mach/src/platform/plugins/builtin/resolver/mod.rs b/crates/mach/src/platform/plugins/builtin/resolver/mod.rs new file mode 100644 index 00000000..ae8e952a --- /dev/null +++ b/crates/mach/src/platform/plugins/builtin/resolver/mod.rs @@ -0,0 +1,5 @@ +mod resolve; +mod resolver; + +pub use crate::platform::plugins::builtin::resolver::resolve::*; +pub use crate::platform::plugins::builtin::resolver::resolver::*; diff --git a/crates/mach/src/plugins/builtin/resolver/resolve.rs b/crates/mach/src/platform/plugins/builtin/resolver/resolve.rs similarity index 100% rename from crates/mach/src/plugins/builtin/resolver/resolve.rs rename to crates/mach/src/platform/plugins/builtin/resolver/resolve.rs diff --git a/crates/mach/src/plugins/builtin/resolver/resolver.rs b/crates/mach/src/platform/plugins/builtin/resolver/resolver.rs similarity index 79% rename from crates/mach/src/plugins/builtin/resolver/resolver.rs rename to crates/mach/src/platform/plugins/builtin/resolver/resolver.rs index d5ce06bd..2c2e1f29 100644 --- a/crates/mach/src/plugins/builtin/resolver/resolver.rs +++ b/crates/mach/src/platform/plugins/builtin/resolver/resolver.rs @@ -1,8 +1,8 @@ use async_trait::async_trait; -use crate::public::Dependency; -use crate::public::ResolveResult; -use crate::public::Resolver; +use crate::platform::public::Dependency; +use crate::platform::public::ResolveResult; +use crate::platform::public::Resolver; use super::resolve; diff --git a/crates/mach/src/platform/plugins/builtin/resolver_node_js/mod.rs b/crates/mach/src/platform/plugins/builtin/resolver_node_js/mod.rs new file mode 100644 index 00000000..99aeb100 --- /dev/null +++ b/crates/mach/src/platform/plugins/builtin/resolver_node_js/mod.rs @@ -0,0 +1,3 @@ +mod resolver; + +pub use crate::platform::plugins::builtin::resolver_node_js::resolver::*; diff --git a/crates/mach/src/plugins/builtin/resolver_node_js/resolver.rs b/crates/mach/src/platform/plugins/builtin/resolver_node_js/resolver.rs similarity index 77% rename from crates/mach/src/plugins/builtin/resolver_node_js/resolver.rs rename to crates/mach/src/platform/plugins/builtin/resolver_node_js/resolver.rs index ced1b975..7416ecff 100644 --- a/crates/mach/src/plugins/builtin/resolver_node_js/resolver.rs +++ b/crates/mach/src/platform/plugins/builtin/resolver_node_js/resolver.rs @@ -3,13 +3,13 @@ use std::sync::Arc; use async_trait::async_trait; -use crate::adapters::node_js::requests::LoadPluginRequest; -use crate::adapters::node_js::requests::RunResolverRequest; -use crate::adapters::node_js::requests::RunResolverResponse; -use crate::adapters::node_js::NodeAdapter; -use crate::public::Dependency; -use crate::public::ResolveResult; -use crate::public::Resolver; +use crate::platform::adapters::node_js::requests::LoadPluginRequest; +use crate::platform::adapters::node_js::requests::RunResolverRequest; +use crate::platform::adapters::node_js::requests::RunResolverResponse; +use crate::platform::adapters::node_js::NodeAdapter; +use crate::platform::public::Dependency; +use crate::platform::public::ResolveResult; +use crate::platform::public::Resolver; pub struct ResolverNodeJs { specifier: String, diff --git a/crates/mach/src/platform/plugins/builtin/transformer_css/mod.rs b/crates/mach/src/platform/plugins/builtin/transformer_css/mod.rs new file mode 100644 index 00000000..ae63b5a2 --- /dev/null +++ b/crates/mach/src/platform/plugins/builtin/transformer_css/mod.rs @@ -0,0 +1,3 @@ +mod transformer; + +pub use crate::platform::plugins::builtin::transformer_css::transformer::*; diff --git a/crates/mach/src/plugins/builtin/transformer_css/transformer.rs b/crates/mach/src/platform/plugins/builtin/transformer_css/transformer.rs similarity index 70% rename from crates/mach/src/plugins/builtin/transformer_css/transformer.rs rename to crates/mach/src/platform/plugins/builtin/transformer_css/transformer.rs index 1c4c8432..706033fa 100644 --- a/crates/mach/src/plugins/builtin/transformer_css/transformer.rs +++ b/crates/mach/src/platform/plugins/builtin/transformer_css/transformer.rs @@ -1,8 +1,8 @@ use async_trait::async_trait; -use crate::public::Config; -use crate::public::MutableAsset; -use crate::public::Transformer; +use crate::platform::public::Config; +use crate::platform::public::MutableAsset; +use crate::platform::public::Transformer; #[derive(Debug)] pub struct DefaultTransformerCSS {} diff --git a/crates/mach/src/platform/plugins/builtin/transformer_javascript/mod.rs b/crates/mach/src/platform/plugins/builtin/transformer_javascript/mod.rs new file mode 100644 index 00000000..15ce9ed4 --- /dev/null +++ b/crates/mach/src/platform/plugins/builtin/transformer_javascript/mod.rs @@ -0,0 +1,7 @@ +mod node_env_replacer; +mod read_imports; +mod transformer; + +pub use crate::platform::plugins::builtin::transformer_javascript::node_env_replacer::*; +pub use crate::platform::plugins::builtin::transformer_javascript::read_imports::*; +pub use crate::platform::plugins::builtin::transformer_javascript::transformer::*; diff --git a/crates/mach/src/plugins/builtin/transformer_javascript/node_env_replacer.rs b/crates/mach/src/platform/plugins/builtin/transformer_javascript/node_env_replacer.rs similarity index 100% rename from crates/mach/src/plugins/builtin/transformer_javascript/node_env_replacer.rs rename to crates/mach/src/platform/plugins/builtin/transformer_javascript/node_env_replacer.rs diff --git a/crates/mach/src/plugins/builtin/transformer_javascript/read_imports.rs b/crates/mach/src/platform/plugins/builtin/transformer_javascript/read_imports.rs similarity index 98% rename from crates/mach/src/plugins/builtin/transformer_javascript/read_imports.rs rename to crates/mach/src/platform/plugins/builtin/transformer_javascript/read_imports.rs index 6509d66e..a463fa81 100644 --- a/crates/mach/src/plugins/builtin/transformer_javascript/read_imports.rs +++ b/crates/mach/src/platform/plugins/builtin/transformer_javascript/read_imports.rs @@ -9,9 +9,9 @@ use swc_core::ecma::ast::*; use swc_core::ecma::visit::Visit; use swc_core::ecma::visit::VisitWith; -use crate::public::DependencyPriority; -use crate::public::ImportSymbolType; -use crate::public::SpecifierType; +use crate::platform::public::DependencyPriority; +use crate::platform::public::ImportSymbolType; +use crate::platform::public::SpecifierType; static REQUIRE_SYMBOL: Lazy = Lazy::new(|| Atom::from("require")); diff --git a/crates/mach/src/plugins/builtin/transformer_javascript/transformer.rs b/crates/mach/src/platform/plugins/builtin/transformer_javascript/transformer.rs similarity index 91% rename from crates/mach/src/plugins/builtin/transformer_javascript/transformer.rs rename to crates/mach/src/platform/plugins/builtin/transformer_javascript/transformer.rs index 408f989e..3876a8ef 100644 --- a/crates/mach/src/plugins/builtin/transformer_javascript/transformer.rs +++ b/crates/mach/src/platform/plugins/builtin/transformer_javascript/transformer.rs @@ -12,12 +12,12 @@ use swc_core::ecma::transforms::react::{self as react_transforms}; use swc_core::ecma::transforms::typescript::{self as typescript_transforms}; use swc_core::ecma::visit::FoldWith; -use crate::platform::swc::parse_program; -use crate::platform::swc::render_program; -use crate::public::Config; -use crate::public::DependencyOptions; -use crate::public::MutableAsset; -use crate::public::Transformer; +use crate::kit::swc::parse_program; +use crate::kit::swc::render_program; +use crate::platform::public::Config; +use crate::platform::public::DependencyOptions; +use crate::platform::public::MutableAsset; +use crate::platform::public::Transformer; use super::collect_decls; use super::read_imports_exports; @@ -107,7 +107,7 @@ impl Transformer for DefaultTransformerJavaScript { priority: dependency.priority, resolve_from: asset.file_path.clone(), imported_symbols: dependency.imported_symbols, - bundle_behavior: crate::public::BundleBehavior::Default, + bundle_behavior: crate::platform::public::BundleBehavior::Default, }); } diff --git a/crates/mach/src/platform/plugins/builtin/transformer_node_js/mod.rs b/crates/mach/src/platform/plugins/builtin/transformer_node_js/mod.rs new file mode 100644 index 00000000..98fa8043 --- /dev/null +++ b/crates/mach/src/platform/plugins/builtin/transformer_node_js/mod.rs @@ -0,0 +1,3 @@ +mod transformer; + +pub use crate::platform::plugins::builtin::transformer_node_js::transformer::*; diff --git a/crates/mach/src/plugins/builtin/transformer_node_js/transformer.rs b/crates/mach/src/platform/plugins/builtin/transformer_node_js/transformer.rs similarity index 80% rename from crates/mach/src/plugins/builtin/transformer_node_js/transformer.rs rename to crates/mach/src/platform/plugins/builtin/transformer_node_js/transformer.rs index fab40c74..d067a575 100644 --- a/crates/mach/src/plugins/builtin/transformer_node_js/transformer.rs +++ b/crates/mach/src/platform/plugins/builtin/transformer_node_js/transformer.rs @@ -3,13 +3,13 @@ use std::sync::Arc; use async_trait::async_trait; -use crate::adapters::node_js::requests::LoadPluginRequest; -use crate::adapters::node_js::requests::RunTransformerRequest; -use crate::adapters::node_js::requests::RunTransformerResponse; -use crate::adapters::node_js::NodeAdapter; -use crate::public::Config; -use crate::public::MutableAsset; -use crate::public::Transformer; +use crate::platform::adapters::node_js::requests::LoadPluginRequest; +use crate::platform::adapters::node_js::requests::RunTransformerRequest; +use crate::platform::adapters::node_js::requests::RunTransformerResponse; +use crate::platform::adapters::node_js::NodeAdapter; +use crate::platform::public::Config; +use crate::platform::public::MutableAsset; +use crate::platform::public::Transformer; pub struct TransformerNodeJs { specifier: String, diff --git a/crates/mach/src/platform/plugins/builtin/transformer_noop/mod.rs b/crates/mach/src/platform/plugins/builtin/transformer_noop/mod.rs new file mode 100644 index 00000000..5cb570d4 --- /dev/null +++ b/crates/mach/src/platform/plugins/builtin/transformer_noop/mod.rs @@ -0,0 +1,3 @@ +mod transformer; + +pub use crate::platform::plugins::builtin::transformer_noop::transformer::*; diff --git a/crates/mach/src/platform/plugins/builtin/transformer_noop/transformer.rs b/crates/mach/src/platform/plugins/builtin/transformer_noop/transformer.rs new file mode 100644 index 00000000..f794846a --- /dev/null +++ b/crates/mach/src/platform/plugins/builtin/transformer_noop/transformer.rs @@ -0,0 +1,28 @@ +use async_trait::async_trait; + +use crate::platform::public::Config; +use crate::platform::public::DependencyOptions; +use crate::platform::public::MutableAsset; +use crate::platform::public::Transformer; + +#[derive(Debug)] +pub struct DefaultTransformerNoop {} + +#[async_trait] +impl Transformer for DefaultTransformerNoop { + async fn transform( + &self, + asset: &mut MutableAsset, + _config: &Config, + ) -> Result<(), String> { + asset.add_dependency(DependencyOptions { + specifier: "./index.js".to_string(), + specifier_type: crate::platform::public::SpecifierType::ESM, + priority: crate::platform::public::DependencyPriority::Lazy, + resolve_from: asset.file_path.clone(), + imported_symbols: vec![crate::platform::public::ImportSymbolType::Namespace("".to_string())], + bundle_behavior: crate::platform::public::BundleBehavior::Default, + }); + return Ok(()); + } +} diff --git a/crates/mach/src/plugins/load_plugins.rs b/crates/mach/src/platform/plugins/load_plugins.rs similarity index 94% rename from crates/mach/src/plugins/load_plugins.rs rename to crates/mach/src/platform/plugins/load_plugins.rs index 65d931f8..db79cf75 100644 --- a/crates/mach/src/plugins/load_plugins.rs +++ b/crates/mach/src/platform/plugins/load_plugins.rs @@ -3,10 +3,10 @@ use std::sync::Arc; use normalize_path::NormalizePath; -use crate::adapters::node_js::native_node_resolve; -use crate::adapters::node_js::NodeAdapter; -use crate::public::Machrc; -use crate::public::Transformer; +use crate::platform::adapters::node_js::native_node_resolve; +use crate::platform::adapters::node_js::NodeAdapter; +use crate::platform::public::Machrc; +use crate::platform::public::Transformer; use super::builtin::resolver::DefaultResolver; use super::builtin::resolver_node_js::ResolverNodeJs; diff --git a/crates/mach/src/platform/plugins/mod.rs b/crates/mach/src/platform/plugins/mod.rs new file mode 100644 index 00000000..aec12fb2 --- /dev/null +++ b/crates/mach/src/platform/plugins/mod.rs @@ -0,0 +1,6 @@ +pub mod builtin; +mod load_plugins; +mod plugin_container; + +pub use crate::platform::plugins::load_plugins::*; +pub use crate::platform::plugins::plugin_container::*; diff --git a/crates/mach/src/plugins/plugin_container.rs b/crates/mach/src/platform/plugins/plugin_container.rs similarity index 96% rename from crates/mach/src/plugins/plugin_container.rs rename to crates/mach/src/platform/plugins/plugin_container.rs index bec4b9de..df4e4ede 100644 --- a/crates/mach/src/plugins/plugin_container.rs +++ b/crates/mach/src/platform/plugins/plugin_container.rs @@ -1,8 +1,8 @@ use std::collections::HashMap; use std::path::Path; -use crate::public::Resolver; -use crate::public::Transformer; +use crate::platform::public::Resolver; +use crate::platform::public::Transformer; #[derive(Default, Debug)] pub struct PluginContainer { diff --git a/crates/mach/src/public/asset.rs b/crates/mach/src/platform/public/asset.rs similarity index 100% rename from crates/mach/src/public/asset.rs rename to crates/mach/src/platform/public/asset.rs diff --git a/crates/mach/src/public/asset_graph.rs b/crates/mach/src/platform/public/asset_graph.rs similarity index 100% rename from crates/mach/src/public/asset_graph.rs rename to crates/mach/src/platform/public/asset_graph.rs diff --git a/crates/mach/src/public/asset_store.rs b/crates/mach/src/platform/public/asset_store.rs similarity index 100% rename from crates/mach/src/public/asset_store.rs rename to crates/mach/src/platform/public/asset_store.rs diff --git a/crates/mach/src/public/bundle.rs b/crates/mach/src/platform/public/bundle.rs similarity index 95% rename from crates/mach/src/public/bundle.rs rename to crates/mach/src/platform/public/bundle.rs index a0b92cb1..78ab42b2 100644 --- a/crates/mach/src/public/bundle.rs +++ b/crates/mach/src/platform/public/bundle.rs @@ -3,8 +3,8 @@ use std::collections::HashSet; use std::path::Path; use std::path::PathBuf; -use crate::platform::hash::hash_string_sha_256; -use crate::platform::hash::truncate; +use crate::kit::hash::hash_string_sha_256; +use crate::kit::hash::truncate; use super::ID_TRUNC; diff --git a/crates/mach/src/public/config.rs b/crates/mach/src/platform/public/config.rs similarity index 100% rename from crates/mach/src/public/config.rs rename to crates/mach/src/platform/public/config.rs diff --git a/crates/mach/src/public/constants.rs b/crates/mach/src/platform/public/constants.rs similarity index 100% rename from crates/mach/src/public/constants.rs rename to crates/mach/src/platform/public/constants.rs diff --git a/crates/mach/src/public/dependency.rs b/crates/mach/src/platform/public/dependency.rs similarity index 100% rename from crates/mach/src/public/dependency.rs rename to crates/mach/src/platform/public/dependency.rs diff --git a/crates/mach/src/public/dependency_graph.rs b/crates/mach/src/platform/public/dependency_graph.rs similarity index 96% rename from crates/mach/src/public/dependency_graph.rs rename to crates/mach/src/platform/public/dependency_graph.rs index cd6d509b..00fc6873 100644 --- a/crates/mach/src/public/dependency_graph.rs +++ b/crates/mach/src/platform/public/dependency_graph.rs @@ -1,5 +1,5 @@ -use crate::platform::hash::hash_string_sha_256; -use crate::platform::hash::truncate; +use crate::kit::hash::hash_string_sha_256; +use crate::kit::hash::truncate; use super::Dependency; use super::ID_TRUNC; diff --git a/crates/mach/src/public/machrc.rs b/crates/mach/src/platform/public/machrc.rs similarity index 100% rename from crates/mach/src/public/machrc.rs rename to crates/mach/src/platform/public/machrc.rs diff --git a/crates/mach/src/platform/public/mod.rs b/crates/mach/src/platform/public/mod.rs new file mode 100644 index 00000000..634882fb --- /dev/null +++ b/crates/mach/src/platform/public/mod.rs @@ -0,0 +1,25 @@ +mod asset; +mod asset_graph; +mod asset_store; +mod bundle; +mod config; +mod constants; +mod dependency; +mod dependency_graph; +mod machrc; +mod packages; +mod resolver; +mod transformer; + +pub use crate::platform::public::asset::*; +pub use crate::platform::public::asset_graph::*; +pub use crate::platform::public::asset_store::*; +pub use crate::platform::public::bundle::*; +pub use crate::platform::public::config::*; +pub use crate::platform::public::constants::*; +pub use crate::platform::public::dependency::*; +pub use crate::platform::public::dependency_graph::*; +pub use crate::platform::public::machrc::*; +pub use crate::platform::public::packages::*; +pub use crate::platform::public::resolver::*; +pub use crate::platform::public::transformer::*; diff --git a/crates/mach/src/public/packages.rs b/crates/mach/src/platform/public/packages.rs similarity index 100% rename from crates/mach/src/public/packages.rs rename to crates/mach/src/platform/public/packages.rs diff --git a/crates/mach/src/public/resolver.rs b/crates/mach/src/platform/public/resolver.rs similarity index 89% rename from crates/mach/src/public/resolver.rs rename to crates/mach/src/platform/public/resolver.rs index 90bc3ede..83e0576a 100644 --- a/crates/mach/src/public/resolver.rs +++ b/crates/mach/src/platform/public/resolver.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use async_trait::async_trait; use dependency::Dependency; -use crate::public::dependency; +use crate::platform::public::dependency; #[async_trait] pub trait Resolver: Debug + Send + Sync { diff --git a/crates/mach/src/public/transformer.rs b/crates/mach/src/platform/public/transformer.rs similarity index 94% rename from crates/mach/src/public/transformer.rs rename to crates/mach/src/platform/public/transformer.rs index b9d427a1..d6c7342b 100644 --- a/crates/mach/src/public/transformer.rs +++ b/crates/mach/src/platform/public/transformer.rs @@ -5,8 +5,8 @@ use async_trait::async_trait; use serde::Deserialize; use serde::Serialize; -use crate::public::Config; -use crate::public::SpecifierType; +use crate::platform::public::Config; +use crate::platform::public::SpecifierType; use super::BundleBehavior; use super::DependencyPriority; diff --git a/crates/mach/src/platform/swc/mod.rs b/crates/mach/src/platform/swc/mod.rs deleted file mode 100644 index b476ce8b..00000000 --- a/crates/mach/src/platform/swc/mod.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![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::platform::swc::convert::*; -pub use crate::platform::swc::lookup_property_access::*; -pub use crate::platform::swc::parse_module::*; -pub use crate::platform::swc::parse_program::*; -pub use crate::platform::swc::parse_script::*; -pub use crate::platform::swc::render_module::*; -pub use crate::platform::swc::render_program::*; -pub use crate::platform::swc::render_script::*; -pub use crate::platform::swc::render_stmts::*; diff --git a/crates/mach/src/platform/transformation/mod.rs b/crates/mach/src/platform/transformation/mod.rs new file mode 100644 index 00000000..c973c870 --- /dev/null +++ b/crates/mach/src/platform/transformation/mod.rs @@ -0,0 +1,3 @@ +mod transform; + +pub use crate::platform::transformation::transform::*; diff --git a/crates/mach/src/transformation/transform.rs b/crates/mach/src/platform/transformation/transform.rs similarity index 88% rename from crates/mach/src/transformation/transform.rs rename to crates/mach/src/platform/transformation/transform.rs index 78b0203b..59888905 100644 --- a/crates/mach/src/transformation/transform.rs +++ b/crates/mach/src/platform/transformation/transform.rs @@ -1,16 +1,16 @@ use std::fs; -use crate::plugins::PluginContainer; -use crate::plugins::TransformerTarget; -use crate::public; -use crate::public::Asset; -use crate::public::AssetGraph; -use crate::public::AssetMap; -use crate::public::Dependency; -use crate::public::DependencyMap; -use crate::public::DependencyOptions; -use crate::public::MutableAsset; -use crate::public::ENTRY_ASSET; +use crate::platform::plugins::PluginContainer; +use crate::platform::plugins::TransformerTarget; +use crate::platform::public; +use crate::platform::public::Asset; +use crate::platform::public::AssetGraph; +use crate::platform::public::AssetMap; +use crate::platform::public::Dependency; +use crate::platform::public::DependencyMap; +use crate::platform::public::DependencyOptions; +use crate::platform::public::MutableAsset; +use crate::platform::public::ENTRY_ASSET; pub async fn transform( config: &public::Config, diff --git a/crates/mach/src/plugins/builtin/resolver/mod.rs b/crates/mach/src/plugins/builtin/resolver/mod.rs deleted file mode 100644 index 9849d577..00000000 --- a/crates/mach/src/plugins/builtin/resolver/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -mod resolve; -mod resolver; - -pub use crate::plugins::builtin::resolver::resolve::*; -pub use crate::plugins::builtin::resolver::resolver::*; diff --git a/crates/mach/src/plugins/builtin/resolver_node_js/mod.rs b/crates/mach/src/plugins/builtin/resolver_node_js/mod.rs deleted file mode 100644 index 740fa650..00000000 --- a/crates/mach/src/plugins/builtin/resolver_node_js/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod resolver; - -pub use crate::plugins::builtin::resolver_node_js::resolver::*; diff --git a/crates/mach/src/plugins/builtin/transformer_css/mod.rs b/crates/mach/src/plugins/builtin/transformer_css/mod.rs deleted file mode 100644 index a5d43e4c..00000000 --- a/crates/mach/src/plugins/builtin/transformer_css/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod transformer; - -pub use crate::plugins::builtin::transformer_css::transformer::*; diff --git a/crates/mach/src/plugins/builtin/transformer_javascript/mod.rs b/crates/mach/src/plugins/builtin/transformer_javascript/mod.rs deleted file mode 100644 index 5116c96b..00000000 --- a/crates/mach/src/plugins/builtin/transformer_javascript/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod node_env_replacer; -mod read_imports; -mod transformer; - -pub use crate::plugins::builtin::transformer_javascript::node_env_replacer::*; -pub use crate::plugins::builtin::transformer_javascript::read_imports::*; -pub use crate::plugins::builtin::transformer_javascript::transformer::*; diff --git a/crates/mach/src/plugins/builtin/transformer_node_js/mod.rs b/crates/mach/src/plugins/builtin/transformer_node_js/mod.rs deleted file mode 100644 index 5459481b..00000000 --- a/crates/mach/src/plugins/builtin/transformer_node_js/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod transformer; - -pub use crate::plugins::builtin::transformer_node_js::transformer::*; diff --git a/crates/mach/src/plugins/builtin/transformer_noop/mod.rs b/crates/mach/src/plugins/builtin/transformer_noop/mod.rs deleted file mode 100644 index 73a72299..00000000 --- a/crates/mach/src/plugins/builtin/transformer_noop/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod transformer; - -pub use crate::plugins::builtin::transformer_noop::transformer::*; diff --git a/crates/mach/src/plugins/builtin/transformer_noop/transformer.rs b/crates/mach/src/plugins/builtin/transformer_noop/transformer.rs deleted file mode 100644 index 9b10fffe..00000000 --- a/crates/mach/src/plugins/builtin/transformer_noop/transformer.rs +++ /dev/null @@ -1,28 +0,0 @@ -use async_trait::async_trait; - -use crate::public::Config; -use crate::public::DependencyOptions; -use crate::public::MutableAsset; -use crate::public::Transformer; - -#[derive(Debug)] -pub struct DefaultTransformerNoop {} - -#[async_trait] -impl Transformer for DefaultTransformerNoop { - async fn transform( - &self, - asset: &mut MutableAsset, - _config: &Config, - ) -> Result<(), String> { - asset.add_dependency(DependencyOptions { - specifier: "./index.js".to_string(), - specifier_type: crate::public::SpecifierType::ESM, - priority: crate::public::DependencyPriority::Lazy, - resolve_from: asset.file_path.clone(), - imported_symbols: vec![crate::public::ImportSymbolType::Namespace("".to_string())], - bundle_behavior: crate::public::BundleBehavior::Default, - }); - return Ok(()); - } -} diff --git a/crates/mach/src/plugins/mod.rs b/crates/mach/src/plugins/mod.rs deleted file mode 100644 index 9d504d6a..00000000 --- a/crates/mach/src/plugins/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub mod builtin; -mod load_plugins; -mod plugin_container; - -pub use crate::plugins::load_plugins::*; -pub use crate::plugins::plugin_container::*; diff --git a/crates/mach/src/public/mod.rs b/crates/mach/src/public/mod.rs deleted file mode 100644 index d30e09a1..00000000 --- a/crates/mach/src/public/mod.rs +++ /dev/null @@ -1,25 +0,0 @@ -mod asset; -mod asset_graph; -mod asset_store; -mod bundle; -mod config; -mod constants; -mod dependency; -mod dependency_graph; -mod machrc; -mod packages; -mod resolver; -mod transformer; - -pub use crate::public::asset::*; -pub use crate::public::asset_graph::*; -pub use crate::public::asset_store::*; -pub use crate::public::bundle::*; -pub use crate::public::config::*; -pub use crate::public::constants::*; -pub use crate::public::dependency::*; -pub use crate::public::dependency_graph::*; -pub use crate::public::machrc::*; -pub use crate::public::packages::*; -pub use crate::public::resolver::*; -pub use crate::public::transformer::*; diff --git a/crates/mach/src/transformation/mod.rs b/crates/mach/src/transformation/mod.rs deleted file mode 100644 index 1ed21475..00000000 --- a/crates/mach/src/transformation/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod transform; - -pub use crate::transformation::transform::*; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e0fed61a..a6ad631b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,7 +38,13 @@ importers: specifier: ^14.1.1 version: 14.1.1 - testing/fixtures/cjs-nested: + testing/fixtures/commonjs: + devDependencies: + http-server: + specifier: ^14.1.1 + version: 14.1.1 + + testing/fixtures/commonjs-nested: devDependencies: '@types/react': specifier: ^18.2.45 @@ -56,12 +62,6 @@ importers: specifier: ^18.2.0 version: 18.2.0(react@18.2.0) - testing/fixtures/commonjs: - devDependencies: - http-server: - specifier: ^14.1.1 - version: 14.1.1 - testing/fixtures/esm: devDependencies: http-server: