diff --git a/packages/webpack-cli/src/webpack-cli.ts b/packages/webpack-cli/src/webpack-cli.ts index 977f8904ab8..cf0f172159b 100644 --- a/packages/webpack-cli/src/webpack-cli.ts +++ b/packages/webpack-cli/src/webpack-cli.ts @@ -130,6 +130,7 @@ interface CommandOption { negatedDescription?: string; defaultValue?: string; hidden?: boolean; + negativeHidden?: boolean; group?: "core"; } @@ -831,7 +832,7 @@ class WebpackCLI { false, ); - optionForCommand.hidden = option.hidden || false; + optionForCommand.hidden = option.hidden || option.negativeHidden || false; command.addOption(optionForCommand); } @@ -1010,8 +1011,10 @@ class WebpackCLI { }, ]; - // Options from webpack core to be included in the minimum help output - const minimumHelpFlags = [ + // Extract all the flags being exported from core. + // A list of cli flags generated by core can be found here https://github.com/webpack/webpack/blob/main/test/__snapshots__/Cli.basictest.js.snap + // Fast search, `includes` is slow + const minHelpSet = new Set([ "mode", "watch", "watch-options-stdin", @@ -1022,12 +1025,8 @@ class WebpackCLI { "name", "output-path", "extends", - ]; - - // Extract all the flags being exported from core. - // A list of cli flags generated by core can be found here https://github.com/webpack/webpack/blob/main/test/__snapshots__/Cli.basictest.js.snap - // Fast search, `includes` is slow - const minHelpSet = new Set(minimumHelpFlags); + ]); + const minimumNegativeHelpFlags = new Set(["devtool"]); const coreArgs = this.webpack.cli.getArguments(); // Take memory const options: CommandOption[] = Array.from({ @@ -1047,6 +1046,7 @@ class WebpackCLI { description: meta.description, group: "core", hidden: !minHelpSet.has(name), + negativeHidden: !minimumNegativeHelpFlags.has(name), }; } diff --git a/test/help/__snapshots__/help.test.js.snap.devServer5.webpack5 b/test/help/__snapshots__/help.test.js.snap.devServer5.webpack5 index 175a4f69140..9b5adec60c9 100644 --- a/test/help/__snapshots__/help.test.js.snap.devServer5.webpack5 +++ b/test/help/__snapshots__/help.test.js.snap.devServer5.webpack5 @@ -112,13 +112,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -169,13 +165,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -226,13 +218,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -282,13 +270,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -374,13 +358,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -421,13 +401,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -468,13 +444,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -515,13 +487,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -607,13 +575,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -946,13 +910,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. --allowed-hosts Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --bonjour Allows to broadcasts dev server via ZeroConf networking on start. @@ -1107,13 +1067,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. --allowed-hosts Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --bonjour Allows to broadcasts dev server via ZeroConf networking on start. @@ -1227,13 +1183,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. --allowed-hosts Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --bonjour Allows to broadcasts dev server via ZeroConf networking on start. @@ -1347,13 +1299,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. --allowed-hosts Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --bonjour Allows to broadcasts dev server via ZeroConf networking on start. @@ -1467,13 +1415,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. --allowed-hosts Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --bonjour Allows to broadcasts dev server via ZeroConf networking on start. @@ -1628,13 +1572,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. --allowed-hosts Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --bonjour Allows to broadcasts dev server via ZeroConf networking on start. @@ -1748,13 +1688,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. --allowed-hosts Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --bonjour Allows to broadcasts dev server via ZeroConf networking on start. @@ -1909,13 +1845,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. --allowed-hosts Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --allowed-hosts-reset Clear all items provided in 'allowedHosts' configuration. Allows to enumerate the hosts from which access to the dev server are allowed (useful when you are proxying dev server, by default is 'auto'). --bonjour Allows to broadcasts dev server via ZeroConf networking on start. @@ -2089,11 +2021,8 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -2179,11 +2108,8 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -2224,11 +2150,8 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -2269,11 +2192,8 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -2314,11 +2234,8 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -2404,11 +2321,8 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -2450,13 +2364,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -2533,13 +2443,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -2794,13 +2700,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console. @@ -2849,13 +2751,9 @@ Options: --name Name of the configuration. Used when loading multiple configurations. -o, --output-path The output directory as **absolute path** (required). --stats [value] Stats options object or preset name. - --no-stats Negative 'stats' option. -t, --target Environment to build for. Environment to build for. An array of environments to build for all of them when possible. - --no-target Negative 'target' option. -w, --watch Enter watch mode, which rebuilds on file change. - --no-watch Negative 'watch' option. --watch-options-stdin Stop watching when stdin stream has ended. - --no-watch-options-stdin Negative 'watch-options-stdin' option. Global options: --color Enable colors on console.