Skip to content

refactor(cli): migrate CLI to CAC#8551

Merged
graphite-app[bot] merged 1 commit intomainfrom
refactor_cli_migrate_cli_to_CAC
Mar 7, 2026
Merged

refactor(cli): migrate CLI to CAC#8551
graphite-app[bot] merged 1 commit intomainfrom
refactor_cli_migrate_cli_to_CAC

Conversation

@h-a-n-a
Copy link
Member

@h-a-n-a h-a-n-a commented Mar 5, 2026

Summary

Replace Node.js's built-in parseArgs with cac for CLI argument parsing.

Fixes: #8410 (camelCase options like --moduleTypes silently ignored), #3248 (-s inline position restriction), #8523 (--help precedence over other options)

Changes

  • Rewrite cli/arguments/index.ts — replace parseArgs + 16 hand-rolled workarounds with cac setup and a focused post-processing pipeline
  • Simplify cli/arguments/alias.ts — remove dead default field
  • Simplify cli/arguments/utils.ts — remove kebabCaseToCamelCase (cac handles this)
  • Add CLI e2e tests for --help precedence (The --help flag should take precendence #8523), camelCase options (Using CLI framework to replace current raw parseArgs #8410), config override, -c -w interaction, and more
  • Add meta/design/cli.md documenting the CLI architecture

What cac gives us

  • camelCase/kebab-case interchangeable matching (--moduleTypes and --module-types both work)
  • --no-* negation, <required>/[optional] value validation, dot-notation nesting, short flag stacking
  • ~130 lines removed, 10 of 16 workarounds eliminated

Related issues

fixes #8410
fixes #3248
fixes #8523
fixes #8524

Copy link
Member Author

h-a-n-a commented Mar 5, 2026


How to use the Graphite Merge Queue

Add the label graphite: merge-when-ready to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@socket-security
Copy link

socket-security bot commented Mar 5, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcac@​6.7.1410010010089100

View full report

@h-a-n-a h-a-n-a force-pushed the refactor_cli_migrate_cli_to_CAC branch from 99e687e to d04fd7f Compare March 5, 2026 11:42
@h-a-n-a h-a-n-a force-pushed the 03-05-test_cli_add_more_cli-e2e_test_cases branch from bc9bf0f to 044d84d Compare March 5, 2026 14:42
@h-a-n-a h-a-n-a force-pushed the refactor_cli_migrate_cli_to_CAC branch 4 times, most recently from f30f32a to 1f99392 Compare March 6, 2026 07:24
@h-a-n-a h-a-n-a marked this pull request as ready for review March 6, 2026 07:26
@h-a-n-a h-a-n-a force-pushed the refactor_cli_migrate_cli_to_CAC branch from 1f99392 to 2eb5d34 Compare March 6, 2026 07:27
@h-a-n-a h-a-n-a requested review from IWANABETHATGUY and hyf0 March 6, 2026 07:31
@h-a-n-a h-a-n-a force-pushed the refactor_cli_migrate_cli_to_CAC branch 4 times, most recently from eca3767 to 4729978 Compare March 6, 2026 07:38
@IWANABETHATGUY
Copy link
Member

Overall, it looks good to me. One thing I am wondering is whether we need to support those nested flags like (checks, transform). Those flags are usually rarely used in CLI (I guess), but they contribute quite a bit to the length of the help message.

@h-a-n-a
Copy link
Member Author

h-a-n-a commented Mar 6, 2026

Overall, it looks good to me. One thing I am wondering is whether we need to support those nested flags like (checks, transform). Those flags are usually rarely used in CLI (I guess), but they contribute quite a bit to the length of the help message.

I was thinking about the same thing if we don't need to align them all with rollup
and it will definitely cause a breaking change.

What is your opinion? cc @hyf0 @shulaoda

@hyf0 hyf0 requested a review from sapphi-red March 6, 2026 15:27
Copy link
Member

@hyf0 hyf0 left a comment

Choose a reason for hiding this comment

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

No negative points. Let's merge it first, if there're adjustments we need to do, we could just do them in later PRs.

@h-a-n-a h-a-n-a force-pushed the 03-05-test_cli_add_more_cli-e2e_test_cases branch from 044d84d to 427a798 Compare March 7, 2026 06:04
@h-a-n-a h-a-n-a force-pushed the refactor_cli_migrate_cli_to_CAC branch from 4729978 to 18ebcf0 Compare March 7, 2026 06:04
@h-a-n-a h-a-n-a force-pushed the refactor_cli_migrate_cli_to_CAC branch from 18ebcf0 to eebf661 Compare March 7, 2026 06:24
@graphite-app graphite-app bot changed the base branch from 03-05-test_cli_add_more_cli-e2e_test_cases to graphite-base/8551 March 7, 2026 06:39
graphite-app bot pushed a commit that referenced this pull request Mar 7, 2026
## New CLI e2e test cases

- `--version` and `-v`
- `--help` and `-h`
- Unrecognized options warn but do not error
- CLI options override config values (`--format cjs` overrides config `format: "esm"`)

## Other

- Add `test:cli` script to `packages/rolldown/tests/package.json`
- Add design doc `meta/design/cli.md` for CLI refactor (#8410)

## Design doc

Refer to the second PR for the finalized design doc #8551
Design doc in the PR is just used for migration.
@graphite-app graphite-app bot force-pushed the refactor_cli_migrate_cli_to_CAC branch from eebf661 to d87b38d Compare March 7, 2026 06:47
@graphite-app graphite-app bot force-pushed the graphite-base/8551 branch from 84f4f79 to 80fcfea Compare March 7, 2026 06:47
@graphite-app graphite-app bot changed the base branch from graphite-base/8551 to main March 7, 2026 06:48
@graphite-app graphite-app bot force-pushed the refactor_cli_migrate_cli_to_CAC branch from d87b38d to bf52dee Compare March 7, 2026 06:48
@netlify
Copy link

netlify bot commented Mar 7, 2026

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 6e41800
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69abcc8e590bef0008c3c1b3

@graphite-app
Copy link
Contributor

graphite-app bot commented Mar 7, 2026

Merge activity

## Summary

Replace Node.js's built-in `parseArgs` with [cac](https://github.com/cacjs/cac) for CLI argument parsing.

**Fixes:** #8410 (camelCase options like `--moduleTypes` silently ignored), #3248 (`-s inline` position restriction), #8523 (`--help` precedence over other options)

## Changes

- Rewrite `cli/arguments/index.ts` — replace `parseArgs` + 16 hand-rolled workarounds with cac setup and a focused post-processing pipeline
- Simplify `cli/arguments/alias.ts` — remove dead `default` field
- Simplify `cli/arguments/utils.ts` — remove `kebabCaseToCamelCase` (cac handles this)
- Add CLI e2e tests for `--help` precedence (#8523), camelCase options (#8410), config override, `-c -w` interaction, and more
- Add `meta/design/cli.md` documenting the CLI architecture

## What cac gives us

- camelCase/kebab-case interchangeable matching (`--moduleTypes` and `--module-types` both work)
- `--no-*` negation, `<required>`/`[optional]` value validation, dot-notation nesting, short flag stacking
- ~130 lines removed, 10 of 16 workarounds eliminated

## Related issues

fixes #8410
fixes #3248
fixes #8523
fixes [#8524](#8524)
@graphite-app graphite-app bot force-pushed the refactor_cli_migrate_cli_to_CAC branch from bf52dee to 6e41800 Compare March 7, 2026 06:58
@graphite-app graphite-app bot merged commit 6e41800 into main Mar 7, 2026
36 checks passed
@graphite-app graphite-app bot deleted the refactor_cli_migrate_cli_to_CAC branch March 7, 2026 07:07
@github-actions github-actions bot mentioned this pull request Mar 9, 2026
shulaoda added a commit that referenced this pull request Mar 9, 2026
## [1.0.0-rc.8] - 2026-03-09

### 🚀 Features

- watch: enable full functional fs watcher in wasm (#8575) by @hyf0
- watch: expose debounce related options (#8572) by @hyf0

### 🐛 Bug Fixes

- detect new URL(…, import.meta.url) with no-sub template literal (#8565) by @char
- devtools: trace dynamic imports in devtools (#8581) by @cal-gooo
- watch: rebuild when a previously missing file is created (#8562) by @hyf0-agent
- watch: filter out Access events to prevent infinite rebuild loop on Linux (#8557) by @hyf0-agent

### 🚜 Refactor

- watch: remove auto watch for fail imports (#8585) by @hyf0
- fs_watcher: unify the way of constructing watcher (#8571) by @hyf0
- cli: migrate CLI to CAC (#8551) by @h-a-n-a
- switch asset module support from hard-code to builtin plugin (#8546) by @hyf0

### 📚 Documentation

- fix subject-verb agreement in why-bundlers.md (#8591) by @brandonzylstra
- maintenance: align release and canary workflow guide (#8538) by @minsoo-web
- add `format` option to directives example config (#8590) by @shulaoda
- fix: change twitter to x logo in team (#8552) by @mdong1909
- correct composable filter support explanation (#8550) by @sapphi-red

### ⚡ Performance

- testing: share tokio runtime across fixture tests (#8567) by @Boshen

### 🧪 Testing

- hmr: fix infinite loop in dev server test retry logic (#8576) by @hyf0-agent
- cli: add more cli-e2e test cases (#8548) by @h-a-n-a

### ⚙️ Miscellaneous Tasks

- docs: update in-depth/directives for `output.strict` option (#8535) by @minsoo-web
- add PNPM_HOME Dev Drive mapping to Windows CI workflows (#8589) by @Boshen
- deps: update github-actions (#8588) by @renovate[bot]
- move Windows cargo target dir to Dev Drive (#8586) by @Boshen
- optimize cache keys to fix race conditions and reduce usage (#8578) by @Boshen
- remove WASI build & test pipeline (#8580) by @Boshen
- remove unnecessary submodule checkouts (#8577) by @Boshen
- use Dev Drive for Windows CI jobs (#8574) by @Boshen
- skip redundant native binding build for browser and remove standalone job (#8573) by @Boshen
- parallelize Node tests on ubuntu, single Node 24 on macOS/windows (#8570) by @Boshen
- docs: bump @voidzero-dev/vitepress-theme to 4.8.0 (#8558) by @crusty-voidzero
- dedupe type-check from dev server workflow (#8554) by @Boshen

### ❤️ New Contributors

* @brandonzylstra made their first contribution in [#8591](#8591)
* @char made their first contribution in [#8565](#8565)
* @cal-gooo made their first contribution in [#8581](#8581)
* @hyf0-agent made their first contribution in [#8562](#8562)
* @h-a-n-a made their first contribution in [#8551](#8551)

Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants