diff --git a/packages/next/src/build/webpack/config/ignore-list.ts b/packages/next/src/build/webpack/config/ignore-list.ts new file mode 100644 index 0000000000000..266eccf10c2c6 --- /dev/null +++ b/packages/next/src/build/webpack/config/ignore-list.ts @@ -0,0 +1,7 @@ +export function shouldIgnorePath(modulePath: string): boolean { + return ( + modulePath.includes('node_modules') || + // Only relevant for when Next.js is symlinked e.g. in the Next.js monorepo + modulePath.includes('next/dist') + ) +} diff --git a/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts b/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts index a8c991fd09465..76a65f621aa7a 100644 --- a/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts +++ b/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts @@ -1,6 +1,9 @@ import { bold, cyan, green, red, yellow } from '../../../../lib/picocolors' import { SimpleWebpackError } from './simpleWebpackError' -import { createOriginalStackFrame } from '../../../../client/components/react-dev-overlay/server/middleware' +import { + createOriginalStackFrame, + getIgnoredSources, +} from '../../../../client/components/react-dev-overlay/server/middleware' import type { webpack } from 'next/dist/compiled/webpack/webpack' // Based on https://github.com/webpack/webpack/blob/fcdd04a833943394bbb0a9eeb54a962a24cc7e41/lib/stats/DefaultStatsFactoryPlugin.js#L422-L431 @@ -62,6 +65,7 @@ async function getSourceFrame( source: { type: 'bundle', sourceMap, + ignoredSources: getIgnoredSources(sourceMap), compilation, moduleId, modulePath: fileName, diff --git a/packages/next/src/client/components/react-dev-overlay/internal/container/RuntimeError/CallStackFrame.tsx b/packages/next/src/client/components/react-dev-overlay/internal/container/RuntimeError/CallStackFrame.tsx index 7a3f4e5c09075..d6afb06e61784 100644 --- a/packages/next/src/client/components/react-dev-overlay/internal/container/RuntimeError/CallStackFrame.tsx +++ b/packages/next/src/client/components/react-dev-overlay/internal/container/RuntimeError/CallStackFrame.tsx @@ -37,7 +37,7 @@ export const CallStackFrame: React.FC<{ return (