fix: formatError() outside rollup context (#11156)

This commit is contained in:
Manu MA 2022-12-04 23:17:20 +01:00 committed by GitHub
parent 401647feb4
commit 2aee2ebb5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}