Skip to content

Commit d4d1825

Browse files
committed
refactor!: remove onAfterSetupMiddleware and onBeforeSetupMiddleware options (#4678)
1 parent a3a41d4 commit d4d1825

9 files changed

+13
-407
lines changed

lib/Server.js

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ const schema = require("./options.json");
198198
* @property {boolean} [setupExitSignals]
199199
* @property {boolean | ClientConfiguration} [client]
200200
* @property {Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response>) => Headers)} [headers]
201-
* @property {(devServer: Server) => void} [onAfterSetupMiddleware]
202-
* @property {(devServer: Server) => void} [onBeforeSetupMiddleware]
203201
* @property {(devServer: Server) => void} [onListening]
204202
* @property {(middlewares: Middleware[], devServer: Server) => Middleware[]} [setupMiddlewares]
205203
*/
@@ -1259,24 +1257,6 @@ class Server {
12591257
(options.open) = [...getOpenItemsFromObject(options.open)];
12601258
}
12611259

1262-
if (options.onAfterSetupMiddleware) {
1263-
// TODO: remove in the next major release
1264-
util.deprecate(
1265-
() => {},
1266-
"'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.",
1267-
`DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE`
1268-
)();
1269-
}
1270-
1271-
if (options.onBeforeSetupMiddleware) {
1272-
// TODO: remove in the next major release
1273-
util.deprecate(
1274-
() => {},
1275-
"'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.",
1276-
`DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE`
1277-
)();
1278-
}
1279-
12801260
if (typeof options.port === "string" && options.port !== "auto") {
12811261
options.port = Number(options.port);
12821262
}
@@ -2022,10 +2002,6 @@ class Server {
20222002
middlewares.push({ name: "compression", middleware: compression() });
20232003
}
20242004

2025-
if (typeof this.options.onBeforeSetupMiddleware === "function") {
2026-
this.options.onBeforeSetupMiddleware(this);
2027-
}
2028-
20292005
if (typeof this.options.headers !== "undefined") {
20302006
middlewares.push({
20312007
name: "set-headers",
@@ -2326,10 +2302,6 @@ class Server {
23262302
(this.app).use(middleware.middleware);
23272303
}
23282304
});
2329-
2330-
if (typeof this.options.onAfterSetupMiddleware === "function") {
2331-
this.options.onAfterSetupMiddleware(this);
2332-
}
23332305
}
23342306

23352307
/**

lib/options.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -351,16 +351,6 @@
351351
},
352352
"link": "https://webpack.js.org/configuration/dev-server/#devservermagichtml"
353353
},
354-
"OnAfterSetupMiddleware": {
355-
"instanceof": "Function",
356-
"description": "Provides the ability to execute a custom function and apply custom middleware(s) after all other middlewares. Deprecated: please use the 'setupMiddlewares' option.",
357-
"link": "https://webpack.js.org/configuration/dev-server/#devserveronaftersetupmiddleware"
358-
},
359-
"OnBeforeSetupMiddleware": {
360-
"instanceof": "Function",
361-
"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.",
362-
"link": "https://webpack.js.org/configuration/dev-server/#devserveronbeforesetupmiddleware"
363-
},
364354
"OnListening": {
365355
"instanceof": "Function",
366356
"description": "Provides the ability to execute a custom function when dev server starts listening.",
@@ -983,12 +973,6 @@
983973
"magicHtml": {
984974
"$ref": "#/definitions/MagicHTML"
985975
},
986-
"onAfterSetupMiddleware": {
987-
"$ref": "#/definitions/OnAfterSetupMiddleware"
988-
},
989-
"onBeforeSetupMiddleware": {
990-
"$ref": "#/definitions/OnBeforeSetupMiddleware"
991-
},
992976
"onListening": {
993977
"$ref": "#/definitions/OnListening"
994978
},

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

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

385-
exports[`options validate should throw an error on the "onAfterSetupMiddleware" option with 'false' value 1`] = `
386-
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
387-
- options.onAfterSetupMiddleware should be an instance of function.
388-
-> Provides the ability to execute a custom function and apply custom middleware(s) after all other middlewares. Deprecated: please use the 'setupMiddlewares' option.
389-
-> Read more at https://webpack.js.org/configuration/dev-server/#devserveronaftersetupmiddleware"
390-
`;
391-
392-
exports[`options validate should throw an error on the "onBeforeSetupMiddleware" option with 'false' value 1`] = `
393-
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
394-
- options.onBeforeSetupMiddleware should be an instance of function.
395-
-> Provides the ability to execute a custom function and apply custom middleware(s) prior to all other middlewares. Deprecated: please use the 'setupMiddlewares' option.
396-
-> Read more at https://webpack.js.org/configuration/dev-server/#devserveronbeforesetupmiddleware"
397-
`;
398-
399385
exports[`options validate should throw an error on the "onListening" option with '' value 1`] = `
400386
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
401387
- 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)