From ced34c58a4efd67622033622249003971ca94f6b Mon Sep 17 00:00:00 2001 From: alexander-akait Date: Mon, 23 Feb 2026 19:16:32 +0300 Subject: [PATCH 1/4] refactor: move configtest into core --- packages/configtest/CHANGELOG.md | 79 ------------------------- packages/configtest/README.md | 31 ---------- packages/configtest/package.json | 26 -------- packages/configtest/src/index.ts | 64 -------------------- packages/configtest/tsconfig.json | 13 ---- packages/webpack-cli/src/webpack-cli.ts | 53 ++++++++++++++++- 6 files changed, 50 insertions(+), 216 deletions(-) delete mode 100644 packages/configtest/CHANGELOG.md delete mode 100644 packages/configtest/README.md delete mode 100644 packages/configtest/package.json delete mode 100644 packages/configtest/src/index.ts delete mode 100644 packages/configtest/tsconfig.json diff --git a/packages/configtest/CHANGELOG.md b/packages/configtest/CHANGELOG.md deleted file mode 100644 index 69f02606722..00000000000 --- a/packages/configtest/CHANGELOG.md +++ /dev/null @@ -1,79 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [3.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@3.0.0...@webpack-cli/configtest@3.0.1) (2024-12-20) - -### Bug Fixes - -- update peer dependencies ([#4356](https://github.com/webpack/webpack-cli/issues/4356)) ([7a7e5d9](https://github.com/webpack/webpack-cli/commit/7a7e5d9f4bd796c7d1089db228b9581e97cc897e)) - -# [3.0.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@2.1.1...@webpack-cli/configtest@3.0.0) (2024-12-19) - -**Note:** Version bump only for package @webpack-cli/configtest - -## [2.1.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@2.1.0...@webpack-cli/configtest@2.1.1) (2023-06-04) - -**Note:** Version bump only for package @webpack-cli/configtest - -# [2.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@2.0.1...@webpack-cli/configtest@2.1.0) (2023-05-07) - -### Features - -- shareable webpack configs using `extends` ([#3738](https://github.com/webpack/webpack-cli/issues/3738)) ([d04d0b9](https://github.com/webpack/webpack-cli/commit/d04d0b98b69948966c8de5dacf771ac324ba5658)) - -## [2.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@2.0.0...@webpack-cli/configtest@2.0.1) (2022-12-05) - -**Note:** Version bump only for package @webpack-cli/configtest - -# [2.0.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.2.0...@webpack-cli/configtest@2.0.0) (2022-11-17) - -### BREAKING CHANGES - -- the minimum supported webpack version is v5.0.0 (#3342) ([b1af0dc](https://github.com/webpack/webpack-cli/commit/b1af0dc7ebcdf746bc37889e4c1f978c65acc4a5)), closes [#3342](https://github.com/webpack/webpack-cli/issues/3342) -- webpack-cli no longer supports webpack v4, the minimum supported version is webpack v5.0.0 - -# [1.2.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.1.1...@webpack-cli/configtest@1.2.0) (2022-06-13) - -### Features - -- added types ([8ec1375](https://github.com/webpack/webpack-cli/commit/8ec1375092a6f9676e82fa4231dd88b1016c2302)) - -## [1.1.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.1.0...@webpack-cli/configtest@1.1.1) (2022-01-24) - -**Note:** Version bump only for package @webpack-cli/configtest - -# [1.1.0](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.0.4...@webpack-cli/configtest@1.1.0) (2021-10-06) - -### Features - -- allow to run commands without webpack installation where it is unnecessary ([#2907](https://github.com/webpack/webpack-cli/issues/2907)) ([603041d](https://github.com/webpack/webpack-cli/commit/603041d7e6a9b764bd79d1a8effd22a3e0f019cb)) - -## [1.0.4](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.0.3...@webpack-cli/configtest@1.0.4) (2021-06-07) - -### Bug Fixes - -- prettier config ([#2719](https://github.com/webpack/webpack-cli/issues/2719)) ([181295f](https://github.com/webpack/webpack-cli/commit/181295fb1b1973c201c221813562219d85b845ae)) - -## [1.0.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.0.2...@webpack-cli/configtest@1.0.3) (2021-05-06) - -**Note:** Version bump only for package @webpack-cli/configtest - -## [1.0.2](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.0.1...@webpack-cli/configtest@1.0.2) (2021-03-27) - -**Note:** Version bump only for package @webpack-cli/configtest - -## [1.0.1](https://github.com/webpack/webpack-cli/compare/@webpack-cli/configtest@1.0.0...@webpack-cli/configtest@1.0.1) (2021-02-02) - -### Bug Fixes - -- improve description for 'configtest' command ([#2379](https://github.com/webpack/webpack-cli/issues/2379)) ([311bae3](https://github.com/webpack/webpack-cli/commit/311bae336d83424c800e553b6ef40242d967685c)) - -# 1.0.0 (2021-01-19) - -### Features - -- `configtest` validate default configuration ([#2354](https://github.com/webpack/webpack-cli/issues/2354)) ([487691a](https://github.com/webpack/webpack-cli/commit/487691abc8d817f5b3c1ab87743d7235ff15d956)) -- added the `watch` command ([#2357](https://github.com/webpack/webpack-cli/issues/2357)) ([9693f7d](https://github.com/webpack/webpack-cli/commit/9693f7d9543a8fce610c4ef903ccca0d12d229a1)) -- new `configtest` command ([#2303](https://github.com/webpack/webpack-cli/issues/2303)) ([eb7b189](https://github.com/webpack/webpack-cli/commit/eb7b18937d045261a5b20ca8356e8b4ae4dfcaad)) diff --git a/packages/configtest/README.md b/packages/configtest/README.md deleted file mode 100644 index 947a82d8697..00000000000 --- a/packages/configtest/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# webpack-cli configtest - -[![NPM Downloads][downloads]][downloads-url] - -> **Note** -> -> This package is used by webpack-cli under-the-hood and is not intended for installation - -## Description - -This package validates a webpack configuration. - -## Installation - -```bash -# npm -npm i -D @webpack-cli/configtest - -# yarn -yarn add -D @webpack-cli/configtest - -``` - -## Usage - -```bash -npx webpack configtest [config-path] -``` - -[downloads]: https://img.shields.io/npm/dm/@webpack-cli/configtest.svg -[downloads-url]: https://www.npmjs.com/package/@webpack-cli/configtest diff --git a/packages/configtest/package.json b/packages/configtest/package.json deleted file mode 100644 index 7a12e7a558a..00000000000 --- a/packages/configtest/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "@webpack-cli/configtest", - "version": "3.0.1", - "description": "Validate a webpack configuration.", - "homepage": "https://github.com/webpack/webpack-cli/tree/main/packages/configtest", - "repository": { - "type": "git", - "url": "https://github.com/webpack/webpack-cli.git" - }, - "license": "MIT", - "main": "lib/index.js", - "types": "lib/index.d.ts", - "files": [ - "lib" - ], - "peerDependencies": { - "webpack": "^5.82.0", - "webpack-cli": "6.x.x" - }, - "engines": { - "node": ">=18.12.0" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/configtest/src/index.ts b/packages/configtest/src/index.ts deleted file mode 100644 index d008bef38f7..00000000000 --- a/packages/configtest/src/index.ts +++ /dev/null @@ -1,64 +0,0 @@ -import { type IWebpackCLI } from "webpack-cli"; - -const WEBPACK_PACKAGE = process.env.WEBPACK_PACKAGE || "webpack"; - -class ConfigTestCommand { - async apply(cli: IWebpackCLI): Promise { - await cli.makeCommand( - { - rawName: "configtest", - name: "configtest [config-path]", - alias: "t", - description: "Validate a webpack configuration.", - pkg: "@webpack-cli/configtest", - dependencies: [WEBPACK_PACKAGE], - }, - [], - async (configPath: string | undefined): Promise => { - cli.webpack = await cli.loadWebpack(); - - const config = await cli.loadConfig(configPath ? { config: [configPath] } : {}); - const configPaths = new Set(); - - if (Array.isArray(config.options)) { - for (const options of config.options) { - const loadedConfigPaths = config.path.get(options); - - if (loadedConfigPaths) { - for (const path of loadedConfigPaths) configPaths.add(path); - } - } - } else if (config.path.get(config.options)) { - const loadedConfigPaths = config.path.get(config.options); - - if (loadedConfigPaths) { - for (const path of loadedConfigPaths) configPaths.add(path); - } - } - - if (configPaths.size === 0) { - cli.logger.error("No configuration found."); - process.exit(2); - } - - cli.logger.info(`Validate '${[...configPaths].join(" ,")}'.`); - - try { - cli.webpack.validate(config.options); - } catch (error) { - if (cli.isValidationError(error as Error)) { - cli.logger.error((error as Error).message); - } else { - cli.logger.error(error); - } - - process.exit(2); - } - - cli.logger.success("There are no validation errors in the given webpack configuration."); - }, - ); - } -} - -export default ConfigTestCommand; diff --git a/packages/configtest/tsconfig.json b/packages/configtest/tsconfig.json deleted file mode 100644 index 1c6d02ef88c..00000000000 --- a/packages/configtest/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "outDir": "./lib", - "rootDir": "./src" - }, - "include": ["./src"], - "references": [ - { - "path": "../webpack-cli" - } - ] -} diff --git a/packages/webpack-cli/src/webpack-cli.ts b/packages/webpack-cli/src/webpack-cli.ts index 53c3a07862c..c8638c8a175 100644 --- a/packages/webpack-cli/src/webpack-cli.ts +++ b/packages/webpack-cli/src/webpack-cli.ts @@ -1175,10 +1175,10 @@ class WebpackCLI implements IWebpackCLI { }, configtest: { rawName: "configtest", - external: true, name: "configtest [config-path]", alias: "t", - pkg: "@webpack-cli/configtest", + description: "Validate a webpack configuration.", + dependencies: [WEBPACK_PACKAGE], }, }; @@ -1234,7 +1234,6 @@ class WebpackCLI implements IWebpackCLI { // Stub for the `help` command }); } else if (this.#isCommand(commandName, WebpackCLI.#commands.version)) { - // Stub for the `version` command this.makeCommand( WebpackCLI.#commands.version, this.getInfoOptions(), @@ -1244,6 +1243,54 @@ class WebpackCLI implements IWebpackCLI { this.logger.raw(info); }, ); + } else if (this.#isCommand(commandName, WebpackCLI.#commands.configtest)) { + this.makeCommand( + WebpackCLI.#commands.configtest, + [], + async (configPath: string | undefined) => { + this.webpack = await this.loadWebpack(); + + const config = await this.loadConfig(configPath ? { config: [configPath] } : {}); + const configPaths = new Set(); + + if (Array.isArray(config.options)) { + for (const options of config.options) { + const loadedConfigPaths = config.path.get(options); + + if (loadedConfigPaths) { + for (const path of loadedConfigPaths) configPaths.add(path); + } + } + } else if (config.path.get(config.options)) { + const loadedConfigPaths = config.path.get(config.options); + + if (loadedConfigPaths) { + for (const path of loadedConfigPaths) configPaths.add(path); + } + } + + if (configPaths.size === 0) { + this.logger.error("No configuration found."); + process.exit(2); + } + + this.logger.info(`Validate '${[...configPaths].join(" ,")}'.`); + + try { + this.webpack.validate(config.options); + } catch (error) { + if (this.isValidationError(error as Error)) { + this.logger.error((error as Error).message); + } else { + this.logger.error(error); + } + + process.exit(2); + } + + this.logger.success("There are no validation errors in the given webpack configuration."); + }, + ); } else { const builtInExternalCommandInfo = Object.values(WebpackCLI.#commands) .filter((item) => item.external) From 9554ca5ccb3cda591b3450139a9c2d62578f930d Mon Sep 17 00:00:00 2001 From: alexander-akait Date: Mon, 23 Feb 2026 19:23:40 +0300 Subject: [PATCH 2/4] refactor: fix lint --- tsconfig.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 6893b2e9aff..d97dc7dfde7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,9 +21,6 @@ "declaration": true }, "references": [ - { - "path": "packages/configtest" - }, { "path": "packages/info" }, From 026109b9026b35f2715e7c9b69bdc928cf6cadd8 Mon Sep 17 00:00:00 2001 From: alexander-akait Date: Mon, 23 Feb 2026 19:30:30 +0300 Subject: [PATCH 3/4] test: fix --- .../configtest.test.js | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 smoketests/missing-command-packages/configtest.test.js diff --git a/smoketests/missing-command-packages/configtest.test.js b/smoketests/missing-command-packages/configtest.test.js deleted file mode 100644 index a34823c08d7..00000000000 --- a/smoketests/missing-command-packages/configtest.test.js +++ /dev/null @@ -1,25 +0,0 @@ -"use strict"; - -const { runTest, runTestWithHelp } = require("../helpers"); - -const packageName = "configtest"; -const isSubPackage = true; - -const configTest = () => { - const args = ["configtest"]; - const logMessage = - "For using this command you need to install: '@webpack-cli/configtest' package"; - - return runTest(packageName, args, logMessage, isSubPackage); -}; - -const configTestWithHelp = () => { - const args = ["help", "configtest"]; - const logMessage = - "For using 'configtest' command you need to install '@webpack-cli/configtest' package"; - - return runTestWithHelp(packageName, args, logMessage, isSubPackage); -}; - -module.exports.name = "Missing @webpack-cli/configtest"; -module.exports.run = [configTest, configTestWithHelp]; From d98b65130b323b3eb510f19ba52bdcda4ff4b9b7 Mon Sep 17 00:00:00 2001 From: alexander-akait Date: Mon, 23 Feb 2026 19:34:15 +0300 Subject: [PATCH 4/4] test: fix --- smoketests/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/smoketests/index.js b/smoketests/index.js index a61aefcbc42..fc990c6fba3 100644 --- a/smoketests/index.js +++ b/smoketests/index.js @@ -4,7 +4,6 @@ const tests = [ require("./missing-packages/webpack-bundle-analyzer.test"), require("./missing-command-packages/serve.test"), require("./missing-command-packages/info.test"), - require("./missing-command-packages/configtest.test"), ]; // eslint-disable-next-line unicorn/prefer-top-level-await