Skip to content

Vite 8 regression: string const enum with alias member produces wrong runtime value #21996

@elderapo

Description

@elderapo

Vite 8 (rolldown) emits incorrect code for string const enum with alias members. The same code works correctly with Vite 7 (esbuild).

export const enum Theme {
  Light = "Light",
  Dark = "Dark",
  Default = Theme.Light,
}
console.log(Theme.Light); // Vite 7: "Light" ✓ | Vite 8: "Default" ✗

Rolldown emits a numeric-style reverse mapping (e[e.Default = e.Light] = "Default") that overwrites the forward mapping. TypeScript never generates reverse mappings for string enums.

Repro: https://github.com/elderapo/vite8-const-enum-bug

npm install && npm run build && node dist/main.js

Upstream: rolldown/rolldown#8866

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug: upstreamBug in a dependency of Vitehas workaroundp2-edge-caseBug, but has workaround or limited in scope (priority)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions