Built-in `showUsage` is not tree-shaking, when put custom `showUsage` at `runMain`.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.3k
- Forks
- 58
- PR merge metrics
- No merged PRs in 30d
Description
Environment
npm -v
9.3.0
node -v
v18.19.1
Reproduction
repo
https://github.com/kazupon/citty-repro1
step to reproduction
# install
npm install
# build
npm run build
> citty-repro1@0.0.0 build
> unbuild
ℹ Building citty-repro1
ℹ Cleaning dist directory: ./dist
✔ Build succeeded for citty-repro1
dist/cli.cjs (total size: 29.3 kB, chunk size: 29.3 kB, exports: showUsage)
📦 node_modules/citty/dist/index.mjs (14 kB)
📦 node_modules/consola/dist/core.mjs (9.79 kB)
📦 node_modules/consola/dist/utils.mjs (2.79 kB)
📦 node_modules/consola/dist/browser.mjs (1.75 kB)
dist/cli.mjs (total size: 28.9 kB, chunk size: 28.9 kB, exports: showUsage)
📦 node_modules/citty/dist/index.mjs (14 kB)
📦 node_modules/consola/dist/core.mjs (9.79 kB)
📦 node_modules/consola/dist/utils.mjs (2.75 kB)
📦 node_modules/consola/dist/browser.mjs (1.75 kB)
Σ Total dist size (byte size): 58.2 kB
# grep built-in `showUsage`
cat dist/cli.mjs | grep showUsage\$1
async function showUsage$1(cmd, parent) {
const showUsage$1$1 = opts.showUsage || showUsage$1;
await showUsage$1$1(...await resolveSubCommand(cmd, rawArgs));
await showUsage$1$1(...await resolveSubCommand(cmd, rawArgs));
Describe the bug
Built-in showUsage and renderUsage are not tree-shaking, when put custom showUsage at runMain.
Additional context
related issue (comment)
https://github.com/rolldown/rolldown/pull/754#pullrequestreview-1981812870
As additional information, my use-case that citty is bundled with unbuild.
Logs
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the linked citty-repro1 steps and inspect the generated dist/cli.mjs output. Then trace runMain and the built-in showUsage/renderUsage exports; done means a custom showUsage passed to runMain allows unused built-ins to be removed from the bundle without changing the CLI behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100