Skip to content

Commit

Permalink
feat(swc/cli): setup packages for binary
Browse files Browse the repository at this point in the history
- relates with swc-project#1589
  • Loading branch information
kwonoj committed Dec 19, 2021
1 parent 25a17e8 commit 3bd39cf
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 1 deletion.
113 changes: 112 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"crates/jsdoc",
"crates/node",
"crates/swc_cli",
"crates/swc_css",
"crates/swc_ecmascript",
"crates/swc_ecma_plugin_ast",
Expand Down
16 changes: 16 additions & 0 deletions crates/swc_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
description = "Commandline for swc"
name = "swc_cli"
version = "0.1.0"
edition = "2018"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
repository = "https://github.com/swc-project/swc.git"

[[bin]]
name = "swc"
path = "./src/main.rs"

[dependencies]
structopt = { version = "0.3.25", features = [ "paw" ] }
paw = "1.0"
36 changes: 36 additions & 0 deletions crates/swc_cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use std::path::PathBuf;

use structopt::StructOpt;

/// Transform, compile files.
#[derive(Debug, StructOpt)]
pub struct CompileCommand {
///Filename to use when reading from stdin - this will be used in
/// source-maps, errors etc
#[structopt(short = "f", long = "filename")]
file_name: String,
/// Path to a .swcrc file to use
#[structopt(parse(from_os_str), long = "config-file")]
config_file: PathBuf,
/// The name of the 'env' to use when loading configs and plugins.
/// Defaults to the value of SWC_ENV, or else NODE_ENV, or else
/// 'development'.
///
/// DEPRECATED: use --env flag instead.
#[structopt(long = "env-name")]
env_name: String,
}

#[derive(StructOpt, Debug)]
#[structopt(about = "Speedy Web Compiler")]
pub enum SwcCommand {
Compile(CompileCommand),
}

impl SwcCommand {
pub fn execute(self) {
match self {
SwcCommand::Compile(..) => {}
};
}
}
7 changes: 7 additions & 0 deletions crates/swc_cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mod cli;
use cli::SwcCommand;

#[paw::main]
fn main(_args: SwcCommand) {
unimplemented!("Not yet implemented");
}

1 comment on commit 3bd39cf

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 3bd39cf Previous: 25a17e8 Ratio
full_es2015 182299461 ns/iter (± 8454174) 212228240 ns/iter (± 13402065) 0.86
full_es2016 148956617 ns/iter (± 5268846) 171122089 ns/iter (± 8132561) 0.87
full_es2017 154073215 ns/iter (± 7646499) 176956616 ns/iter (± 10868566) 0.87
full_es2018 153649761 ns/iter (± 7578505) 182009461 ns/iter (± 14116946) 0.84
full_es2019 152282422 ns/iter (± 6306303) 178790557 ns/iter (± 13087427) 0.85
full_es2020 151772302 ns/iter (± 5921664) 176094444 ns/iter (± 12410554) 0.86
full_es3 209505400 ns/iter (± 10292911) 248924019 ns/iter (± 15435628) 0.84
full_es5 193253757 ns/iter (± 8006621) 228712871 ns/iter (± 17165264) 0.84
parser 693350 ns/iter (± 19589) 864849 ns/iter (± 99594) 0.80

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.