Rolldown emits a numeric-style reverse mapping for string enum alias members, which corrupts the enum object at runtime.
Input
export const enum Theme {
Light = "Light",
Dark = "Dark",
Default = Theme.Light,
}
console.log(Theme.Light); // expected: "Light"
console.log(Theme.Default); // expected: "Light"
Rolldown output (incorrect)
e.Light = "Light", e.Dark = "Dark", e[e.Default = e.Light] = "Default"
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// reverse mapping overwrites e.Light from "Light" to "Default"
esbuild output (correct)
O.Light = "Light", O.Dark = "Dark", O.Default = "Light"
Result
Theme.Light evaluates to "Default" instead of "Light". TypeScript never generates reverse mappings for string enums — only for numeric ones.
Reproduction
https://github.com/elderapo/vite8-const-enum-bug
npm install && npm run build && node dist/main.js
Versions
- vite 8.0.1 (bundled rolldown)
- typescript 5.9.3
Rolldown emits a numeric-style reverse mapping for string enum alias members, which corrupts the enum object at runtime.
Input
Rolldown output (incorrect)
esbuild output (correct)
Result
Theme.Lightevaluates to"Default"instead of"Light". TypeScript never generates reverse mappings for string enums — only for numeric ones.Reproduction
https://github.com/elderapo/vite8-const-enum-bug
Versions