Skip to content

fix(mangler): upper-case JSX component names#21028

Open
gthb wants to merge 3 commits intooxc-project:mainfrom
gthb:fix-component-name-capitalization
Open

fix(mangler): upper-case JSX component names#21028
gthb wants to merge 3 commits intooxc-project:mainfrom
gthb:fix-component-name-capitalization

Conversation

@gthb
Copy link
Copy Markdown

@gthb gthb commented Apr 4, 2026

What

Ensure mangled JSX component names start with an upper-case letter. In JSX, <e /> is an HTML element while <E /> is a component, so changing a component's name changes its meaning.

Fixes #13248

How

Add base54_upper_first(), a name generator that uses upper-case letters for the first character and the full BASE54_CHARS for subsequent characters.

If the source type is JSX, walk resolved references to find symbols whose parent node is JSXOpeningElement or JSXClosingElement. Partition the frequency table into a regular pool (using base54) and a JSX pool (using base54_upper_first).

For non-JSX ones (.js, .mjs, .ts) just skip that component symbol scan.

Extract reserved-name generation and assignment loops to their own functions.

What
---

Ensure mangled JSX component names start with an upper-case letter. In JSX,
`<e />` is an HTML element while `<E />` is a component, so changing a
component's name changes its meaning.

Fixes oxc-project#13248

How
---

Add `base54_upper_first()`, a name generator that uses upper-case letters for
the first character and the full `BASE54_CHARS` for subsequent characters.

If the source type is JSX, walk resolved references to find symbols whose
parent node is `JSXOpeningElement` or `JSXClosingElement`. Partition the
frequency table into a regular pool (using `base54`) and a JSX pool (using
`base54_upper_first`).

For non-JSX ones (`.js`, `.mjs`, `.ts`) just skip that component symbol scan.

Extract reserved-name generation and assignment loops to their own functions.
@github-actions github-actions bot added A-minifier Area - Minifier C-bug Category - Bug labels Apr 4, 2026
@gthb
Copy link
Copy Markdown
Author

gthb commented Apr 4, 2026

Used AI for an initial stab at this, then reviewed and iterated plenty, then squashed to spare you the commit noise.

gthb added 2 commits April 4, 2026 09:33
... and avoid the em-dashes which LLMs have induced everyone to revile
Mangling is deterministic, so assert the specific names rather than
just checking originals are absent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minifier C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

minifier: Minifying JSX with mangle.toplevel breaks component name capitalization

1 participant