Skip to content

bundler: rename esm top-level vars that collide with host globals - #35617

Closed
robobun wants to merge 4 commits into
mainfrom
farm/03d315b3/bundler-esm-global-shadow
Closed

robobun wants to merge 4 commits into
mainfrom
farm/03d315b3/bundler-esm-global-shadow

narrow reserve loop to browser target, VarScoped kinds, non-CJS modules

5c3b604
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jul 25, 2026 in 24m 42s

Code review found 2 potential issues

Found 3 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 2
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit src/bundler/linker_context/renameSymbolsInChunk.rs:146-148 Bug history embedded in code comment
🟡 Nit src/bundler/linker_context/renameSymbolsInChunk.rs:171-178 Reservation matches! misses TsEnum/TsNamespace and ESM-hoisted Class kinds

Annotations

Check warning on line 148 in src/bundler/linker_context/renameSymbolsInChunk.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Bug history embedded in code comment

The parenthetical "(Chart.js's `const getComputedStyle = …` recurses into itself via `defaultView.getComputedStyle`; #14110)" is bug history that already lives verbatim in the PR description — REVIEW.md's comment rule says bug history belongs there, not in code. The gating rationale (why `target=browser`, why skip `WrapKind::Cjs`, which symbol kinds) is durable design content and should stay; only the Chart.js/#14110 sentence needs trimming.

Check warning on line 178 in src/bundler/linker_context/renameSymbolsInChunk.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

Reservation matches! misses TsEnum/TsNamespace and ESM-hoisted Class kinds

The `matches!` misses two symbol kinds that also print as chunk-top-level `var`: (1) `TsEnum`/`TsNamespace` — a top-level `enum Event {…}` or `namespace URL {…}` emits `var Event;` via `generate_closure_for_type_script_namespace_or_enum` (p.rs:6108) while keeping kind `TsEnum`/`TsNamespace`; (2) `Class` in `WrapKind::Esm` modules — a non-movable class (`extends`, decorators, static block, computed key; `G::Class::can_be_moved`, g.rs:85) is hoisted to `var ClassName;` at `OutsideWrapperPrefix` (g