From 80d04e5421c2db216c3ddeef1c95720715dd298b Mon Sep 17 00:00:00 2001 From: eps1lon Date: Mon, 2 Dec 2024 21:32:54 +0100 Subject: [PATCH] Fix cursor position --- .../react-dev-overlay/server/middleware-turbopack.ts | 9 +++++++-- .../owner-stack-react-missing-key-prop.test.ts | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/next/src/client/components/react-dev-overlay/server/middleware-turbopack.ts b/packages/next/src/client/components/react-dev-overlay/server/middleware-turbopack.ts index d645ecfb0232b3..2358cb9e7cccc6 100644 --- a/packages/next/src/client/components/react-dev-overlay/server/middleware-turbopack.ts +++ b/packages/next/src/client/components/react-dev-overlay/server/middleware-turbopack.ts @@ -229,8 +229,13 @@ async function nativeTraceSource( ?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default') ?.replace('__webpack_exports__.', '') || '', - column: originalPosition.column ?? 0, - file: originalPosition.source, + column: (originalPosition.column ?? 0) + 1, + file: originalPosition.source?.startsWith('file://') + ? path.relative( + process.cwd(), + url.fileURLToPath(originalPosition.source) + ) + : originalPosition.source, lineNumber: originalPosition.line ?? 0, // TODO: c&p from async createOriginalStackFrame but why not frame.arguments? arguments: [], diff --git a/test/development/app-dir/owner-stack-react-missing-key-prop/owner-stack-react-missing-key-prop.test.ts b/test/development/app-dir/owner-stack-react-missing-key-prop/owner-stack-react-missing-key-prop.test.ts index 1edeb793828137..d2f4a84b29978b 100644 --- a/test/development/app-dir/owner-stack-react-missing-key-prop/owner-stack-react-missing-key-prop.test.ts +++ b/test/development/app-dir/owner-stack-react-missing-key-prop/owner-stack-react-missing-key-prop.test.ts @@ -29,12 +29,12 @@ const isOwnerStackEnabled = `"at Page (app/rsc/page.tsx (6:13))"` ) expect(source).toMatchInlineSnapshot(` - "app/rsc/page.tsx (7:9) @ + "app/rsc/page.tsx (7:10) @ 5 |
6 | {list.map((item, index) => ( > 7 | {item} - | ^ + | ^ 8 | ))} 9 |
10 | )"