feat!: refine bundler options#1714
Open
Mister-Hope wants to merge 2 commits into
Open
Conversation
This was referenced May 21, 2026
Coverage Report for CI Build 26201119905Coverage remained the same at 72.983%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
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.
Summary
Refine the
Bundlerinterface and bundler configuration hooks to give plugin authors the tools they need to configure bundler-specific behavior correctly and completely.Problems & Rationale
1. Complex comparison to identify the active bundler
Plugins in
extendsBundlerOptionsneed to know which bundler is active to add the right options (e.g.viteOptionsvschainWebpack). The only discriminator wasbundler.name, which is the full scoped package name.2. Missing merge helper in
extendsBundlerOptionsWhen a plugin accepts user bundler options and wants to merge them into the resolved options, it needs the correct merge function (
vite.mergeConfigvswebpack-mergediffer in semantics). The hook only passes(options, app)— no merge helper.We considered adding
mergeConfigas a hook parameter, but allextends*hooks share the uniform signature(extendable: T, app: App):Adding a third parameter would break this consistency. So
mergeConfigis exposed on theBundlerobject instead:export interface Bundler { name: string + type: string dev: (app: App) => Promise<() => Promise<void>> build: (app: App) => Promise<void> + mergeConfig: <Config extends Record<string, any>>( + currentConfig: Config, + newConfig: DeepPartial<Config>, + ) => Config }Plugins access it naturally:
app.options.bundler.mergeConfig(...).3.
configureWebpack/configureVitecannot remove array itemsThe old merge-on-return model was purely additive — array items could only be appended, never deleted.
Returning a value now fully replaces the config. To merge explicitly, use the
mergeConfigcallback parameter passed to the hook.Note: the
mergeConfigfrom vite always create a fresh new object at every level while merging.Breaking changes
Bundlerinterface now requirestypeandmergeConfig.configureWebpackreturn value replaces the config. Use the passedmergeConfigparameter to merge instead.