diff --git a/OPTIONS.md b/OPTIONS.md index 2175e8b30a0..3d742a08dee 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -14,7 +14,6 @@ Options: --no-hot Disables Hot Module Replacement. --analyze It invokes webpack-bundle-analyzer plugin to get bundle information. --progress [value] Print compilation progress during build. - --prefetch Prefetch this request. -j, --json [value] Prints result as JSON or store it in a file. --fail-on-warnings Stop webpack-cli process with non-zero exit code on warnings from webpack --no-amd Negative 'amd' option. diff --git a/packages/webpack-cli/README.md b/packages/webpack-cli/README.md index a50d0844752..a0466798b35 100644 --- a/packages/webpack-cli/README.md +++ b/packages/webpack-cli/README.md @@ -95,7 +95,6 @@ npx webpack-cli --help verbose --mode Defines the mode to pass to webpack. --name Name of the configuration. Used when loading multiple configurations. -o, --output-path Output location of the file generated by webpack e.g. ./dist/. - --prefetch Prefetch this request --stats [value] It instructs webpack on how to treat the stats e.g. verbose. --no-stats Disable stats output. -t, --target Sets the build target e.g. node. diff --git a/packages/webpack-cli/src/plugins/CLIPlugin.ts b/packages/webpack-cli/src/plugins/CLIPlugin.ts index d319fdcfeea..f53cc835187 100644 --- a/packages/webpack-cli/src/plugins/CLIPlugin.ts +++ b/packages/webpack-cli/src/plugins/CLIPlugin.ts @@ -9,12 +9,6 @@ export class CLIPlugin { this.options = options; } - setupPrefetchPlugin(compiler: Compiler) { - const { PrefetchPlugin } = compiler.webpack || require("webpack"); - - new PrefetchPlugin(null, this.options.prefetch).apply(compiler); - } - async setupBundleAnalyzerPlugin(compiler: Compiler) { // eslint-disable-next-line node/no-extraneous-require,@typescript-eslint/no-var-requires const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); @@ -111,10 +105,6 @@ export class CLIPlugin { this.setupProgressPlugin(compiler); } - if (this.options.prefetch) { - this.setupPrefetchPlugin(compiler); - } - if (this.options.analyze) { this.setupBundleAnalyzerPlugin(compiler); } diff --git a/packages/webpack-cli/src/webpack-cli.ts b/packages/webpack-cli/src/webpack-cli.ts index 8668a6f85c3..ee0a6e669d6 100644 --- a/packages/webpack-cli/src/webpack-cli.ts +++ b/packages/webpack-cli/src/webpack-cli.ts @@ -832,15 +832,6 @@ class WebpackCLI implements IWebpackCLI { ], description: "Print compilation progress during build.", }, - { - name: "prefetch", - configs: [ - { - type: "string", - }, - ], - description: "Prefetch this request.", - }, // Output options { @@ -2301,7 +2292,6 @@ class WebpackCLI implements IWebpackCLI { configPath: config.path.get(item), helpfulOutput: !options.json, progress: options.progress, - prefetch: options.prefetch, analyze: options.analyze, }), ); diff --git a/test/build/prefetch/prefetch.test.js b/test/build/prefetch/prefetch.test.js deleted file mode 100644 index 3b1ca594e63..00000000000 --- a/test/build/prefetch/prefetch.test.js +++ /dev/null @@ -1,46 +0,0 @@ -"use strict"; - -const { join } = require("path"); -const { run, readFile } = require("../../utils/test-utils"); -// eslint-disable-next-line node/no-unpublished-require -const rimraf = require("rimraf"); - -describe("prefetch", () => { - afterEach(() => { - rimraf.sync(join(__dirname, "dist")); - }); - - it("should load the prefetched file", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, [ - "--prefetch", - "./src/p.js", - "--mode", - "development", - ]); - - expect(exitCode).toBe(0); - expect(stderr).toBeFalsy(); - expect(stdout).toBeTruthy(); - - const content = await readFile(join(__dirname, "/dist/main.js"), "utf-8"); - - expect(content).not.toContain("// no prefetching"); - }); - - it("should log error when the prefetched file is absent", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--prefetch", "./src/somefile.js"]); - - expect(exitCode).toBe(1); - expect(stderr).toBeFalsy(); - // Should contain the error message - expect(stdout).toContain(`Error: Can't resolve './src/somefile.js'`); - }); - - it("should log error when flag value is not supplied", async () => { - const { exitCode, stderr, stdout } = await run(__dirname, ["--prefetch"]); - - expect(exitCode).toBe(2); - expect(stderr).toContain(`Error: Option '--prefetch ' argument missing`); - expect(stdout).toBeFalsy(); - }); -}); diff --git a/test/build/prefetch/src/index.js b/test/build/prefetch/src/index.js deleted file mode 100644 index 59d0025c017..00000000000 --- a/test/build/prefetch/src/index.js +++ /dev/null @@ -1,11 +0,0 @@ -async function load() { - const value = await import ( - /* webpackMode: "lazy" */ - /* webpackPrefetch: true */ - './p.js' - ); - - console.log(value); -} - -load(); diff --git a/test/build/prefetch/src/p.js b/test/build/prefetch/src/p.js deleted file mode 100644 index cc132d2393a..00000000000 --- a/test/build/prefetch/src/p.js +++ /dev/null @@ -1,3 +0,0 @@ -console.log("HERE"); - -module.exports = "async-value"; diff --git a/test/build/prefetch/webpack.config.js b/test/build/prefetch/webpack.config.js deleted file mode 100644 index f053ebf7976..00000000000 --- a/test/build/prefetch/webpack.config.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = {};