-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(runtime): fix sourcemap with
prepareStackTrace
(#16220)
- Loading branch information
Showing
6 changed files
with
66 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/vite/src/node/ssr/runtime/__tests__/fixtures/has-error-deep.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function crash(message: string) { | ||
throw new Error(message) | ||
} | ||
|
||
export function main(): void { | ||
crash('crash') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function crash(message: string) { | ||
throw new Error(message) | ||
} | ||
|
||
export function main(): void { | ||
crash('crash') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import assert from 'node:assert' | ||
import { createServer, createViteRuntime } from 'vite' | ||
|
||
// same test case as packages/vite/src/node/ssr/runtime/__tests__/server-source-maps.spec.ts | ||
// implemented for e2e to catch build specific behavior | ||
|
||
const server = await createServer({ | ||
configFile: false, | ||
root: fileURLToPath(new URL('.', import.meta.url)), | ||
server: { | ||
middlewareMode: true, | ||
}, | ||
}) | ||
|
||
const runtime = await createViteRuntime(server, { | ||
sourcemapInterceptor: 'prepareStackTrace', | ||
}) | ||
|
||
const mod = await runtime.executeEntrypoint('/src/has-error-deep.ts') | ||
let error | ||
try { | ||
mod.main() | ||
} catch (e) { | ||
error = e | ||
} finally { | ||
await server.close() | ||
} | ||
assert.match(error?.stack, /has-error-deep.ts:6:3/) |