From ad5b12067951f1fa173c6a3dccfa6969e8415cfe Mon Sep 17 00:00:00 2001 From: ChenKS12138 Date: Wed, 5 Apr 2023 02:53:38 +0800 Subject: [PATCH] fix: stack track point to incorrect file. (#3004) --- packages/vite-node/src/source-map-handler.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/vite-node/src/source-map-handler.ts b/packages/vite-node/src/source-map-handler.ts index 1d542fdcba6a..c95640503346 100644 --- a/packages/vite-node/src/source-map-handler.ts +++ b/packages/vite-node/src/source-map-handler.ts @@ -192,8 +192,10 @@ function mapSourcePosition(position: OriginalMapping) { // better to give a precise location in the compiled file than a vague // location in the original file. if (originalPosition.source !== null) { + // `originalPositionFor` do not return the expected file source. So use `position.source` + // instead of `originalPosition.source` originalPosition.source = supportRelativeURL( - sourceMap.url, originalPosition.source) + sourceMap.url, position.source) return originalPosition } }