Skip to content

Commit

Permalink
fix: err.id too
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Nov 9, 2024
1 parent db31543 commit 6b0ea32
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ exports[`parse error 2`] = `
"frame": "1 | invalid code
| ^
2 | ",
"id": "",
"id": "/fixtures/errors/syntax-error.js",
"loc": {
"column": 9,
"file": "/fixtures/errors/syntax-error.js",
Expand Down Expand Up @@ -58,7 +58,7 @@ exports[`parse error 4`] = `
"frame": "1 | invalid code
| ^
2 | ",
"id": "",
"id": "/fixtures/errors/syntax-error.js",
"loc": {
"column": 9,
"file": "/fixtures/errors/syntax-error.js",
Expand Down
1 change: 1 addition & 0 deletions packages/vite/src/node/ssr/ssrTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ async function ssrTransformScript(
ast = await rollupParseAstAsync(code)
} catch (err) {
if (err.code === 'PARSE_ERROR' && typeof err.pos === 'number') {
err.id = url
err.loc = numberToPos(code, err.pos)
err.loc.file = url
err.frame = generateCodeFrame(code, err.pos)
Expand Down

0 comments on commit 6b0ea32

Please sign in to comment.