From 06108ba0694b0c360ad38cd48a578be68e64caa6 Mon Sep 17 00:00:00 2001 From: UncleJart Date: Tue, 30 Jan 2024 12:57:43 +0200 Subject: [PATCH] fix: add fallbacks to `moduleName` and `loc` webpack 5 error fields if not present in error formatter (#447) --- middleware.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/middleware.js b/middleware.js index 62985cc..55dd14c 100644 --- a/middleware.js +++ b/middleware.js @@ -193,7 +193,9 @@ function formatErrors(errors) { // Convert webpack@5 error info into a backwards-compatible flat string return errors.map(function (error) { - return error.moduleName + ' ' + error.loc + '\n' + error.message; + var moduleName = error.moduleName || ''; + var loc = error.loc || ''; + return moduleName + ' ' + loc + '\n' + error.message; }); }