Skip to content

fix(cli): add normalization for camelCase long options in CLI arguments#8408

Closed
hyf0 wants to merge 1 commit intomainfrom
02-21-fix_cli_add_normalization_for_camelcase_long_options_in_cli_arguments
Closed

fix(cli): add normalization for camelCase long options in CLI arguments#8408
hyf0 wants to merge 1 commit intomainfrom
02-21-fix_cli_add_normalization_for_camelcase_long_options_in_cli_arguments

Conversation

@hyf0
Copy link
Member

@hyf0 hyf0 commented Feb 21, 2026

No description provided.

@hyf0 hyf0 marked this pull request as ready for review February 21, 2026 12:35
Copilot AI review requested due to automatic review settings February 21, 2026 12:35
Copy link
Member Author

hyf0 commented Feb 21, 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.

@netlify
Copy link

netlify bot commented Feb 21, 2026

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit c23a082
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6999c6297112600009a56caa
😎 Deploy Preview https://deploy-preview-8408--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the rolldown CLI argument parser by normalizing camelCase long options (e.g. --moduleTypes) into the canonical kebab-case form (e.g. --module-types) so they’re recognized consistently.

Changes:

  • Add an argv preprocessing step to convert camelCase --longOptions into kebab-case before node:util.parseArgs runs.
  • Add an e2e CLI test exercising camelCase object option parsing (--moduleTypes) and update snapshots accordingly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/rolldown/src/cli/arguments/index.ts Adds normalizeArgv and routes CLI args through it before parsing.
packages/rolldown/tests/cli/cli-e2e.test.ts Adds an e2e test covering --moduleTypes for object option parsing.
packages/rolldown/tests/cli/snapshots/cli-e2e.test.ts.snap Adds snapshot output for the new e2e test.

Comment on lines +64 to +76
return argv.map((arg) => {
// Only process long options (--option or --option=value)
if (!arg.startsWith('--')) return arg;
const eqIndex = arg.indexOf('=', 2);
if (eqIndex === -1) {
// --optionName → --option-name
return `--${camelCaseToKebabCase(arg.slice(2))}`;
}
// --optionName=value → --option-name=value
const name = arg.slice(2, eqIndex);
const value = arg.slice(eqIndex);
return `--${camelCaseToKebabCase(name)}${value}`;
});
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

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

normalizeArgv rewrites every --* token even after the -- end-of-options marker. That changes the contents of positional arguments that intentionally start with -- (e.g. rolldown -- --fooBar), which should be passed through verbatim. Consider switching to an index-based loop that stops normalizing once -- is encountered (or explicitly skips normalization for args after it).

Suggested change
return argv.map((arg) => {
// Only process long options (--option or --option=value)
if (!arg.startsWith('--')) return arg;
const eqIndex = arg.indexOf('=', 2);
if (eqIndex === -1) {
// --optionName → --option-name
return `--${camelCaseToKebabCase(arg.slice(2))}`;
}
// --optionName=value → --option-name=value
const name = arg.slice(2, eqIndex);
const value = arg.slice(eqIndex);
return `--${camelCaseToKebabCase(name)}${value}`;
});
const normalized: string[] = [];
let seenEndOfOptions = false;
for (const arg of argv) {
if (seenEndOfOptions) {
normalized.push(arg);
continue;
}
if (arg === '--') {
seenEndOfOptions = true;
normalized.push(arg);
continue;
}
// Only process long options (--option or --option=value)
if (!arg.startsWith('--')) {
normalized.push(arg);
continue;
}
const eqIndex = arg.indexOf('=', 2);
if (eqIndex === -1) {
// --optionName → --option-name
normalized.push(`--${camelCaseToKebabCase(arg.slice(2))}`);
continue;
}
// --optionName=value → --option-name=value
const name = arg.slice(2, eqIndex);
const value = arg.slice(eqIndex);
normalized.push(`--${camelCaseToKebabCase(name)}${value}`);
}
return normalized;

Copilot uses AI. Check for mistakes.
@hyf0 hyf0 force-pushed the 02-21-fix_cli_add_normalization_for_camelcase_long_options_in_cli_arguments branch from 363e90e to c23a082 Compare February 21, 2026 14:50
@hyf0 hyf0 closed this Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants