Skip to content

Commit bf7b36a

Browse files
authoredDec 1, 2024··
fix(vite-node): fix error stack on Windows (#6786)
1 parent 98c7e51 commit bf7b36a

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed
 

‎packages/vite-node/src/server.ts

+1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export class ViteNodeServer {
190190
}
191191

192192
getSourceMap(source: string) {
193+
source = normalizeModuleId(source)
193194
const fetchResult = this.fetchCache.get(source)?.result
194195
if (fetchResult?.map) {
195196
return fetchResult.map
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// 1
2+
// 1
3+
async function main() {
4+
try {
5+
// 2
6+
// 2
7+
throw new Error('boom')
8+
}
9+
catch (e) {
10+
// eslint-disable-next-line no-console
11+
console.log(e)
12+
}
13+
}
14+
// 3
15+
// 3
16+
main()

‎test/vite-node/test/cli.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ it.each(['index.js', 'index.cjs', 'index.mjs'])('correctly runs --watch %s', asy
5252
editFile(entryPath, c => c.replace('test 1', 'test 2'))
5353
await viteNode.waitForStdout('test 2')
5454
})
55+
56+
it('error stack', async () => {
57+
const entryPath = resolve(__dirname, '../src/watch/source-map.ts')
58+
const { viteNode } = await runViteNodeCli('--watch', entryPath)
59+
await viteNode.waitForStdout('source-map.ts:7:11')
60+
})

0 commit comments

Comments
 (0)
Please sign in to comment.