Skip to content

fix: add code location and codeframe for rollup errors #406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 31, 2022
3 changes: 2 additions & 1 deletion src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ async function _build (nitro: Nitro, rollupConfig: RollupConfig) {

nitro.logger.start('Building server...')
const build = await rollup.rollup(rollupConfig).catch((error) => {
nitro.logger.error('Rollup error: ' + error.message)
const location = `${relative(process.cwd(), error.id)}:${error.loc.line}:${error.loc.column}`
nitro.logger.error(`Rollup error while parsing \`${location}\`` + '\n' + '\n' + error.frame)
throw error
})

Expand Down