Skip to content

Commit 654a77f

Browse files
committed
refactor!: remove onAfterSetupMiddleware and onBeforeSetupMiddleware options (#4678)
1 parent efbd6e9 commit 654a77f

9 files changed

+86
-558
lines changed

lib/Server.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,6 @@ const schema = require("./options.json");
200200
* @property {boolean} [setupExitSignals]
201201
* @property {boolean | ClientConfiguration} [client]
202202
* @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
203-
* @property {(devServer: Server) => void} [onAfterSetupMiddleware]
204-
* @property {(devServer: Server) => void} [onBeforeSetupMiddleware]
205203
* @property {(devServer: Server) => void} [onListening]
206204
* @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
207205
*/
@@ -1306,24 +1304,6 @@ class Server {
13061304
(options.open) = [...getOpenItemsFromObject(options.open)];
13071305
}
13081306

1309-
if (options.onAfterSetupMiddleware) {
1310-
// TODO: remove in the next major release
1311-
util.deprecate(
1312-
() => {},
1313-
"'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.",
1314-
`DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE`
1315-
)();
1316-
}
1317-
1318-
if (options.onBeforeSetupMiddleware) {
1319-
// TODO: remove in the next major release
1320-
util.deprecate(
1321-
() => {},
1322-
"'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.",
1323-
`DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE`
1324-
)();
1325-
}
1326-
13271307
if (typeof options.port === "string" && options.port !== "auto") {
13281308
options.port = Number(options.port);
13291309
}
@@ -2068,10 +2048,6 @@ class Server {
20682048
middlewares.push({ name: "compression", middleware: compression() });
20692049
}
20702050

2071-
if (typeof this.options.onBeforeSetupMiddleware === "function") {
2072-
this.options.onBeforeSetupMiddleware(this);
2073-
}
2074-
20752051
if (typeof this.options.headers !== "undefined") {
20762052
middlewares.push({
20772053
name: "set-headers",
@@ -2372,10 +2348,6 @@ class Server {
23722348
(this.app).use(middleware.middleware);
23732349
}
23742350
});
2375-
2376-
if (typeof this.options.onAfterSetupMiddleware === "function") {
2377-
this.options.onAfterSetupMiddleware(this);
2378-
}
23792351
}
23802352

23812353
/**

lib/options.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -375,16 +375,6 @@
375375
},
376376
"link": "https://webpack.js.org/configuration/dev-server/#devservermagichtml"
377377
},
378-
"OnAfterSetupMiddleware": {
379-
"instanceof": "Function",
380-
"description": "Provides the ability to execute a custom function and apply custom middleware(s) after all other middlewares. Deprecated: please use the 'setupMiddlewares' option.",
381-
"link": "https://webpack.js.org/configuration/dev-server/#devserveronaftersetupmiddleware"
382-
},
383-
"OnBeforeSetupMiddleware": {
384-
"instanceof": "Function",
385-
"description": "Provides the ability to execute a custom function and apply custom middleware(s) prior to all other middlewares. Deprecated: please use the 'setupMiddlewares' option.",
386-
"link": "https://webpack.js.org/configuration/dev-server/#devserveronbeforesetupmiddleware"
387-
},
388378
"OnListening": {
389379
"instanceof": "Function",
390380
"description": "Provides the ability to execute a custom function when dev server starts listening.",
@@ -1007,12 +997,6 @@
1007997
"magicHtml": {
1008998
"$ref": "#/definitions/MagicHTML"
1009999
},
1010-
"onAfterSetupMiddleware": {
1011-
"$ref": "#/definitions/OnAfterSetupMiddleware"
1012-
},
1013-
"onBeforeSetupMiddleware": {
1014-
"$ref": "#/definitions/OnBeforeSetupMiddleware"
1015-
},
10161000
"onListening": {
10171001
"$ref": "#/definitions/OnListening"
10181002
},

test/__snapshots__/validate-options.test.js.snap.webpack5

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -402,20 +402,6 @@ exports[`options validate should throw an error on the "magicHtml" option with '
402402
-> Read more at https://webpack.js.org/configuration/dev-server/#devservermagichtml"
403403
`;
404404

405-
exports[`options validate should throw an error on the "onAfterSetupMiddleware" option with 'false' value 1`] = `
406-
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
407-
- options.onAfterSetupMiddleware should be an instance of function.
408-
-> Provides the ability to execute a custom function and apply custom middleware(s) after all other middlewares. Deprecated: please use the 'setupMiddlewares' option.
409-
-> Read more at https://webpack.js.org/configuration/dev-server/#devserveronaftersetupmiddleware"
410-
`;
411-
412-
exports[`options validate should throw an error on the "onBeforeSetupMiddleware" option with 'false' value 1`] = `
413-
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
414-
- options.onBeforeSetupMiddleware should be an instance of function.
415-
-> Provides the ability to execute a custom function and apply custom middleware(s) prior to all other middlewares. Deprecated: please use the 'setupMiddlewares' option.
416-
-> Read more at https://webpack.js.org/configuration/dev-server/#devserveronbeforesetupmiddleware"
417-
`;
418-
419405
exports[`options validate should throw an error on the "onListening" option with '' value 1`] = `
420406
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
421407
- options.onListening should be an instance of function.

test/e2e/__snapshots__/on-after-setup-middleware.test.js.snap.webpack5

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/e2e/__snapshots__/on-before-setup-middleware.test.js.snap.webpack5

Lines changed: 0 additions & 21 deletions
This file was deleted.

test/e2e/on-after-setup-middleware.test.js

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)