This commit refactors the middleware application logic in the webpack-dev-server codebase to ensure that middleware is applied only once, regardless of how many times it's called.
Previously, certain middleware, such as static serving middleware, was being applied multiple times to support features like historyApiFallback. This refactor eliminates duplicate middleware application by introducing a mechanism to track applied middleware and applying each middleware only once.
Changes:
Introduced appliedMiddleware array to track applied middleware.
Created applyMiddlewareOnce function to apply middleware only if it hasn't been applied before.
Updated webpack-dev-server codebase to utilize applyMiddlewareOnce for applying middleware associated with various features.
This update aims to improve code efficiency and prevent unintended behavior or performance issues caused by duplicate middleware application.
This commit refactors the middleware application logic in the webpack-dev-server codebase to ensure that middleware is applied only once, regardless of how many times it's called.
Previously, certain middleware, such as static serving middleware, was being applied multiple times to support features like
historyApiFallback
. This refactor eliminates duplicate middleware application by introducing a mechanism to track applied middleware and applying each middleware only once.Changes:
appliedMiddleware
array to track applied middleware.applyMiddlewareOnce
function to apply middleware only if it hasn't been applied before.applyMiddlewareOnce
for applying middleware associated with various features.This update aims to improve code efficiency and prevent unintended behavior or performance issues caused by duplicate middleware application.
Fixes: #2716
For Bugs and Features; did you add new tests?
Motivation / Use-Case
Breaking Changes
Additional Info