test(transformer): add test for string enum alias member#20652
Merged
graphite-app[bot] merged 1 commit intomainfrom Apr 13, 2026
Merged
test(transformer): add test for string enum alias member#20652graphite-app[bot] merged 1 commit intomainfrom
graphite-app[bot] merged 1 commit intomainfrom
Conversation
This was referenced Mar 23, 2026
Member
Author
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
5 tasks
9b82f47 to
687f71b
Compare
2ed8fb8 to
3874d8f
Compare
687f71b to
0bf9397
Compare
10 tasks
0bf9397 to
b491ac1
Compare
b491ac1 to
140947b
Compare
3874d8f to
54abab1
Compare
Member
Author
Merge activity
|
140947b to
d016ae2
Compare
54abab1 to
420f2bf
Compare
98c89b5 to
ff89f68
Compare
d016ae2 to
b87d3be
Compare
b87d3be to
d575d86
Compare
ff89f68 to
07d6574
Compare
d575d86 to
0197623
Compare
07d6574 to
8496bbe
Compare
## Summary - Add a conformance test for string enum alias members (e.g. `Default = Theme.Light`) covering both const and non-const enum cases - Verifies no incorrect reverse mapping is generated for string alias members (relates to rolldown/rolldown#8866) ## Test plan - `cargo run -p oxc_transform_conformance -- --filter enum-string-alias-member` passes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
8496bbe to
e7e1aea
Compare
0197623 to
995e13e
Compare
IWANABETHATGUY
pushed a commit
to rolldown/rolldown
that referenced
this pull request
Apr 15, 2026
## Summary Enable cross-module enum inlining by consuming pre-computed enum member values from oxc_semantic. **Depends on:** oxc-project/oxc#20652 closes #4342 ### What changed - **Extract enum values** from initial `Scoping` before the transformer converts enums to IIFEs/placeholders - **Store on `EcmaView`** as `enum_member_value_map` (name-keyed, survives transformer rewrites) - **Inline enum member accesses** in the scope hoisting finalizer: - `Direction.Up` → `0` (dot notation) - `Direction["Up"]` → `0` (bracket notation) - `ns.Direction.Up` → `0` (chained namespace access) - **Tree-shake dead enum declarations** when all references are inlined member accesses - Supports both `const enum` and regular `enum` when all members have statically known values - Enables oxc's `optimize_const_enums` and `optimize_enums` transformer options ### Architecture The enum inlining pipeline follows Rolldown's existing module processing stages: ``` ┌─ Scan Stage (per module) ──────────────────────────────────────────┐ │ │ │ pre_process_ecma_ast.rs │ │ ├─ Step 1: SemanticBuilder → Scoping │ │ ├─ Step 1.5: Extract enum_member_value_map from Scoping │ │ │ (before transformer destroys enum declarations) │ │ ├─ Step 3: Transformer (optimize_const_enums + optimize_enums) │ │ │ const enums → removed, regular enums → @__PURE__ IIFE │ │ └─ Returns ParseToEcmaAstResult { enum_member_value_map, ... } │ │ │ │ ecma_module_view_factory.rs │ │ ├─ AstScanner: scans AST for imports/exports/statements │ │ └─ enum_member_value_map stored directly on EcmaView │ │ (bypasses AstScanner — no symbol-level processing needed) │ │ │ └─────────────────────────────────────────────────────────────────────┘ ┌─ Link Stage ───────────────────────────────────────────────────────┐ │ │ │ include_statements.rs (tree-shaking) │ │ ├─ Computes has_enum_inlining once for the whole bundle │ │ └─ For member expr refs (e.g. B.member): │ │ if member exists in enum_member_value_map → skip including │ │ the enum declaration (it will be inlined, declaration is dead) │ │ │ │ has_enum_inlining stored on LinkStageOutput for generate stage │ │ │ └─────────────────────────────────────────────────────────────────────┘ ┌─ Generate Stage ───────────────────────────────────────────────────┐ │ │ │ ScopeHoistingFinalizer (impl_visit_mut.rs + mod.rs) │ │ ├─ visit_expression: try_inline_enum_access() before other │ │ │ member expr rewrites │ │ ├─ After namespace rewrite (ns.E → E): retry enum inlining │ │ └─ try_inline_enum_member_by_ref: canonical_ref → owner module │ │ → enum_member_value_map → literal value │ │ │ └─────────────────────────────────────────────────────────────────────┘ ``` ### Comparison with other tools | Feature | Rolldown (this PR) | esbuild | TypeScript (`tsc`) | |---|---|---|---| | Const enum inlining | Yes | Yes | Yes (same-file only with `--isolatedModules`) | | Regular enum inlining | Yes | Yes | No | | Cross-module const enum | Yes | Yes | No (with `--isolatedModules`) | | Optional chaining (`E?.X`) | No | No | No | | Computed access (`E["X"]`) | Yes | Yes | Yes | | Namespace chains (`ns.E.X`) | Yes | Yes | N/A | | Tree-shake dead enum decls | Yes | Yes | No | | Merged/sibling enums | Yes | Yes | Yes | ### Performance - `has_enum_inlining` flag computed once during link stage, reused by generate stage - Fast-path skip in visitor hot loop for enum-free bundles ## Test plan - [x] `ts_enum_cross_module_inlining_access` — direct + computed member access inlined - [x] `ts_enum_cross_module_inlining_edge_cases` — renamed re-exports, namespace re-exports, mixed value types, const vs regular - [x] `ts_enum_cross_module_inlining_definitions` — enum definitions handled correctly - [x] `ts_enum_cross_module_inlining_re_export` — chained `ns.Enum.Member` inlined - [x] `ts_enum_cross_module_tree_shaking` — dead enum declarations removed - [x] `ts_enum_same_module_inlining_access` — same-module accesses inlined - [x] `ts_const_enum_comments` — const enum member accesses inlined - [x] `ts_sibling_enum` — merged enum declarations resolved correctly - [x] `cross_module_constant_folding_*` — number, string, computed property name folding - [x] Full enum test suite: 15 passed, 0 failed ### Known limitations - Optional chaining on enums (`E?.X`) not inlined (matches esbuild behavior) - Comment annotations (`/* Direction.Up */`) on inlined values not yet implemented 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Default = Theme.Light) covering both const and non-const enum casesTest plan
cargo run -p oxc_transform_conformance -- --filter enum-string-alias-memberpasses🤖 Generated with Claude Code