From 51a76e3d416dc267fbebdb22b6fe71b929b76ff5 Mon Sep 17 00:00:00 2001 From: alexander-akait Date: Wed, 4 Mar 2026 18:20:57 +0300 Subject: [PATCH] refactor: improve perf + more tests --- package-lock.json | 500 ++++-------------- package.json | 8 +- packages/webpack-cli/src/webpack-cli.ts | 133 +++-- .../invalid-schema/invalid-schema.test.js | 48 ++ 4 files changed, 221 insertions(+), 468 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7f8e0f80894..30ed355f02b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,8 +13,8 @@ "@babel/core": "^7.25.2", "@babel/preset-env": "^7.25.2", "@babel/register": "^7.15.8", - "@changesets/cli": "^2.29.8", - "@changesets/get-github-info": "^0.7.0", + "@changesets/cli": "^2.30.0", + "@changesets/get-github-info": "^0.8.0", "@types/jest": "^30.0.0", "@types/node": "^22.5.5", "@types/rechoir": "^0.6.1", @@ -30,7 +30,7 @@ "get-port": "^7.1.0", "husky": "^9.1.4", "jest": "^30.2.0", - "lint-staged": "^16.2.7", + "lint-staged": "^16.3.2", "mini-css-extract-plugin": "^2.6.1", "nyc": "^18.0.0", "prettier": "^3.6.0", @@ -42,7 +42,7 @@ "ts-loader": "^9.3.1", "ts-node": "^10.9.1", "typescript": "^5.0.4", - "webpack": "^5.103.0", + "webpack": "^5.105.4", "webpack-bundle-analyzer": "^5.1.0", "webpack-dev-server": "^5.1.0" }, @@ -1833,13 +1833,13 @@ "license": "MIT" }, "node_modules/@changesets/apply-release-plan": { - "version": "7.0.14", - "resolved": "https://registry.npmjs.org/@changesets/apply-release-plan/-/apply-release-plan-7.0.14.tgz", - "integrity": "sha512-ddBvf9PHdy2YY0OUiEl3TV78mH9sckndJR14QAt87KLEbIov81XO0q0QAmvooBxXlqRRP8I9B7XOzZwQG7JkWA==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@changesets/apply-release-plan/-/apply-release-plan-7.1.0.tgz", + "integrity": "sha512-yq8ML3YS7koKQ/9bk1PqO0HMzApIFNwjlwCnwFEXMzNe8NpzeeYYKCmnhWJGkN8g7E51MnWaSbqRcTcdIxUgnQ==", "dev": true, "license": "MIT", "dependencies": { - "@changesets/config": "^3.1.2", + "@changesets/config": "^3.1.3", "@changesets/get-version-range-type": "^0.4.0", "@changesets/git": "^3.0.4", "@changesets/should-skip-package": "^0.1.2", @@ -1864,31 +1864,6 @@ "node": ">=8" } }, - "node_modules/@changesets/apply-release-plan/node_modules/fs-extra": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", - "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, - "node_modules/@changesets/apply-release-plan/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "dev": true, - "license": "MIT", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/@changesets/apply-release-plan/node_modules/prettier": { "version": "2.8.8", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", @@ -1918,16 +1893,6 @@ "node": ">=10" } }, - "node_modules/@changesets/apply-release-plan/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/@changesets/assemble-release-plan": { "version": "6.0.9", "resolved": "https://registry.npmjs.org/@changesets/assemble-release-plan/-/assemble-release-plan-6.0.9.tgz", @@ -1967,34 +1932,32 @@ } }, "node_modules/@changesets/cli": { - "version": "2.29.8", - "resolved": "https://registry.npmjs.org/@changesets/cli/-/cli-2.29.8.tgz", - "integrity": "sha512-1weuGZpP63YWUYjay/E84qqwcnt5yJMM0tep10Up7Q5cS/DGe2IZ0Uj3HNMxGhCINZuR7aO9WBMdKnPit5ZDPA==", + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/@changesets/cli/-/cli-2.30.0.tgz", + "integrity": "sha512-5D3Nk2JPqMI1wK25pEymeWRSlSMdo5QOGlyfrKg0AOufrUcjEE3RQgaCpHoBiM31CSNrtSgdJ0U6zL1rLDDfBA==", "dev": true, "license": "MIT", "dependencies": { - "@changesets/apply-release-plan": "^7.0.14", + "@changesets/apply-release-plan": "^7.1.0", "@changesets/assemble-release-plan": "^6.0.9", "@changesets/changelog-git": "^0.2.1", - "@changesets/config": "^3.1.2", + "@changesets/config": "^3.1.3", "@changesets/errors": "^0.2.0", "@changesets/get-dependents-graph": "^2.1.3", - "@changesets/get-release-plan": "^4.0.14", + "@changesets/get-release-plan": "^4.0.15", "@changesets/git": "^3.0.4", "@changesets/logger": "^0.1.1", "@changesets/pre": "^2.0.2", - "@changesets/read": "^0.6.6", + "@changesets/read": "^0.6.7", "@changesets/should-skip-package": "^0.1.2", "@changesets/types": "^6.1.0", "@changesets/write": "^0.4.0", "@inquirer/external-editor": "^1.0.2", "@manypkg/get-packages": "^1.1.3", "ansi-colors": "^4.1.3", - "ci-info": "^3.7.0", "enquirer": "^2.4.1", "fs-extra": "^7.0.1", "mri": "^1.2.0", - "p-limit": "^2.2.0", "package-manager-detector": "^0.2.0", "picocolors": "^1.1.0", "resolve-from": "^5.0.0", @@ -2016,22 +1979,6 @@ "node": ">=8" } }, - "node_modules/@changesets/cli/node_modules/ci-info": { - "version": "3.9.0", - "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", - "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/sibiraj-s" - } - ], - "license": "MIT", - "engines": { - "node": ">=8" - } - }, "node_modules/@changesets/cli/node_modules/enquirer": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.4.1.tgz", @@ -2046,47 +1993,6 @@ "node": ">=8.6" } }, - "node_modules/@changesets/cli/node_modules/fs-extra": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", - "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, - "node_modules/@changesets/cli/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "dev": true, - "license": "MIT", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/@changesets/cli/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@changesets/cli/node_modules/semver": { "version": "7.7.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", @@ -2113,67 +2019,23 @@ "node": ">=8" } }, - "node_modules/@changesets/cli/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/@changesets/config": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@changesets/config/-/config-3.1.2.tgz", - "integrity": "sha512-CYiRhA4bWKemdYi/uwImjPxqWNpqGPNbEBdX1BdONALFIDK7MCUj6FPkzD+z9gJcvDFUQJn9aDVf4UG7OT6Kog==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@changesets/config/-/config-3.1.3.tgz", + "integrity": "sha512-vnXjcey8YgBn2L1OPWd3ORs0bGC4LoYcK/ubpgvzNVr53JXV5GiTVj7fWdMRsoKUH7hhhMAQnsJUqLr21EncNw==", "dev": true, "license": "MIT", "dependencies": { "@changesets/errors": "^0.2.0", "@changesets/get-dependents-graph": "^2.1.3", "@changesets/logger": "^0.1.1", + "@changesets/should-skip-package": "^0.1.2", "@changesets/types": "^6.1.0", "@manypkg/get-packages": "^1.1.3", "fs-extra": "^7.0.1", "micromatch": "^4.0.8" } }, - "node_modules/@changesets/config/node_modules/fs-extra": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", - "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, - "node_modules/@changesets/config/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "dev": true, - "license": "MIT", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/@changesets/config/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/@changesets/errors": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/@changesets/errors/-/errors-0.2.0.tgz", @@ -2211,9 +2073,9 @@ } }, "node_modules/@changesets/get-github-info": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@changesets/get-github-info/-/get-github-info-0.7.0.tgz", - "integrity": "sha512-+i67Bmhfj9V4KfDeS1+Tz3iF32btKZB2AAx+cYMqDSRFP7r3/ZdGbjCo+c6qkyViN9ygDuBjzageuPGJtKGe5A==", + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@changesets/get-github-info/-/get-github-info-0.8.0.tgz", + "integrity": "sha512-cRnC+xdF0JIik7coko3iUP9qbnfi1iJQ3sAa6dE+Tx3+ET8bjFEm63PA4WEohgjYcmsOikPHWzPsMWWiZmntOQ==", "dev": true, "license": "MIT", "dependencies": { @@ -2222,16 +2084,16 @@ } }, "node_modules/@changesets/get-release-plan": { - "version": "4.0.14", - "resolved": "https://registry.npmjs.org/@changesets/get-release-plan/-/get-release-plan-4.0.14.tgz", - "integrity": "sha512-yjZMHpUHgl4Xl5gRlolVuxDkm4HgSJqT93Ri1Uz8kGrQb+5iJ8dkXJ20M2j/Y4iV5QzS2c5SeTxVSKX+2eMI0g==", + "version": "4.0.15", + "resolved": "https://registry.npmjs.org/@changesets/get-release-plan/-/get-release-plan-4.0.15.tgz", + "integrity": "sha512-Q04ZaRPuEVZtA+auOYgFaVQQSA98dXiVe/yFaZfY7hoSmQICHGvP0TF4u3EDNHWmmCS4ekA/XSpKlSM2PyTS2g==", "dev": true, "license": "MIT", "dependencies": { "@changesets/assemble-release-plan": "^6.0.9", - "@changesets/config": "^3.1.2", + "@changesets/config": "^3.1.3", "@changesets/pre": "^2.0.2", - "@changesets/read": "^0.6.6", + "@changesets/read": "^0.6.7", "@changesets/types": "^6.1.0", "@manypkg/get-packages": "^1.1.3" } @@ -2268,9 +2130,9 @@ } }, "node_modules/@changesets/parse": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/@changesets/parse/-/parse-0.4.2.tgz", - "integrity": "sha512-Uo5MC5mfg4OM0jU3up66fmSn6/NE9INK+8/Vn/7sMVcdWg46zfbvvUSjD9EMonVqPi9fbrJH9SXHn48Tr1f2yA==", + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@changesets/parse/-/parse-0.4.3.tgz", + "integrity": "sha512-ZDmNc53+dXdWEv7fqIUSgRQOLYoUom5Z40gmLgmATmYR9NbL6FJJHwakcCpzaeCy+1D0m0n7mT4jj2B/MQPl7A==", "dev": true, "license": "MIT", "dependencies": { @@ -2291,92 +2153,22 @@ "fs-extra": "^7.0.1" } }, - "node_modules/@changesets/pre/node_modules/fs-extra": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", - "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, - "node_modules/@changesets/pre/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "dev": true, - "license": "MIT", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/@changesets/pre/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/@changesets/read": { - "version": "0.6.6", - "resolved": "https://registry.npmjs.org/@changesets/read/-/read-0.6.6.tgz", - "integrity": "sha512-P5QaN9hJSQQKJShzzpBT13FzOSPyHbqdoIBUd2DJdgvnECCyO6LmAOWSV+O8se2TaZJVwSXjL+v9yhb+a9JeJg==", + "version": "0.6.7", + "resolved": "https://registry.npmjs.org/@changesets/read/-/read-0.6.7.tgz", + "integrity": "sha512-D1G4AUYGrBEk8vj8MGwf75k9GpN6XL3wg8i42P2jZZwFLXnlr2Pn7r9yuQNbaMCarP7ZQWNJbV6XLeysAIMhTA==", "dev": true, "license": "MIT", "dependencies": { "@changesets/git": "^3.0.4", "@changesets/logger": "^0.1.1", - "@changesets/parse": "^0.4.2", + "@changesets/parse": "^0.4.3", "@changesets/types": "^6.1.0", "fs-extra": "^7.0.1", "p-filter": "^2.1.0", "picocolors": "^1.1.0" } }, - "node_modules/@changesets/read/node_modules/fs-extra": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", - "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, - "node_modules/@changesets/read/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "dev": true, - "license": "MIT", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/@changesets/read/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/@changesets/should-skip-package": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@changesets/should-skip-package/-/should-skip-package-0.1.2.tgz", @@ -2408,31 +2200,6 @@ "prettier": "^2.7.1" } }, - "node_modules/@changesets/write/node_modules/fs-extra": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", - "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.1.2", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, - "node_modules/@changesets/write/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "dev": true, - "license": "MIT", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/@changesets/write/node_modules/prettier": { "version": "2.8.8", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", @@ -2449,16 +2216,6 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, - "node_modules/@changesets/write/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/@cspell/cspell-bundled-dicts": { "version": "9.7.0", "resolved": "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-9.7.0.tgz", @@ -4745,16 +4502,6 @@ "node": ">=6 <7 || >=8" } }, - "node_modules/@manypkg/find-root/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "dev": true, - "license": "MIT", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/@manypkg/find-root/node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -4797,16 +4544,6 @@ "node": ">=8" } }, - "node_modules/@manypkg/find-root/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/@manypkg/get-packages": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@manypkg/get-packages/-/get-packages-1.1.3.tgz", @@ -4865,16 +4602,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/@manypkg/get-packages/node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "dev": true, - "license": "MIT", - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/@manypkg/get-packages/node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -4885,16 +4612,6 @@ "node": ">=8" } }, - "node_modules/@manypkg/get-packages/node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/@noble/hashes": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", @@ -9400,9 +9117,9 @@ } }, "node_modules/enhanced-resolve": { - "version": "5.19.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.19.0.tgz", - "integrity": "sha512-phv3E1Xl4tQOShqSte26C7Fl84EwUdZsyOuSSk9qtAGyyQs2s3jJzComh+Abf4g187lUUAvH+H26omrqia2aGg==", + "version": "5.20.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.20.0.tgz", + "integrity": "sha512-/ce7+jQ1PQ6rVXwe+jKEg5hW5ciicHwIQUagZkp6IufBoY3YDgdTTY1azVs0qoRgVmvsNB+rbjLJxDAeHHtwsQ==", "license": "MIT", "dependencies": { "graceful-fs": "^4.2.4", @@ -11078,6 +10795,21 @@ ], "license": "MIT" }, + "node_modules/fs-extra": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + }, + "engines": { + "node": ">=6 <7 || >=8" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -14418,6 +14150,16 @@ "node": ">=10" } }, + "node_modules/jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", + "dev": true, + "license": "MIT", + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, "node_modules/jsx-ast-utils": { "version": "3.3.5", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz", @@ -14489,19 +14231,18 @@ } }, "node_modules/lint-staged": { - "version": "16.2.7", - "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-16.2.7.tgz", - "integrity": "sha512-lDIj4RnYmK7/kXMya+qJsmkRFkGolciXjrsZ6PC25GdTfWOAWetR0ZbsNXRAj1EHHImRSalc+whZFg56F5DVow==", + "version": "16.3.2", + "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-16.3.2.tgz", + "integrity": "sha512-xKqhC2AeXLwiAHXguxBjuChoTTWFC6Pees0SHPwOpwlvI3BH7ZADFPddAdN3pgo3aiKgPUx/bxE78JfUnxQnlg==", "dev": true, "license": "MIT", "dependencies": { - "commander": "^14.0.2", + "commander": "^14.0.3", "listr2": "^9.0.5", "micromatch": "^4.0.8", - "nano-spawn": "^2.0.0", - "pidtree": "^0.6.0", "string-argv": "^0.3.2", - "yaml": "^2.8.1" + "tinyexec": "^1.0.2", + "yaml": "^2.8.2" }, "bin": { "lint-staged": "bin/lint-staged.js" @@ -14850,16 +14591,6 @@ "node": ">=6" } }, - "node_modules/make-dir/node_modules/pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/make-dir/node_modules/semver": { "version": "5.7.2", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", @@ -16021,19 +15752,6 @@ "multicast-dns": "cli.js" } }, - "node_modules/nano-spawn": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/nano-spawn/-/nano-spawn-2.0.0.tgz", - "integrity": "sha512-tacvGzUY5o2D8CBh2rrwxyNojUsZNU2zjNTzKQrkgGJQTbGAfArVWXSKMBokBeeg6C7OLRGUEyoFlYbfeWQIqw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=20.17" - }, - "funding": { - "url": "https://github.com/sindresorhus/nano-spawn?sponsor=1" - } - }, "node_modules/nanoid": { "version": "3.3.11", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", @@ -17421,17 +17139,14 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/pidtree": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.6.0.tgz", - "integrity": "sha512-eG2dWTVw5bzqGRztnHExczNxt5VGsE6OwTeCG3fdUf9KBsZzO3R5OIIIzWR+iZA0NtZ+RDVdaoE2dK1cn6jH4g==", + "node_modules/pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", "dev": true, "license": "MIT", - "bin": { - "pidtree": "bin/pidtree.js" - }, "engines": { - "node": ">=0.10" + "node": ">=6" } }, "node_modules/pirates": { @@ -17933,15 +17648,6 @@ ], "license": "MIT" }, - "node_modules/randombytes": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", - "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", - "license": "MIT", - "dependencies": { - "safe-buffer": "^5.1.0" - } - }, "node_modules/range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -18028,16 +17734,6 @@ "js-yaml": "bin/js-yaml.js" } }, - "node_modules/read-yaml-file/node_modules/pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/read-yaml-file/node_modules/strip-bom": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", @@ -18766,15 +18462,6 @@ "devOptional": true, "license": "MIT" }, - "node_modules/serialize-javascript": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", - "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", - "license": "BSD-3-Clause", - "dependencies": { - "randombytes": "^2.1.0" - } - }, "node_modules/serve-index": { "version": "1.9.2", "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.2.tgz", @@ -19854,15 +19541,14 @@ } }, "node_modules/terser-webpack-plugin": { - "version": "5.3.16", - "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.16.tgz", - "integrity": "sha512-h9oBFCWrq78NyWWVcSwZarJkZ01c2AyGrzs1crmHZO3QUg9D61Wu4NPjBy69n7JqylFF5y+CsUZYmYEIZ3mR+Q==", + "version": "5.3.17", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.17.tgz", + "integrity": "sha512-YR7PtUp6GMU91BgSJmlaX/rS2lGDbAF7D+Wtq7hRO+MiljNmodYvqslzCFiYVAgW+Qoaaia/QUIP4lGXufjdZw==", "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "^0.3.25", "jest-worker": "^27.4.5", "schema-utils": "^4.3.0", - "serialize-javascript": "^6.0.2", "terser": "^5.31.1" }, "engines": { @@ -19983,6 +19669,16 @@ "devOptional": true, "license": "MIT" }, + "node_modules/tinyexec": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", + "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, "node_modules/tinyglobby": { "version": "0.2.15", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", @@ -20723,6 +20419,16 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4.0.0" + } + }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -20920,9 +20626,9 @@ "license": "BSD-2-Clause" }, "node_modules/webpack": { - "version": "5.105.2", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.105.2.tgz", - "integrity": "sha512-dRXm0a2qcHPUBEzVk8uph0xWSjV/xZxenQQbLwnwP7caQCYpqG1qddwlyEkIDkYn0K8tvmcrZ+bOrzoQ3HxCDw==", + "version": "5.105.4", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.105.4.tgz", + "integrity": "sha512-jTywjboN9aHxFlToqb0K0Zs9SbBoW4zRUlGzI2tYNxVYcEi/IPpn+Xi4ye5jTLvX2YeLuic/IvxNot+Q1jMoOw==", "license": "MIT", "peer": true, "dependencies": { @@ -20932,11 +20638,11 @@ "@webassemblyjs/ast": "^1.14.1", "@webassemblyjs/wasm-edit": "^1.14.1", "@webassemblyjs/wasm-parser": "^1.14.1", - "acorn": "^8.15.0", + "acorn": "^8.16.0", "acorn-import-phases": "^1.0.3", "browserslist": "^4.28.1", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.19.0", + "enhanced-resolve": "^5.20.0", "es-module-lexer": "^2.0.0", "eslint-scope": "5.1.1", "events": "^3.2.0", @@ -20948,9 +20654,9 @@ "neo-async": "^2.6.2", "schema-utils": "^4.3.3", "tapable": "^2.3.0", - "terser-webpack-plugin": "^5.3.16", + "terser-webpack-plugin": "^5.3.17", "watchpack": "^2.5.1", - "webpack-sources": "^3.3.3" + "webpack-sources": "^3.3.4" }, "bin": { "webpack": "bin/webpack.js" diff --git a/package.json b/package.json index c35c8faa0f8..c252ecb0093 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,8 @@ "@babel/core": "^7.25.2", "@babel/preset-env": "^7.25.2", "@babel/register": "^7.15.8", - "@changesets/cli": "^2.29.8", - "@changesets/get-github-info": "^0.7.0", + "@changesets/cli": "^2.30.0", + "@changesets/get-github-info": "^0.8.0", "@types/jest": "^30.0.0", "@types/node": "^22.5.5", "@types/rechoir": "^0.6.1", @@ -67,7 +67,7 @@ "get-port": "^7.1.0", "husky": "^9.1.4", "jest": "^30.2.0", - "lint-staged": "^16.2.7", + "lint-staged": "^16.3.2", "mini-css-extract-plugin": "^2.6.1", "nyc": "^18.0.0", "prettier": "^3.6.0", @@ -79,7 +79,7 @@ "ts-loader": "^9.3.1", "ts-node": "^10.9.1", "typescript": "^5.0.4", - "webpack": "^5.103.0", + "webpack": "^5.105.4", "webpack-bundle-analyzer": "^5.1.0", "webpack-dev-server": "^5.1.0" }, diff --git a/packages/webpack-cli/src/webpack-cli.ts b/packages/webpack-cli/src/webpack-cli.ts index e9291615e68..977f8904ab8 100644 --- a/packages/webpack-cli/src/webpack-cli.ts +++ b/packages/webpack-cli/src/webpack-cli.ts @@ -25,7 +25,6 @@ import { type MultiCompiler, type MultiConfiguration, type MultiStats, - type MultiStatsOptions, type Problem, type Stats, type StatsOptions, @@ -95,6 +94,9 @@ interface CommandOptions extends CommanderCommandOptions { external?: boolean; } +// eslint-disable-next-line @typescript-eslint/no-explicit-any +type CommanderArgs = Record; + type BasicPrimitive = string | boolean | number; type EnumValue = string | number | boolean | EnumValueObject | EnumValue[] | null; @@ -165,7 +167,7 @@ declare interface WebpackCallback { type ProcessedArguments = Parameters<(typeof webpack)["cli"]["processArguments"]>[2]; -interface Options { +interface KnownOptions { config?: string[]; argv?: Argv; env?: Env; @@ -176,7 +178,6 @@ interface Options { isWatchingLikeCommand?: boolean; progress?: boolean | "profile"; analyze?: boolean; - prefetch?: string; json?: boolean; entry?: string | string[]; merge?: boolean; @@ -185,6 +186,12 @@ interface Options { extends?: string[]; } +type Options = + // Webpack CLI own options + KnownOptions & + // Webpack and webpack-dev-server options + Record; + const DEFAULT_WEBPACK_PACKAGES: string[] = ["webpack", "loader"]; class ConfigurationLoadingError extends Error { @@ -1529,7 +1536,7 @@ class WebpackCLI { return this.getBuiltInOptions(); }, - async (entries, options) => { + async (entries: string[], options: CommanderArgs) => { if (entries.length > 0) { options.entry = [...entries, ...(options.entry || [])]; } @@ -1574,7 +1581,7 @@ class WebpackCLI { return [...webpackOptions, ...devServerOptions]; }, - async (entries: string[], options) => { + async (entries: string[], options: CommanderArgs) => { const builtInOptions = this.getBuiltInOptions(); let devServerFlags: CommandOption[] = []; @@ -1585,7 +1592,7 @@ class WebpackCLI { } const webpackCLIOptions: Partial = {}; - const devServerCLIOptions: Record = {}; + const devServerCLIOptions: CommanderArgs = {}; for (const optionName in options) { const kebabedOption = this.toKebabCase(optionName); @@ -1651,23 +1658,23 @@ class WebpackCLI { continue; } - const devServerConfiguration: DevServerConfiguration = { - ...compilerForDevServer.options.devServer, - }; + const devServerConfiguration: DevServerConfiguration = + compilerForDevServer.options.devServer || {}; const args: Record = {}; - - for (const flag of devServerFlags) { - args[flag.name] = flag as unknown as WebpackArgument; - } - const values: ProcessedArguments = {}; for (const name of Object.keys(options)) { + if (name === "argv") continue; + const kebabName = this.toKebabCase(name); + const arg = devServerFlags.find((item) => item.name === kebabName); - if (args[kebabName] !== undefined) { - values[kebabName] = options[name]; + if (arg) { + args[name] = arg as unknown as WebpackArgument; + // We really don't know what the value is + // eslint-disable-next-line @typescript-eslint/no-explicit-any + values[name] = options[name as keyof Options] as any; } } @@ -1703,7 +1710,7 @@ class WebpackCLI { this.logger.error( `${this.capitalizeFirstLetter(problem.type.replace("-", " "))}${ problem.value ? ` '${problem.value}'` : "" - } for the '--${problem.argument}' option${ + } for the '--${problem.argument.replaceAll(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}' option${ problem.index ? ` by index '${problem.index}'` : "" }`, ); @@ -2530,33 +2537,30 @@ class WebpackCLI { const { default: CLIPlugin } = (await import("./plugins/cli-plugin.js")).default; - const internalBuildConfig = (item: Configuration) => { - const originalWatchValue = item.watch; + const internalBuildConfig = (configuration: Configuration) => { + const originalWatchValue = configuration.watch; // Apply options const builtInOptions = this.getBuiltInOptions(); const args: Record = {}; - - for (const flag of builtInOptions) { - if (flag.group === "core") { - args[flag.name] = flag as unknown as WebpackArgument; - } - } - const values: ProcessedArguments = {}; for (const name of Object.keys(options)) { if (name === "argv") continue; const kebabName = this.toKebabCase(name); + const arg = builtInOptions.find((item) => item.group === "core" && item.name === kebabName); - if (args[kebabName] !== undefined) { - values[kebabName] = options[name as keyof Options] as string[]; + if (arg) { + args[name] = arg as unknown as WebpackArgument; + // We really don't know what the value is + // eslint-disable-next-line @typescript-eslint/no-explicit-any + values[name] = options[name as keyof Options] as any; } } if (Object.keys(values).length > 0) { - const problems = this.webpack.cli.processArguments(args, item, values); + const problems = this.webpack.cli.processArguments(args, configuration, values); if (problems) { const groupBy = >(xs: Problem[], key: K) => @@ -2579,7 +2583,7 @@ class WebpackCLI { this.logger.error( `${this.capitalizeFirstLetter(problem.type.replaceAll("-", " "))}${ problem.value ? ` '${problem.value}'` : "" - } for the '--${problem.argument}' option${ + } for the '--${problem.argument.replaceAll(/[A-Z]/g, (m) => `-${m.toLowerCase()}`)}' option${ problem.index ? ` by index '${problem.index}'` : "" }`, ); @@ -2595,7 +2599,7 @@ class WebpackCLI { } // Output warnings - if (!Object.isExtensible(item)) { + if (!Object.isExtensible(configuration)) { return; } @@ -2611,7 +2615,7 @@ class WebpackCLI { ); if (options.argv.env.WEBPACK_SERVE) { - item.watch = false; + configuration.watch = false; } } @@ -2623,46 +2627,46 @@ class WebpackCLI { config.cache.type === "filesystem"; // Setup default cache options - if (isFileSystemCacheOptions(item) && Object.isExtensible(item.cache)) { - const configPath = config.path.get(item); + if (isFileSystemCacheOptions(configuration) && Object.isExtensible(configuration.cache)) { + const configPath = config.path.get(configuration); if (configPath) { - if (!item.cache.buildDependencies) { - item.cache.buildDependencies = {}; + if (!configuration.cache.buildDependencies) { + configuration.cache.buildDependencies = {}; } - if (!item.cache.buildDependencies.defaultConfig) { - item.cache.buildDependencies.defaultConfig = []; + if (!configuration.cache.buildDependencies.defaultConfig) { + configuration.cache.buildDependencies.defaultConfig = []; } if (Array.isArray(configPath)) { for (const oneOfConfigPath of configPath) { - item.cache.buildDependencies.defaultConfig.push(oneOfConfigPath); + configuration.cache.buildDependencies.defaultConfig.push(oneOfConfigPath); } } else { - item.cache.buildDependencies.defaultConfig.push(configPath); + configuration.cache.buildDependencies.defaultConfig.push(configPath); } } } // Respect `process.env.NODE_ENV` if ( - !item.mode && + !configuration.mode && process.env?.NODE_ENV && (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "production" || process.env.NODE_ENV === "none") ) { - item.mode = process.env.NODE_ENV; + configuration.mode = process.env.NODE_ENV; } // Setup stats - if (typeof item.stats === "undefined") { - item.stats = { preset: "normal" }; - } else if (typeof item.stats === "boolean") { - item.stats = item.stats ? { preset: "normal" } : { preset: "none" }; - } else if (typeof item.stats === "string") { - item.stats = { preset: item.stats }; + if (typeof configuration.stats === "undefined") { + configuration.stats = { preset: "normal" }; + } else if (typeof configuration.stats === "boolean") { + configuration.stats = configuration.stats ? { preset: "normal" } : { preset: "none" }; + } else if (typeof configuration.stats === "string") { + configuration.stats = { preset: configuration.stats }; } let colors; @@ -2672,27 +2676,27 @@ class WebpackCLI { colors = Boolean(this.#isColorSupportChanged); } // From stats - else if (typeof item.stats.colors !== "undefined") { - colors = item.stats.colors; + else if (typeof configuration.stats.colors !== "undefined") { + colors = configuration.stats.colors; } // Default else { colors = Boolean(this.colors.isColorSupported); } - if (Object.isExtensible(item.stats)) { - item.stats.colors = colors; + if (Object.isExtensible(configuration.stats)) { + configuration.stats.colors = colors; } // Apply CLI plugin - if (!item.plugins) { - item.plugins = []; + if (!configuration.plugins) { + configuration.plugins = []; } - if (Object.isExtensible(item.plugins)) { - item.plugins.unshift( + if (Object.isExtensible(configuration.plugins)) { + configuration.plugins.unshift( new CLIPlugin({ - configPath: config.path.get(item), + configPath: config.path.get(configuration), helpfulOutput: !options.json, progress: options.progress, analyze: options.analyze, @@ -2791,14 +2795,10 @@ class WebpackCLI { } const statsOptions = this.isMultipleCompiler(compiler) - ? ({ - children: compiler.compilers.map((compiler) => - compiler.options ? compiler.options.stats : undefined, - ), - } as MultiStatsOptions) - : compiler.options - ? (compiler.options.stats as StatsOptions) - : undefined; + ? { + children: compiler.compilers.map((compiler) => compiler.options.stats), + } + : compiler.options.stats; if (options.json) { const handleWriteError = (error: Error) => { @@ -2827,8 +2827,7 @@ class WebpackCLI { }); } } else { - // TODO bug on webpack side - const printedStats = stats.toString(statsOptions as StatsOptions); + const printedStats = stats.toString(statsOptions); // Avoid extra empty line when `stats: 'none'` if (printedStats) { diff --git a/test/build/error/invalid-schema/invalid-schema.test.js b/test/build/error/invalid-schema/invalid-schema.test.js index 29b6e151f8b..f5cf4a411f4 100644 --- a/test/build/error/invalid-schema/invalid-schema.test.js +++ b/test/build/error/invalid-schema/invalid-schema.test.js @@ -58,6 +58,17 @@ describe("invalid schema", () => { expect(stdout).toBeFalsy(); }); + it("should log error on invalid option #1", async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ["--cache-type", "Yukihira"]); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Invalid value 'Yukihira' for the '--cache-type' option"); + expect(stderr).toContain("Expected: 'memory'"); + expect(stderr).toContain("Invalid value 'Yukihira' for the '--cache-type' option"); + expect(stderr).toContain("Expected: 'filesystem'"); + expect(stdout).toBeFalsy(); + }); + it('should log error on invalid option using "build" command', async () => { const { exitCode, stderr, stdout } = await run(__dirname, ["build", "--mode", "Yukihira"]); @@ -120,4 +131,41 @@ describe("invalid schema", () => { expect(stderr).toContain("Expected: 'development | production | none'"); expect(stdout).toBeFalsy(); }); + + it('should log error on invalid option using "s" command #1', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ["s", "--cache-type", "Yukihira"]); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Invalid value 'Yukihira' for the '--cache-type' option"); + expect(stderr).toContain("Expected: 'memory'"); + expect(stderr).toContain("Invalid value 'Yukihira' for the '--cache-type' option"); + expect(stderr).toContain("Expected: 'filesystem'"); + expect(stdout).toBeFalsy(); + }); + + it('should log error on invalid option using "s" command #2', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, ["s", "--server-type", "Yukihira"]); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Invalid value 'Yukihira' for the '--server-type' option"); + expect(stderr).toContain("Expected: 'http | https | spdy | http2'"); + expect(stdout).toBeFalsy(); + }); + + it('should log error on invalid option using "s" command #3', async () => { + const { exitCode, stderr, stdout } = await run(__dirname, [ + "s", + "--cache-type", + "Yukihira", + "--server-type", + "Yukihira", + ]); + + expect(exitCode).toBe(2); + expect(stderr).toContain("Invalid value 'Yukihira' for the '--cache-type' option"); + expect(stderr).toContain("Expected: 'memory'"); + expect(stderr).toContain("Invalid value 'Yukihira' for the '--cache-type' option"); + expect(stderr).toContain("Expected: 'filesystem'"); + expect(stdout).toBeFalsy(); + }); });