Skip to content

fix: keep multi-compiler options when --config-name or extends rebuild the configuration array - #4871

Merged
alexander-akait merged 1 commit into
mainfrom
fix/keep-multi-compiler-options
Oct 15, 2026
Merged

alexander-akait merged 1 commit into
mainfrom
fix/keep-multi-compiler-options

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Options for the whole MultiCompiler are set on the exported configuration array itself: parallelism, and plugins since webpack/webpack#22702 (which lets a plugin such as webpack-dev-server be applied once to the MultiCompiler). loadConfig rebuilds the array for --config-name, --extends and configurations using extends, and the rebuilt array lost those properties, so webpack silently fell back to the defaults. They are now copied over to the rebuilt array.

// webpack.config.js
module.exports = Object.assign([first, second], { parallelism: 1 });
Command Before After
webpack 1 compiler at a time 1 compiler at a time
webpack --config-name first --config-name second 2 at once 1 at a time
webpack -c ./extends.config.js (children use extends) 2 at once 1 at a time
webpack --extends ./base.config.js 2 at once 1 at a time

Checked against webpack/webpack#22702 too: on all those paths, plus arrays of config functions and a promise, a top-level plugin is applied once to the MultiCompiler.

Not covered: several -c files are concatenated into one new array, and there is no obvious rule to merge their array options, so they are still not carried over.

What kind of change does this PR introduce?

fix

Did you add tests for your changes?

Yes: test/build/multi-compiler-options/multi-compiler-options.test.js. A plugin in each child counts how many compilers run at once; parallelism is used because no released webpack has top-level plugins yet, and both take the same path. Three of the four cases fail without the fix.

Does this PR introduce a breaking change?

No.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

n/a

Use of AI

Written with Claude Code: it reproduced the dropped options with the real CLI, wrote the fix and the test, and checked it against the webpack branch, directed and reviewed by the author.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ML8tLtqrJohECUzhdBwqsw


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Preserved multi-compiler options, including parallelism and plugins, when selecting named configurations or resolving extended configurations.

@changeset-bot

changeset-bot Bot commented Oct 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: db8378d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
webpack-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

This PR is packaged and the instant preview is available (5d4e9e4).

Install it locally:

  • npm
npm i -D webpack-cli@https://pkg.pr.new/webpack-cli@5d4e9e4
  • yarn
yarn add -D webpack-cli@https://pkg.pr.new/webpack-cli@5d4e9e4
  • pnpm
pnpm add -D webpack-cli@https://pkg.pr.new/webpack-cli@5d4e9e4

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.84%. Comparing base (430bdd6) to head (db8378d).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4871      +/-   ##
==========================================
- Coverage   94.98%   94.84%   -0.14%     
==========================================
  Files          14       14              
  Lines        5598     5626      +28     
  Branches      840      841       +1     
==========================================
+ Hits         5317     5336      +19     
- Misses        280      289       +9     
  Partials        1        1              
Files with missing lines Coverage Δ
packages/webpack-cli/src/webpack-cli.ts 96.73% <100.00%> (+0.02%) ⬆️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 430bdd6...db8378d. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 91b7fe6b-91b4-4483-9f8b-110920b93726
📥 Commits

Reviewing files that changed from the base of the PR and between 430bdd6 and db8378d.

📒 Files selected for processing: 9
  • .changeset/keep-multi-compiler-options.md
  • packages/webpack-cli/src/webpack-cli.ts
  • test/build/multi-compiler-options/base.config.js
  • test/build/multi-compiler-options/concurrency-plugin.js
  • test/build/multi-compiler-options/extends.config.js
  • test/build/multi-compiler-options/multi-compiler-options.test.js
  • test/build/multi-compiler-options/src/first.js
  • test/build/multi-compiler-options/src/second.js
  • test/build/multi-compiler-options/webpack.config.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

loadConfig now preserves non-index properties when it rebuilds multi-compiler configuration arrays for named-configuration selection and extends. New integration tests check that the array-level parallelism option remains effective across default loading, repeated --config-name, configuration-level extends, and CLI --extends.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to db837

This patch preserves array-level options such as parallelism when webpack-cli rebuilds multi-compiler configurations. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preserving multi-compiler options when --config-name or extends rebuilds the configuration array.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 8…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@alexander-akait
alexander-akait merged commit 5d4e9e4 into main Oct 15, 2026
40 of 41 checks passed
@alexander-akait
alexander-akait deleted the fix/keep-multi-compiler-options branch October 15, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant