diff --git a/packages/next/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts b/packages/next/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts index 465dec54fd24a..42fe8e8851884 100644 --- a/packages/next/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts +++ b/packages/next/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts @@ -82,7 +82,10 @@ export async function getNotFoundError( .map(({ origin }) => origin.readableIdentifier(compilation.requestShortener) ) - .filter((name) => name && !name.includes('next-client-pages-loader.js')) + .filter( + (name) => + name && !/next-(middleware|client-pages)-loader\.js/.test(name) + ) if (moduleTrace.length === 0) return '' return `\nImport trace for requested module:\n${moduleTrace.join( diff --git a/packages/next/client/dev/error-overlay/format-webpack-messages.js b/packages/next/client/dev/error-overlay/format-webpack-messages.js index 55c868192e0ee..1fe458fc2935b 100644 --- a/packages/next/client/dev/error-overlay/format-webpack-messages.js +++ b/packages/next/client/dev/error-overlay/format-webpack-messages.js @@ -38,7 +38,8 @@ function formatMessage(message, verbose) { const filteredModuleTrace = message.moduleTrace && message.moduleTrace.filter( - (trace) => !trace.originName.includes('next-client-pages-loader.js') + (trace) => + !/next-(middleware|client-pages)-loader\.js/.test(trace.originName) ) message = (message.moduleName ? stripAnsi(message.moduleName) + '\n' : '') +