Skip to content

fix: merge build.rolldownOptions.output.minify correctly - #23536

Merged
sapphi-red merged 4 commits into
vitejs:mainfrom
hktitof:fix/rolldown-output-minify-merge
Sep 30, 2026
Merged

sapphi-red merged 4 commits into
vitejs:mainfrom
hktitof:fix/rolldown-output-minify-merge

Conversation

@hktitof

@hktitof hktitof commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

What does this PR solve

setting build.rolldownOptions.output.minify overrode the whole value instead of being merged, the same bug output.comments had before #23514

with build.minify: 'oxc' on an es lib build vite resolves { compress: true, mangle: true, codegen: false }, the codegen guard is there to keep pure annotations so tree shaking keeps working. a partial user object like { mangle: { props: true } } replaced it wholesale and silently dropped that guard

the fix moves the resolved value after the user spread and merges it like comments already does, so a boolean still wins over the computed default and partial objects keep the defaults

Tests

added two tests to the existing resolveRolldownOptions block in build.spec.ts

merges a partial output.minify object with the lib defaults fails on main, the resolved minify comes back without compress and codegen, and passes with this change. keeps an explicit boolean output.minify untouched pins that a plain false still wins over the resolved default

all 70 tests in build.spec.ts pass

@github-actions github-actions Bot added the bot: maybe Maybe a bot, LLM, or agent label Sep 20, 2026
@hktitof
hktitof force-pushed the fix/rolldown-output-minify-merge branch from 836cb07 to c97929e Compare September 22, 2026 14:21
setting `build.rolldownOptions.output.minify` overrode the whole value
instead of being merged, so a partial object dropped the defaults vite
computes for es lib builds and lost the codegen: false guard that keeps
pure annotations intact for tree shaking

move the resolved value after the user spread and merge it like
output.comments, a boolean still wins over the computed default and
partial objects keep the defaults

same invariant as vitejs#23514, applied to output.minify
@hktitof
hktitof force-pushed the fix/rolldown-output-minify-merge branch from c97929e to a9764c2 Compare September 22, 2026 14:21
@sapphi-red sapphi-red added the p2-edge-case Bug, but has workaround or limited in scope (priority) label Sep 30, 2026
@sapphi-red
sapphi-red merged commit bba3bb8 into vitejs:main Sep 30, 2026
18 checks passed
@hktitof

hktitof commented Sep 30, 2026

Copy link
Copy Markdown
Contributor Author

thanks for the approval and the merge @sapphi-red, and for the test cleanups you pushed on the branch, the mangle keepNames value is the correct one and the non null output access reads better than the cast i had. the fix now keeps the resolved minify defaults before the spread and merges the user object on top so the codegen guard survives. happy to follow up if any other rolldown output option needs the same merge shape

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: maybe Maybe a bot, LLM, or agent p2-edge-case Bug, but has workaround or limited in scope (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants