swc-project / swc

Rust-based platform for the Web
https://swc.rs
Apache License 2.0
30.41k stars 1.17k forks source link

Reimplement CLI in rust #1589

Open kdy1 opened 3 years ago

kdy1 commented 3 years ago

Node binding should export runCLI.

This would help lots of cases.

tmpfs commented 2 years ago

Hey @kdy1, I keep looking at the Typescript CLI entry points and wonder why they exist and it's not just straight Rust binaries using clap (or structopt).

Is there functionality that is enabled by having the command line programs exposed as node executables? Is it part of a plan for a Javascript-based plugin system maybe?

I just wanted to look into the reason why --ignore isn't working for example and it seems like it was never implemented from what I can tell. Implementing this would be much more straightforward if it was all just Rust :pray:

kdy1 commented 2 years ago

Is there functionality that is enabled by having the command line programs exposed as node executables? Is it part of a plan for a Javascript-based plugin system maybe?

No. It's because to make managing version more convenient for the end-user

tmpfs commented 2 years ago

Thanks, that helps! I will try to find some time to tackle this one as I think it would simplify things quite a bit - we should be able to remove quite a bit of typescript :+1:

I assume you would prefer to use clap over structopt?

kwonoj commented 2 years ago

It's quite late to realize but I forget js-side plugin support in @swc/cli. This may be some headache if we want 100% feature parity.

For now I'll skip those until new cli becomes stable enough. This is also related with experimental plugin stablization and may possible to think about whole plan accordingly based on those.

kwonoj commented 2 years ago

swc_cli is a ground to implement this. Roughly, these are the tasks need to be implemented and if anyone want to dive in, please feel free to send PR

  1. compile command
    • port rest of cli flag features in subcommand flag struct
    • watch mode implementation
  2. minify command
  3. lint command
  4. bundle command - accept JSON based configs

Currently, implementations are sort of exploration, does not have to be 1:1 match to existing @swc/cli's behavior. Specifically, there will be rough edges to deal with dynamic values which requires js runtime. We want to give suffecient time to iterate, finalize behaviors based on feedbacks & some constraints we have.

StemCll commented 11 months ago

Hi @kwonoj Is this PR still valid? If not, I'd like to work on this task setting up a new one.

stephanrotolante commented 3 months ago

Hey @kwonoj,

Is this still a good first issue? I am looking back at some of the PRs referenced in the ticket and am trying to get an understand at whats going on. I am still kind of unsure whats being asked.

If I had to guess its replace the entire nodejs cli into one thats a rust/node bind gen?