Skip to content

Commit

Permalink
fix: formatError() outside rollup context (#11156)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed Dec 4, 2022
1 parent 401647f commit 2aee2eb
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/vite/src/node/server/pluginContainer.ts
Expand Up @@ -445,6 +445,21 @@ export async function createPluginContainer(
}
}
}
} else if (err.loc) {
if (!err.frame) {
let code = err.pluginCode
if (err.loc.file) {
err.id = normalizePath(err.loc.file)
if (!code) {
try {
code = fs.readFileSync(err.loc.file, 'utf-8')
} catch {}
}
}
if (code) {
err.frame = generateCodeFrame(code, err.loc)
}
}
}
return err
}
Expand Down

0 comments on commit 2aee2eb

Please sign in to comment.