fix: reset variable render names between outputs in the same generate#6350
Merged
lukastaegert merged 2 commits intoApr 18, 2026
Merged
Conversation
When the same input bundle is generated for multiple outputs in one `output` array, `Variable.renderBaseName` set during a chunked output's import deconfliction (e.g. `vendor` for `_` imported from a chunk) was left on the shared `Variable` instance. The next output's `deconflictTopLevelVariables` then skipped that variable because of the existing `renderBaseName`, so the function declaration was rendered as `function vendor._(...)` — invalid JavaScript. Reset `renderBaseName`/`renderName` for the chunk's top-level variables at the start of `setIdentifierRenderResolutions`, before either the exports loop or `deconflictChunk` reassigns them.
|
@barry3406 is attempting to deploy a commit to the rollup-js Team on Vercel. A member of the Team first needs to authorize it. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6350 +/- ##
=======================================
Coverage 98.78% 98.78%
=======================================
Files 274 274
Lines 10788 10791 +3
Branches 2881 2881
=======================================
+ Hits 10657 10660 +3
Misses 89 89
Partials 42 42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
lukastaegert
approved these changes
Apr 18, 2026
lukastaegert
left a comment
Member
There was a problem hiding this comment.
Sorry for missing this, this looks like a really nice fix. Will merge and release it once pipelines agree.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This PR has been released as part of rollup@4.60.2. You can test it via |
Closed
4 tasks
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.
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Fixes #6296
Description:
When the same input bundle is generated for multiple outputs in a single
outputarray,Variable.renderBaseNameset during one output's import deconfliction was left on the sharedVariableinstance and leaked into the next output.Concretely: generating a chunked CJS output calls
deconflictImportsOther, which setssetRenderNames(chunk.variableName, exportName)on imported variables — so a function_imported from avendorchunk ends up withrenderBaseName='vendor',renderName='_'. The state lives on the sharedVariableinstance, not on a per-output structure. When the next output (UMD) goes throughdeconflictTopLevelVariables, the!variable.renderBaseNameskip leaves the stalevendorin place, and the local function declaration ends up rendered asfunction vendor._(...)— invalid JavaScript.Fix: reset
renderBaseName/renderNametonullfor top-level variables of the chunk's modules at the start ofsetIdentifierRenderResolutions, before either the exports loop ordeconflictChunkreassigns them. Each output then starts from a clean slate.Added a regression test in
test/misc/misc.jsthat exercises the exact scenario from #6296: a single bundle generated as both chunked CJS (with avendormanualChunk) and UMD, asserting the UMD output contains no dotted function declarations and is parseable as valid JavaScript.