Surface Bun build error details in build.js error handler

When Bun.build aggregates resolution failures, the thrown error keeps the
real causes on error.errors (an array). The previous handler only printed
error.message and error.stack, both of which are generic / undefined for
this kind of failure, so CI logs read as 'Bundle failed / undefined' with
no clue what was unresolved. Walk error.errors first so the actual file +
import that failed shows up in CI output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2026-04-08 14:01:09 -07:00
co-authored by Claude Opus 4.6
parent b0c78cacda
commit adcca35b03
+10 -2
View File
@@ -339,13 +339,21 @@ async function buildStaticSite(extraEntrypoints = []) {
return result;
} catch (error) {
// Bun's build aggregator errors expose details on `error.errors` (an
// array of resolution / parse failures), not `error.stack`. Print
// both so CI logs surface the real cause instead of "undefined".
console.error('Failed to build static site:', error.message);
console.error(error.stack);
if (error.logs) {
if (error.errors?.length) {
for (const e of error.errors) {
console.error(' -', e.message || e);
}
}
if (error.logs?.length) {
for (const log of error.logs) {
console.error(log.message || log);
}
}
if (error.stack) console.error(error.stack);
process.exit(1);
}
}