From 9628cc952cc0bfa45c893a94d0b849388c328663 Mon Sep 17 00:00:00 2001 From: Will Binns-Smith Date: Mon, 24 Feb 2025 10:43:26 -0800 Subject: [PATCH] Webpack: handle file:// urls when finding sourcemaps Previously we only handled the eval sourcemaps case where the module id was encoded into the source url. This handles cases when the `file://` protocol is used, such as with Rspack. Test Plan: `pnpm test-dev-rspack test/development/acceptance-app/rsc-runtime-errors.test.ts` --- .../components/react-dev-overlay/server/middleware-webpack.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/next/src/client/components/react-dev-overlay/server/middleware-webpack.ts b/packages/next/src/client/components/react-dev-overlay/server/middleware-webpack.ts index 1c56a3b5b2978..1719b2029262d 100644 --- a/packages/next/src/client/components/react-dev-overlay/server/middleware-webpack.ts +++ b/packages/next/src/client/components/react-dev-overlay/server/middleware-webpack.ts @@ -287,6 +287,9 @@ async function getSource( ): Promise { const { getCompilations } = options + // Rspack is now using file:// URLs for source maps. Remove the rsc prefix to produce the file:/// url. + sourceURL = sourceURL.replace(/(.*)\/(?=file:\/\/)/, '') + let nativeSourceMap: SourceMap | undefined try { nativeSourceMap = findSourceMap(sourceURL)