Skip to content

Conversation

@avivkeller
Copy link
Member

This PR consolidates @webpack-cli/serve and @webpack-cli/configtest into webpack-cli (a single package), and simplifies a lot of the logic regarding loading these packages and their options (instead relying on Commander's built-in methods, i.e. help and action, etc)

Fixes #4619


I tried my best to limit the breaking changes (since, the less breakage the better), however, note the following:

Breaking: -v and --version are no no-op. The version command, however, is an alias of info (has not changed).1

Semi-Breaking: The format and styling of several error/help outputs has changed, as these are now handled by Commander, rather than custom logic.

Semi-Breaking: The IWebpackCLI object has been removed, since it began to differ from the actual implementation.1

Footnotes

  1. These breaking changes can be reverted. 2

@avivkeller avivkeller requested a review from a team as a code owner January 27, 2026 20:26
Copilot AI review requested due to automatic review settings January 27, 2026 20:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR consolidates the separate @webpack-cli/configtest, @webpack-cli/info, and @webpack-cli/serve packages into the core webpack-cli package and reworks how commands/options are wired up by delegating more behavior to Commander. It also updates the CLI API surface (e.g., makeCommand/makeOption), changes version/help behavior, and removes now-redundant sub-packages and tests.

Changes:

  • Inline configtest, info, and serve into webpack-cli’s main CLI implementation (webpack-cli.ts), with new Commander-based command/option registration and argument processing.
  • Simplify and refactor CLI types and bootstrap logic, remove the legacy IWebpackCLI interface, and adjust logging, option construction, and info/version behavior.
  • Remove the now-obsolete @webpack-cli/{configtest,info,serve} packages, update the monorepo/package references accordingly, and drop legacy help/version test suites in favor of the new command wiring.

Reviewed changes

Copilot reviewed 30 out of 31 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tsconfig.json Removes project references to the deprecated configtest, info, and serve sub-packages, reflecting their inlining into webpack-cli.
packages/webpack-cli/src/types.ts Cleans up CLI types (removing IWebpackCLI, external-command types, ParseOptions re-export), tightens WebpackCLIOptions to Commander-centric usage, and updates LogHandler and built-in option metadata (hidden flag).
packages/webpack-cli/src/webpack-cli.ts Major refactor: configures Commander output/exit behavior, centralizes logger creation, unifies built-in/core options via makeOption/getBuiltInOptions, introduces processArguments, and inlines build, watch, configtest, serve, and info/version commands directly into run().
packages/webpack-cli/src/bootstrap.ts Simplifies bootstrap to construct WebpackCLI directly, updates run parameter typing, and adds a small dev-only auto-run hook for npm_lifecycle_script === "tsx".
packages/webpack-cli/src/index.ts Re-exports the main CLI class and types from webpack-cli.ts, maintaining CommonJS compatibility while moving toward a default export pattern.
packages/webpack-cli/package.json Drops dependencies on @webpack-cli/configtest, @webpack-cli/info, and @webpack-cli/serve now that their functionality lives in webpack-cli proper.
packages/serve/* Removes the @webpack-cli/serve package (source, tsconfig, README, changelog) now superseded by the built-in serve command.
packages/info/* Removes the @webpack-cli/info package (source, tsconfig, README, changelog) in favor of an integrated info/version command in webpack-cli.
packages/configtest/* Removes the @webpack-cli/configtest package (source, tsconfig, README, changelog) now handled by the internal configtest command.
packages/README.md Updates package list documentation to reflect removal of the separate configtest, info, and serve sub-packages.
.cspell.json Switches to useGitignore: true and trims custom ignore paths, relying more on .gitignore for spell-check exclusions.
test/version/basic.test.js Removes tests for version/v/--version behavior that previously aliased to info, consistent with the breaking change that -v/--version are now no-ops and version aliases info.
test/version/additional-package.test.js Drops coverage around version --additional-package in favor of the new integrated info/version behavior.
test/version/output.test.js Removes tests for output-formatting flags on the old version command, to be superseded by behavior on the unified info/version command.
test/help/help.test.js & test/help/__snapshots__/help.test.js.snap.* Deletes a large suite of bespoke help-behavior tests/snapshots (global and per-command help, --help verbose, error cases), reflecting the migration to Commander’s built-in help handling.
test/build/unknown/__snapshots__/unknown.test.js.snap.webpack5 Updates expected stderr output format for unknown command/option cases to match Commander’s new messages (e.g., (Did you mean --entry?), new color escape sequences, and reworded unknown-command text).
test/build/basic/basic.test.js Adjusts assertions for unknown-command suggestions to align with the new error wording emitted by Commander-backed parsing (e.g., "Unknown command 'buil'" and (Did you mean build?)).
test/api/__snapshots__/CLI.test.js.snap.webpack5 Removes the snapshot for the “custom help output” test, which is no longer valid under the new Commander-centered help implementation.
test/api/CLI.test.js Reworks the CLI API tests to target the new makeCommand and makeOption signatures/behavior, including complex option shapes (configs, enums, multi-type options, negative flags), and drops the old “custom help output” test suite.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +178 to +181
warn: (val, raw) => log("warn", this.colors.red(util.format(val)), raw),
info: (val, raw) => log("info", this.colors.red(util.format(val)), raw),
success: (val, raw) => log("log", this.colors.red(util.format(val)), raw),
log: (val, raw) => log("error", this.colors.red(util.format(val)), raw),
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated logger implementation now colors all message types (including warn, info, and success) in red and routes log messages through the error method, which will send them to stderr instead of stdout. This is likely unintended, regresses the previous behavior where different severities used distinct colors, and can break tooling that distinguishes normal output from errors. Please restore distinct colors for each severity and have log use a non-error channel (e.g. console.log/stdout) rather than the error path.

Suggested change
warn: (val, raw) => log("warn", this.colors.red(util.format(val)), raw),
info: (val, raw) => log("info", this.colors.red(util.format(val)), raw),
success: (val, raw) => log("log", this.colors.red(util.format(val)), raw),
log: (val, raw) => log("error", this.colors.red(util.format(val)), raw),
warn: (val, raw) => log("warn", this.colors.yellow(util.format(val)), raw),
info: (val, raw) => log("info", this.colors.cyan(util.format(val)), raw),
success: (val, raw) => log("log", this.colors.green(util.format(val)), raw),
log: (val, raw) => log("log", util.format(val), raw),

Copilot uses AI. Check for mistakes.
@avivkeller avivkeller marked this pull request as draft January 27, 2026 20:36
Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please split this work step by step, i.e. package by package, it is impossible to review

@alexander-akait
Copy link
Member

Also no breaking changes, all breaking changes should be in the next major release

@alexander-akait
Copy link
Member

And please avoid any unnecessary changes not related to just move, all refactor works should be done separably

@avivkeller
Copy link
Member Author

Yes, I seem to have gotten ahead of myself. Nevertheless, I'll break this up :-)

@alexander-akait
Copy link
Member

Thanks

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.

Deprecate Some Packages

3 participants