Repository navigation
fix: evaluate banner/footer function addon per chunk - #1011
Merged
Merged
Conversation
The returned addon reassigned the `chunkAddon` parameter on its first call, caching the first chunk's result for every subsequent chunk. As a result the per-chunk `fileName` passed to the function was always the first chunk's name, and function addons returning a string produced the same output for all chunks.
✅ Deploy Preview for tsdown-main ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
tsdown
create-tsdown
@tsdown/css
@tsdown/exe
tsdown-migrate
commit: |
sxzz
approved these changes
Jul 11, 2026
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.
Description
resolveChunkAddonreturns anAddonFunctionthat Rolldown calls once per output chunk. Whenbanner/footeris a function, the closure reassigned its ownchunkAddonparameter with the first chunk's result:After the first chunk
chunkAddonis no longer a function, so it is never invoked again — every later chunk reuses the first chunk's value. This was harmless when the context was only{ format }, but oncefileNamewas added to the context (and string returns were allowed) it means:fileNamehanded to the function is always the first chunk's name, andFix: compute a local
resolvedvalue on each invocation instead of overwriting the parameter.Linked Issues
Additional context
Added a regression test that builds two entries with
banner/footerfunctions echoingfileName. Onmainthe second chunk gets the first chunk's banner/footer; with this fix each chunk gets its own.