Skip to content

Commit b966286

Browse files
authored
refactor!: remove onAfterSetupMiddleware and onBeforeSetupMiddleware options (#4678)
1 parent 8996d36 commit b966286

9 files changed

+9
-414
lines changed

lib/Server.js

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

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

2026-
if (typeof this.options.onBeforeSetupMiddleware === "function") {
2027-
this.options.onBeforeSetupMiddleware(this);
2028-
}
2029-
20302006
if (typeof this.options.headers !== "undefined") {
20312007
middlewares.push({
20322008
name: "set-headers",
@@ -2327,10 +2303,6 @@ class Server {
23272303
(this.app).use(middleware.middleware);
23282304
}
23292305
});
2330-
2331-
if (typeof this.options.onAfterSetupMiddleware === "function") {
2332-
this.options.onAfterSetupMiddleware(this);
2333-
}
23342306
}
23352307

23362308
/**

lib/options.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -344,16 +344,6 @@
344344
},
345345
"link": "https://webpack.js.org/configuration/dev-server/#devservermagichtml"
346346
},
347-
"OnAfterSetupMiddleware": {
348-
"instanceof": "Function",
349-
"description": "Provides the ability to execute a custom function and apply custom middleware(s) after all other middlewares. Deprecated: please use the 'setupMiddlewares' option.",
350-
"link": "https://webpack.js.org/configuration/dev-server/#devserveronaftersetupmiddleware"
351-
},
352-
"OnBeforeSetupMiddleware": {
353-
"instanceof": "Function",
354-
"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.",
355-
"link": "https://webpack.js.org/configuration/dev-server/#devserveronbeforesetupmiddleware"
356-
},
357347
"OnListening": {
358348
"instanceof": "Function",
359349
"description": "Provides the ability to execute a custom function when dev server starts listening.",
@@ -976,12 +966,6 @@
976966
"magicHtml": {
977967
"$ref": "#/definitions/MagicHTML"
978968
},
979-
"onAfterSetupMiddleware": {
980-
"$ref": "#/definitions/OnAfterSetupMiddleware"
981-
},
982-
"onBeforeSetupMiddleware": {
983-
"$ref": "#/definitions/OnBeforeSetupMiddleware"
984-
},
985969
"onListening": {
986970
"$ref": "#/definitions/OnListening"
987971
},

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)