diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index f068ecdc56e..c80006ab0d4 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -540,9 +540,6 @@ yarn add webpack-cli --dev --no-amd Negates amd --no-bail Negates bail --no-cache Negates cache - --no-cache-immutable-paths-reset Negates cache-immutable-paths-reset - --no-dependencies-reset Negates dependencies-reset - --no-entry-reset Negates entry-reset --no-experiments-asset Negates experiments-asset --no-experiments-async-web-assembly Negates experiments-async-web-assembly --no-experiments-import-async Negates experiments-import-async @@ -551,13 +548,9 @@ yarn add webpack-cli --dev --no-experiments-output-module Negates experiments-output-module --no-experiments-sync-web-assembly Negates experiments-sync-web-assembly --no-experiments-top-level-await Negates experiments-top-level-await - --no-externals-reset Negates externals-reset - --no-infrastructure-logging-debug-reset Negates infrastructure-logging-debug-reset --no-module-expr-context-critical Negates module-expr-context-critical --no-module-expr-context-recursive Negates module-expr-context-recursive - --no-module-no-parse-reset Negates module-no-parse-reset --no-module-rules-side-effects Negates module-rules-side-effects - --no-module-rules-reset Negates module-rules-reset --no-module-strict-export-presence Negates module-strict-export-presence --no-module-strict-this-context-on-imports Negates module-strict-this-context-on-imports --no-module-unknown-context-critical Negates module-unknown-context-critical @@ -585,13 +578,7 @@ yarn add webpack-cli --dev --no-optimization-split-chunks-hide-path-info Negates optimization-split-chunks-hide-path-info --no-optimization-used-exports Negates optimization-used-exports --no-output-compare-before-emit Negates output-compare-before-emit - --no-output-enabled-library-types-reset Negates output-enabled-library-types-reset --no-output-iife Negates output-iife - --no-output-library-reset Negates output-library-reset - --no-output-library-root-reset Negates output-library-root-reset - --no-output-library-export-reset Negates output-library-export-reset - --no-output-library-name-reset Negates output-library-name-reset - --no-output-library-name-root-reset Negates output-library-name-root-reset --no-output-library-umd-named-define Negates output-library-umd-named-define --no-output-module Negates output-module --no-output-pathinfo Negates output-pathinfo @@ -599,47 +586,19 @@ yarn add webpack-cli --dev --no-performance Negates performance --no-profile Negates profile --no-resolve-alias-only-module Negates resolve-alias-only-module - --no-resolve-alias-reset Negates resolve-alias-reset - --no-resolve-alias-fields-reset Negates resolve-alias-fields-reset --no-resolve-cache Negates resolve-cache --no-resolve-cache-with-context Negates resolve-cache-with-context - --no-resolve-condition-names-reset Negates resolve-condition-names-reset - --no-resolve-description-files-reset Negates resolve-description-files-reset - --no-resolve-enforce-extension Negates resolve-enforce-extension - --no-resolve-exports-fields-reset Negates resolve-exports-fields-reset - --no-resolve-extensions-reset Negates resolve-extensions-reset - --no-resolve-fully-specified Negates resolve-fully-specified - --no-resolve-main-fields-reset Negates resolve-main-fields-reset - --no-resolve-main-files-reset Negates resolve-main-files-reset - --no-resolve-modules-reset Negates resolve-modules-reset - --no-resolve-restrictions-reset Negates resolve-restrictions-reset - --no-resolve-roots-reset Negates resolve-roots-reset --no-resolve-symlinks Negates resolve-symlinks --no-resolve-unsafe-cache Negates resolve-unsafe-cache --no-resolve-use-sync-file-system-calls Negates resolve-use-sync-file-system-calls --no-resolve-loader-alias-only-module Negates resolve-loader-alias-only-module - --no-resolve-loader-alias-reset Negates resolve-loader-alias-reset - --no-resolve-loader-alias-fields-reset Negates resolve-loader-alias-fields-reset --no-resolve-loader-cache Negates resolve-loader-cache --no-resolve-loader-cache-with-context Negates resolve-loader-cache-with-context - --no-resolve-loader-condition-names-reset Negates resolve-loader-condition-names-reset - --no-resolve-loader-description-files-reset Negates resolve-loader-description-files-reset - --no-resolve-loader-enforce-extension Negates resolve-loader-enforce-extension - --no-resolve-loader-exports-fields-reset Negates resolve-loader-exports-fields-reset - --no-resolve-loader-extensions-reset Negates resolve-loader-extensions-reset - --no-resolve-loader-fully-specified Negates resolve-loader-fully-specified - --no-resolve-loader-main-fields-reset Negates resolve-loader-main-fields-reset - --no-resolve-loader-main-files-reset Negates resolve-loader-main-files-reset - --no-resolve-loader-modules-reset Negates resolve-loader-modules-reset - --no-resolve-loader-restrictions-reset Negates resolve-loader-restrictions-reset - --no-resolve-loader-roots-reset Negates resolve-loader-roots-reset --no-resolve-loader-symlinks Negates resolve-loader-symlinks --no-resolve-loader-unsafe-cache Negates resolve-loader-unsafe-cache --no-resolve-loader-use-sync-file-system-calls Negates resolve-loader-use-sync-file-system-calls --no-snapshot-build-dependencies-hash Negates snapshot-build-dependencies-hash --no-snapshot-build-dependencies-timestamp Negates snapshot-build-dependencies-timestamp - --no-snapshot-immutable-paths-reset Negates snapshot-immutable-paths-reset - --no-snapshot-managed-paths-reset Negates snapshot-managed-paths-reset --no-snapshot-module-hash Negates snapshot-module-hash --no-snapshot-module-timestamp Negates snapshot-module-timestamp --no-snapshot-resolve-hash Negates snapshot-resolve-hash @@ -665,11 +624,8 @@ yarn add webpack-cli --dev --no-stats-error-details Negates stats-error-details --no-stats-error-stack Negates stats-error-stack --no-stats-errors Negates stats-errors - --no-stats-exclude-assets-reset Negates stats-exclude-assets-reset - --no-stats-exclude-modules-reset Negates stats-exclude-modules-reset --no-stats-hash Negates stats-hash --no-stats-ids Negates stats-ids - --no-stats-logging-debug-reset Negates stats-logging-debug-reset --no-stats-logging-trace Negates stats-logging-trace --no-stats-module-assets Negates stats-module-assets --no-stats-module-trace Negates stats-module-trace @@ -688,8 +644,6 @@ yarn add webpack-cli --dev --no-stats-used-exports Negates stats-used-exports --no-stats-version Negates stats-version --no-stats-warnings Negates stats-warnings - --no-stats-warnings-filter-reset Negates stats-warnings-filter-reset - --no-watch-options-ignored-reset Negates watch-options-ignored-reset --no-watch-options-stdin Negates watch-options-stdin ``` diff --git a/packages/webpack-cli/lib/utils/cli-flags.js b/packages/webpack-cli/lib/utils/cli-flags.js index bc874e1e7f9..8ab115bf3b6 100644 --- a/packages/webpack-cli/lib/utils/cli-flags.js +++ b/packages/webpack-cli/lib/utils/cli-flags.js @@ -250,7 +250,7 @@ let flagsFromCore = meta.usage = `--${flag} `; } else { meta.type = Boolean; - meta.negative = true; + meta.negative = !flag.endsWith('-reset'); meta.usage = `--${flag}`; } return { diff --git a/test/core-flags/module-flags.test.js b/test/core-flags/module-flags.test.js index f6a8aa71802..2d7a79a2c68 100644 --- a/test/core-flags/module-flags.test.js +++ b/test/core-flags/module-flags.test.js @@ -28,18 +28,17 @@ describe('module config related flag', () => { } }); - it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); - expect(stderr).toBeFalsy(); - if (flag.name.includes('-reset')) { - const option = propName.split('Reset')[0]; - expect(stdout).toContain(`${option}: []`); - } else if (flag.name.includes('rules-')) { - expect(stdout).toContain('sideEffects: false'); - } else { - expect(stdout).toContain(`${propName}: false`); - } - }); + if (!flag.name.endsWith('-reset')) { + it(`should config --no-${flag.name} correctly`, () => { + const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); + expect(stderr).toBeFalsy(); + if (flag.name.includes('rules-')) { + expect(stdout).toContain('sideEffects: false'); + } else { + expect(stdout).toContain(`${propName}: false`); + } + }); + } } if (flag.type === String) { diff --git a/test/core-flags/output-flags.test.js b/test/core-flags/output-flags.test.js index 7bda29b938f..15e8f0163a6 100644 --- a/test/core-flags/output-flags.test.js +++ b/test/core-flags/output-flags.test.js @@ -32,25 +32,14 @@ describe('output config related flag', () => { } }); - it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); + if (!flag.name.endsWith('-reset')) { + it(`should config --no-${flag.name} correctly`, () => { + const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); - if (flag.name.includes('loading-types-reset')) { - expect(stderr).toBeFalsy(); - if (flag.name === 'output-enabled-wasm-loading-types-reset') { - expect(stdout).toContain(`enabledWasmLoadingTypes: [ 'fetch' ]`); - } else { - expect(stdout).toContain(`enabledChunkLoadingTypes: [ 'jsonp', 'import-scripts' ]`); - } - } else if (flag.name.includes('-reset')) { - const option = propName.split('Reset')[0]; - expect(stderr).toBeFalsy(); - expect(stdout).toContain(`${option}: []`); - } else { expect(stderr).toBeFalsy(); expect(stdout).toContain(`${propName}: false`); - } - }); + }); + } } if (flag.type === Number) { diff --git a/test/core-flags/stats-flags.test.js b/test/core-flags/stats-flags.test.js index be141e097e3..f43076ee660 100644 --- a/test/core-flags/stats-flags.test.js +++ b/test/core-flags/stats-flags.test.js @@ -24,16 +24,14 @@ describe('stats config related flag', () => { } }); - it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); + if (!flag.name.endsWith('-reset')) { + it(`should config --no-${flag.name} correctly`, () => { + const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); - expect(stderr).toBeFalsy(); - if (flag.name.includes('reset')) { - expect(stdout).toContain(`stats: {}`); - } else { + expect(stderr).toBeFalsy(); expect(stdout).toContain(`stats: { ${propName}: false }`); - } - }); + }); + } } if (flag.type === Number) { diff --git a/test/core-flags/watch-flags.test.js b/test/core-flags/watch-flags.test.js index ff8208ee2e4..ef777ca7a33 100644 --- a/test/core-flags/watch-flags.test.js +++ b/test/core-flags/watch-flags.test.js @@ -23,16 +23,14 @@ describe('watch config related flag', () => { } }); - it(`should config --no-${flag.name} correctly`, () => { - const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); + if (!flag.name.endsWith('-reset')) { + it(`should config --no-${flag.name} correctly`, () => { + const { stderr, stdout } = run(__dirname, [`--no-${flag.name}`]); - expect(stderr).toBeFalsy(); - if (flag.name.includes('reset')) { - expect(stdout).toContain('watch: false'); - } else { + expect(stderr).toBeFalsy(); expect(stdout).toContain(`watchOptions: { ${propName}: false }`); - } - }); + }); + } } if (flag.type === Number) {