diff --git a/CHANGELOG.md b/CHANGELOG.md index 3197c97a712..26190805218 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +# [5.1.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@5.0.2...webpack-cli@5.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)) + +### Performance Improvements + +- simplify logic, reduce extra loops and perf ([#3767](https://github.com/webpack/webpack-cli/issues/3767)) ([6afe1d3](https://github.com/webpack/webpack-cli/commit/6afe1d3be41e191aa7c4865919d092d952e98605)) + ## [5.0.2](https://github.com/webpack/webpack-cli/compare/webpack-cli@5.0.1...webpack-cli@5.0.2) (2023-04-21) ### Bug Fixes diff --git a/package.json b/package.json index 578dd8c72cb..35598849252 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "ts-jest": "^29.0.1", "ts-loader": "^9.3.1", "ts-node": "^10.8.0", - "typescript": "^4.9.3", + "typescript": "^5.0.4", "webpack": "^5.72.0", "webpack-bundle-analyzer": "^4.5.0", "webpack-dev-server": "^4.8.1" diff --git a/packages/generators/CHANGELOG.md b/packages/generators/CHANGELOG.md index b5aef954f37..49db5df3f64 100644 --- a/packages/generators/CHANGELOG.md +++ b/packages/generators/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [3.0.4](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generators@3.0.3...@webpack-cli/generators@3.0.4) (2023-05-09) + +**Note:** Version bump only for package @webpack-cli/generators + ## [3.0.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/generators@3.0.2...@webpack-cli/generators@3.0.3) (2023-05-07) **Note:** Version bump only for package @webpack-cli/generators diff --git a/packages/generators/package.json b/packages/generators/package.json index c0c52719b7c..3d9a4b781f2 100644 --- a/packages/generators/package.json +++ b/packages/generators/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/generators", - "version": "3.0.3", + "version": "3.0.4", "description": "Webpack-CLI generators", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -25,7 +25,7 @@ "plugin-template" ], "dependencies": { - "webpack-cli": "^5.1.0", + "webpack-cli": "^5.1.1", "yeoman-environment": "^3.9.1", "yeoman-generator": "^5.7.0" }, diff --git a/packages/serve/CHANGELOG.md b/packages/serve/CHANGELOG.md index 50c1128920c..18c1436d157 100644 --- a/packages/serve/CHANGELOG.md +++ b/packages/serve/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.0.4](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@2.0.3...@webpack-cli/serve@2.0.4) (2023-05-09) + +### Bug Fixes + +- false positive warning when `--watch` used ([#3783](https://github.com/webpack/webpack-cli/issues/3783)) ([c0436ba](https://github.com/webpack/webpack-cli/commit/c0436baca2da7a8ce9e53bbbe960dd1951fe6404)) + ## [2.0.3](https://github.com/webpack/webpack-cli/compare/@webpack-cli/serve@2.0.2...@webpack-cli/serve@2.0.3) (2023-05-07) ### Performance Improvements diff --git a/packages/serve/package.json b/packages/serve/package.json index deef045193a..f26bcd5733b 100644 --- a/packages/serve/package.json +++ b/packages/serve/package.json @@ -1,6 +1,6 @@ { "name": "@webpack-cli/serve", - "version": "2.0.3", + "version": "2.0.4", "description": "", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/packages/serve/src/index.ts b/packages/serve/src/index.ts index 28374fa9194..3770144b57b 100644 --- a/packages/serve/src/index.ts +++ b/packages/serve/src/index.ts @@ -47,10 +47,7 @@ class ServeCommand { process.exit(2); } - const builtInOptions = cli.getBuiltInOptions().filter( - // eslint-disable-next-line @typescript-eslint/no-explicit-any - (option: any) => option.name !== "watch", - ); + const builtInOptions = cli.getBuiltInOptions(); return [...builtInOptions, ...devServerFlags]; }, @@ -110,6 +107,8 @@ class ServeCommand { env: { WEBPACK_SERVE: true, ...options.env }, }; + webpackCLIOptions.isWatchingLikeCommand = true; + const compiler = await cli.createCompiler(webpackCLIOptions); if (!compiler) { diff --git a/packages/webpack-cli/CHANGELOG.md b/packages/webpack-cli/CHANGELOG.md index 51ebf70f6c3..6d3078a6a0a 100644 --- a/packages/webpack-cli/CHANGELOG.md +++ b/packages/webpack-cli/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.1.1](https://github.com/webpack/webpack-cli/compare/webpack-cli@5.1.0...webpack-cli@5.1.1) (2023-05-09) + +### Bug Fixes + +- false positive warning when `--watch` used ([#3783](https://github.com/webpack/webpack-cli/issues/3783)) ([c0436ba](https://github.com/webpack/webpack-cli/commit/c0436baca2da7a8ce9e53bbbe960dd1951fe6404)) + # [5.1.0](https://github.com/webpack/webpack-cli/compare/webpack-cli@5.0.2...webpack-cli@5.1.0) (2023-05-07) ### Features diff --git a/packages/webpack-cli/package.json b/packages/webpack-cli/package.json index a273745954f..117d4be9f3d 100644 --- a/packages/webpack-cli/package.json +++ b/packages/webpack-cli/package.json @@ -1,6 +1,6 @@ { "name": "webpack-cli", - "version": "5.1.0", + "version": "5.1.1", "description": "CLI for webpack & friends", "license": "MIT", "repository": { @@ -37,7 +37,7 @@ "@discoveryjs/json-ext": "^0.5.0", "@webpack-cli/configtest": "^2.1.0", "@webpack-cli/info": "^2.0.1", - "@webpack-cli/serve": "^2.0.3", + "@webpack-cli/serve": "^2.0.4", "colorette": "^2.0.14", "commander": "^10.0.1", "cross-spawn": "^7.0.3", diff --git a/packages/webpack-cli/src/types.ts b/packages/webpack-cli/src/types.ts index 67b65c32074..a2aebc5c872 100644 --- a/packages/webpack-cli/src/types.ts +++ b/packages/webpack-cli/src/types.ts @@ -212,6 +212,7 @@ interface WebpackRunOptions extends WebpackOptionsNormalized { argv?: Argv; env: Env; failOnWarnings?: boolean; + isWatchingLikeCommand?: boolean; } /** diff --git a/packages/webpack-cli/src/webpack-cli.ts b/packages/webpack-cli/src/webpack-cli.ts index 7c57942e0e9..72f8a515b86 100644 --- a/packages/webpack-cli/src/webpack-cli.ts +++ b/packages/webpack-cli/src/webpack-cli.ts @@ -2163,11 +2163,10 @@ class WebpackCLI implements IWebpackCLI { // Output warnings if ( - (typeof originalWatchValue !== "undefined" || - (options.argv && typeof options.argv.watch !== "undefined")) && + options.isWatchingLikeCommand && options.argv && options.argv.env && - (options.argv.env["WEBPACK_WATCH"] || options.argv.env["WEBPACK_SERVE"]) + (typeof originalWatchValue !== "undefined" || typeof options.argv.watch !== "undefined") ) { this.logger.warn( `No need to use the '${ @@ -2418,6 +2417,7 @@ class WebpackCLI implements IWebpackCLI { if (isWatchCommand) { options.watch = true; + options.isWatchingLikeCommand = true; } compiler = await this.createCompiler(options as WebpackDevServerOptions, callback); diff --git a/test/serve/basic/__snapshots__/serve-basic.test.js.snap.devServer4.webpack5 b/test/serve/basic/__snapshots__/serve-basic.test.js.snap.devServer4.webpack5 index 4112d980d0b..fc9215cd6bb 100644 --- a/test/serve/basic/__snapshots__/serve-basic.test.js.snap.devServer4.webpack5 +++ b/test/serve/basic/__snapshots__/serve-basic.test.js.snap.devServer4.webpack5 @@ -8,19 +8,14 @@ exports[`basic serve usage should log an error on unknown flag: stderr 1`] = ` exports[`basic serve usage should log an error on unknown flag: stdout 1`] = `""`; exports[`basic serve usage should log error on using '--watch' flag with serve: stderr 1`] = ` -"[webpack-cli] Error: Unknown option '--watch' -[webpack-cli] Run 'webpack --help' to see available commands and options" -`; - -exports[`basic serve usage should log error on using '--watch' flag with serve: stdout 1`] = `""`; - -exports[`basic serve usage should log error on using '-w' alias with serve: stderr 1`] = ` -"[webpack-cli] Error: Unknown option '-w' -[webpack-cli] Run 'webpack --help' to see available commands and options" +"[webpack-cli] No need to use the 'serve' command together with '{ watch: true | false }' or '--watch'/'--no-watch' configuration, it does not make sense. + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/test/serve/basic/public' directory" `; -exports[`basic serve usage should log error on using '-w' alias with serve: stdout 1`] = `""`; - exports[`basic serve usage should log used supplied config with serve: stderr 1`] = ` " [webpack-cli] Compiler starting... [webpack-cli] Compiler is using config: '/test/serve/basic/log.config.js' @@ -34,6 +29,15 @@ exports[`basic serve usage should log used supplied config with serve: stderr 1` [webpack-cli] Compiler is watching files for updates..." `; +exports[`basic serve usage should log warning on using '-w' alias with serve: stderr 1`] = ` +"[webpack-cli] No need to use the 'serve' command together with '{ watch: true | false }' or '--watch'/'--no-watch' configuration, it does not make sense. + [webpack-dev-server] Project is running at: + [webpack-dev-server] Loopback: http://localhost:/ + [webpack-dev-server] On Your Network (IPv4): http://:/ + [webpack-dev-server] On Your Network (IPv6): http://[]:/ + [webpack-dev-server] Content not from webpack is served from '/test/serve/basic/public' directory" +`; + exports[`basic serve usage should respect the "publicPath" option from configuration (from the "devServer" options): stderr 1`] = ` " [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: http://localhost:/ diff --git a/test/serve/basic/serve-basic.test.js b/test/serve/basic/serve-basic.test.js index 863bc8c6ee4..217bf0a9725 100644 --- a/test/serve/basic/serve-basic.test.js +++ b/test/serve/basic/serve-basic.test.js @@ -373,17 +373,19 @@ describe("basic serve usage", () => { it("should log error on using '--watch' flag with serve", async () => { const { exitCode, stdout, stderr } = await runWatch(testPath, ["serve", "--watch"]); - expect(exitCode).toBe(2); + expect(exitCode).toBe(0); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); + expect(stdout).toContain("HotModuleReplacementPlugin"); + expect(stdout).toContain("main.js"); }); - it("should log error on using '-w' alias with serve", async () => { + it("should log warning on using '-w' alias with serve", async () => { const { exitCode, stdout, stderr } = await runWatch(testPath, ["serve", "-w"]); - expect(exitCode).toBe(2); + expect(exitCode).toBe(0); expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); - expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); + expect(stdout).toContain("HotModuleReplacementPlugin"); + expect(stdout).toContain("main.js"); }); it("should log an error on unknown flag", async () => { diff --git a/test/watch/basic/basic.config.js b/test/watch/basic/basic.config.js new file mode 100644 index 00000000000..f053ebf7976 --- /dev/null +++ b/test/watch/basic/basic.config.js @@ -0,0 +1 @@ +module.exports = {}; diff --git a/test/watch/basic/basic.test.js b/test/watch/basic/basic.test.js index 56752a2a608..852ed265a97 100644 --- a/test/watch/basic/basic.test.js +++ b/test/watch/basic/basic.test.js @@ -47,6 +47,14 @@ describe("basic", () => { } } }); + + proc.stderr.on("data", (chunk) => { + const data = chunk.toString(); + + expect(data).not.toContain( + " No need to use the 'watch' command together with '{ watch: true | false }' or '--watch'/'--no-watch' configuration, it does not make sense.", + ); + }); }); it("should recompile upon file change using the `watch` command", (done) => { @@ -77,6 +85,14 @@ describe("basic", () => { } } }); + + proc.stderr.on("data", (chunk) => { + const data = chunk.toString(); + + expect(data).not.toContain( + " No need to use the 'watch' command together with '{ watch: true | false }' or '--watch'/'--no-watch' configuration, it does not make sense.", + ); + }); }); it("should recompile upon file change using the `watch` command and entries syntax", (done) => { diff --git a/yarn.lock b/yarn.lock index ff59bfe5036..5e17ba81337 100644 --- a/yarn.lock +++ b/yarn.lock @@ -793,14 +793,14 @@ resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.5.1.tgz#cdd35dce4fa1a89a4fd42b1599eb35b3af408884" integrity sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ== -"@eslint/eslintrc@^2.0.2": - version "2.0.2" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.0.2.tgz#01575e38707add677cf73ca1589abba8da899a02" - integrity sha512-3W4f5tDUra+pA+FzgugqL2pRimUTDJWKr7BINqOpkZrC0uYI0NIc0/JFgBROCU07HR6GieA5m3/rsPIhDmCXTQ== +"@eslint/eslintrc@^2.0.3": + version "2.0.3" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.0.3.tgz#4910db5505f4d503f27774bf356e3704818a0331" + integrity sha512-+5gy6OQfk+xx3q0d6jGZZC3f3KzAkXc/IanVxd1is/VIIziRqqt3ongQz0FiTUXqTk0c7aDB3OaFuKnuSoJicQ== dependencies: ajv "^6.12.4" debug "^4.3.2" - espree "^9.5.1" + espree "^9.5.2" globals "^13.19.0" ignore "^5.2.0" import-fresh "^3.2.1" @@ -808,10 +808,10 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@8.39.0": - version "8.39.0" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.39.0.tgz#58b536bcc843f4cd1e02a7e6171da5c040f4d44b" - integrity sha512-kf9RB0Fg7NZfap83B3QOqOGg9QmD9yBudqQXzzOtn3i4y7ZUXe5ONeW34Gwi+TxhH4mvj72R1Zc300KUMa9Bng== +"@eslint/js@8.40.0": + version "8.40.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.40.0.tgz#3ba73359e11f5a7bd3e407f70b3528abfae69cec" + integrity sha512-ElyB54bJIhXQYVKjDSvCkPO1iU1tSAeVQJbllWJq1XQSmmA4dgFk8CbiBGpiOPxleE48vDogxCtmMYku4HSVLA== "@gar/promisify@^1.0.1", "@gar/promisify@^1.1.3": version "1.1.3" @@ -4402,20 +4402,20 @@ eslint-visitor-keys@^1.1.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e" integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ== -eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz#c7f0f956124ce677047ddbc192a68f999454dedc" - integrity sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ== +eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1: + version "3.4.1" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz#c22c48f48942d08ca824cc526211ae400478a994" + integrity sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA== eslint@^8.33.0: - version "8.39.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.39.0.tgz#7fd20a295ef92d43809e914b70c39fd5a23cf3f1" - integrity sha512-mwiok6cy7KTW7rBpo05k6+p4YVZByLNjAZ/ACB9DRCu4YDRwjXI01tWHp6KAUWelsBetTxKK/2sHB0vdS8Z2Og== + version "8.40.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.40.0.tgz#a564cd0099f38542c4e9a2f630fa45bf33bc42a4" + integrity sha512-bvR+TsP9EHL3TqNtj9sCNJVAFK3fBN8Q7g5waghxyRsPLIMwL73XSKnZFK0hk/O2ANC+iAoq6PWMQ+IfBAJIiQ== dependencies: "@eslint-community/eslint-utils" "^4.2.0" "@eslint-community/regexpp" "^4.4.0" - "@eslint/eslintrc" "^2.0.2" - "@eslint/js" "8.39.0" + "@eslint/eslintrc" "^2.0.3" + "@eslint/js" "8.40.0" "@humanwhocodes/config-array" "^0.11.8" "@humanwhocodes/module-importer" "^1.0.1" "@nodelib/fs.walk" "^1.2.8" @@ -4426,8 +4426,8 @@ eslint@^8.33.0: doctrine "^3.0.0" escape-string-regexp "^4.0.0" eslint-scope "^7.2.0" - eslint-visitor-keys "^3.4.0" - espree "^9.5.1" + eslint-visitor-keys "^3.4.1" + espree "^9.5.2" esquery "^1.4.2" esutils "^2.0.2" fast-deep-equal "^3.1.3" @@ -4453,14 +4453,14 @@ eslint@^8.33.0: strip-json-comments "^3.1.0" text-table "^0.2.0" -espree@^9.5.1: - version "9.5.1" - resolved "https://registry.yarnpkg.com/espree/-/espree-9.5.1.tgz#4f26a4d5f18905bf4f2e0bd99002aab807e96dd4" - integrity sha512-5yxtHSZXRSW5pvv3hAlXM5+/Oswi1AUFqBmbibKb5s6bp3rGIDkyXU6xCoyuuLhijr4SFwPrXRoZjz0AZDN9tg== +espree@^9.5.2: + version "9.5.2" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.5.2.tgz#e994e7dc33a082a7a82dceaf12883a829353215b" + integrity sha512-7OASN1Wma5fum5SrNhFMAMJxOUAbhyfQ8dQ//PJaJbNw0URTPWqIghHWt1MmAANKhHZIYOHruW4Kw4ruUWOdGw== dependencies: acorn "^8.8.0" acorn-jsx "^5.3.2" - eslint-visitor-keys "^3.4.0" + eslint-visitor-keys "^3.4.1" esprima@^4.0.0, esprima@^4.0.1: version "4.0.1" @@ -9831,12 +9831,12 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA== -"typescript@^3 || ^4", typescript@^4.9.3: +"typescript@^3 || ^4": version "4.9.5" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a" integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g== -"typescript@^4.6.4 || ^5.0.0": +"typescript@^4.6.4 || ^5.0.0", typescript@^5.0.4: version "5.0.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b" integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==