Skip to content

Commit

Permalink
fix(vite-node): fix error stack on Windows (#6786)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa authored Dec 1, 2024
1 parent 98c7e51 commit bf7b36a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/vite-node/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export class ViteNodeServer {
}

getSourceMap(source: string) {
source = normalizeModuleId(source)
const fetchResult = this.fetchCache.get(source)?.result
if (fetchResult?.map) {
return fetchResult.map
Expand Down
16 changes: 16 additions & 0 deletions test/vite-node/src/watch/source-map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 1
// 1
async function main() {
try {
// 2
// 2
throw new Error('boom')
}
catch (e) {
// eslint-disable-next-line no-console
console.log(e)
}
}
// 3
// 3
main()
6 changes: 6 additions & 0 deletions test/vite-node/test/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ it.each(['index.js', 'index.cjs', 'index.mjs'])('correctly runs --watch %s', asy
editFile(entryPath, c => c.replace('test 1', 'test 2'))
await viteNode.waitForStdout('test 2')
})

it('error stack', async () => {
const entryPath = resolve(__dirname, '../src/watch/source-map.ts')
const { viteNode } = await runViteNodeCli('--watch', entryPath)
await viteNode.waitForStdout('source-map.ts:7:11')
})

0 comments on commit bf7b36a

Please sign in to comment.