Repository navigation
fix: keep a declaration's name when it clashes with an external import - #11052
Conversation
Since rolldown#3082 the esm external import bindings were named before the modules' top-level symbols, so a local sharing a name with an external import got the `$1` suffix and the import kept the name. Rollup and esbuild do the reverse, and the entry case only looked right because entry exports are pre-claimed. The two esbuild fixtures now match esbuild's own expected output for those tests. Fixes rolldown#11035
…declarations Apply the same priority to the iife/umd/cjs external namespaces, which lets `collect_chunk_scope_captured_names` read original names like it already does for wrappers and drop its renamer parameter. Import bindings read through a namespace (`ns.prop`) and `require()` results inside a CJS closure are never declared at the chunk root, so they no longer reserve a root name; they only ever pushed a real binding to a suffix.
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
…e's own declarations" This reverts commit d187503. An ESM entry that re-exports a named import of a CommonJS module declares that import at the top level, so its name must stay reserved. Without the reservation, `export { for } from './dep.js'` printed `var for = import_dep.for;`.
…wn#11122 fixture Entry exports are named before the modules' declarations, and external import bindings after them. So entry_renamed_binding_avoids_own_nested_binding re-exports `other.js`'s `join` from the entry: the entry's own `join` is then renamed and must skip the parameter `join$1`. internal-docs/renaming/implementation.md lists the external import bindings after the declarations.
✅ Deploy Preview for rolldown-rs canceled.
|
|
Sorry for the wait. I reverted the second commit, so this PR lands the first commit's fix, plus a doc and fixture update. The second commit stops reserving top-level names for imports read through a namespace. But an ESM entry that re-exports a CommonJS named import declares such an import at the top level. With that commit, |
## [1.3.1] - 2026-11-09 ### 🚀 Features - inline-common-chunks: inline chunks using `import.meta.ROLLDOWN_FILE_URL_*` (#11543) by @mattlewis92 ### 🐛 Bug Fixes - cli: apply --environment before loading the binding (#11553) by @Brooooooklyn - rolldown_plugin_vite_resolve: escape module names in generated error stubs (#11584) by @sapphi-red - add the code location to transform logs and errors at position 0 (#11568) by @chinmayajha - match sticky regexes only at the start of the string (#11569) by @chinmayajha - iife/umd: skip namespace markers when the entry has no exports (#11567) by @lazerg - keep a declaration's name when it clashes with an external import (#11052) by @Nic-Polumeyv - drop top-level statements made dead by imported constants before chunk linking (#11053) by @elliott-with-the-longest-name-on-github - keep `this.resolve` custom options apart for overlapping calls (#11505) by @wan9chi - transform: reuse TsconfigCache's answer when no tsconfig owns the file (#11265) by @sarankumar1325 - treat top-level `this` of a required module without module syntax as its exports (#11271) by @sarankumar1325 - keep side effects of a module whose exported constant is inlined (#11440) by @hyfdev - leave same-chunk dynamic imports out of `dynamicImports` (#11156) by @kkkhs ### 🚜 Refactor - prepend transferred imports as AST fragments (#11464) by @Dunqing ### 📚 Documentation - show `vp` first in setup commands (#11503) by @IWANABETHATGUY ### ⚡ Performance - incremental: reuse link-time facade symbols across rebuilds (#11542) by @mattlewis92 - incremental: share module sourcemap chains across cache clones (#11540) by @mattlewis92 - chunk_optimizer: answer runtime-merge reachability from one chunk-level graph (#11541) by @mattlewis92 - send only changed chunk properties back to Rust from output hooks (#11488) by @anonrig ### 🧪 Testing - remove review fixtures committed by mistake in #11052 (#11574) by @hyfdev - wasi: cover raw context destruction (#11561) by @Brooooooklyn ### ⚙️ Miscellaneous Tasks - deps: update rust crates (#11573) by @renovate[bot] - deps: update mimalloc-safe to 0.1.70 (#11589) by @shulaoda - renovate: update GitHub Actions that are pinned to a commit (#11583) by @hyfdev - skip Playwright browser downloads in Prepare Release (#11579) by @shulaoda - pin the rolldown crates to exact versions of each other on release (#11577) by @shulaoda - update `CodSpeedHQ/action` to v5.6.3 for Ubuntu 26.04 (#11575) by @hyfdev - remove stale entries from `.typos.toml` (#11571) by @iiio2 - pick the Prepare Release target branch from the version (#11525) by @shulaoda - run every OS on pushes to maintenance branches (#11520) by @shulaoda - rebase maintenance Vite branches onto their Vite minor (#11515) by @shulaoda - run CI on pushes to maintenance branches (#11516) by @shulaoda - support patch releases from maintenance branches (#11393) by @shulaoda ### ❤️ New Contributors * @chinmayajha made their first contribution in [#11568](#11568) * @lazerg made their first contribution in [#11567](#11567) * @elliott-with-the-longest-name-on-github made their first contribution in [#11053](#11053) * @sarankumar1325 made their first contribution in [#11265](#11265) * @anonrig made their first contribution in [#11488](#11488) * @kkkhs made their first contribution in [#11156](#11156) Co-authored-by: shulaoda <[email protected]>
In ESM output, when a module's top-level declaration and an external import had the same name, rolldown renamed the declaration and kept the name for the import.
This PR renames the import instead, as Rollup does.
Before:
After:
The renamed declaration showed up where its name is visible: the
.nameof a class or function, and type names in.d.tsoutput from rolldown-plugin-dts.The renamer now names external import bindings after the modules' declarations, instead of together with the entry's exports.
CommonJS, IIFE and UMD output does not change.
Fixes #11035.