Skip to content

Commit 06d4528

Browse files
committed
fix(build/externals): propagate bundle failures instead of silent stubs
`bundlePackage` caught every error, wrote a `throw new Error(...)` stub to the output path, and returned `undefined`. Consequences: - The orchestrator's `try { await bundlePackage(...) } catch` blocks for optional packages were unreachable — the outer catch never fired. - The build completed "successfully" even when bundles failed. The "Failed to bundle X" log line scrolled past amid the rest of the output, and downstream consumers didn't learn anything was wrong until they `require()`'d the package at runtime and hit the stub's `throw new Error('Failed to bundle X')`. Rethrows the error. Optional-package try/catch now works as intended, and non-optional failures bubble up to `buildExternals` → `main.mts` so the build exits non-zero.
1 parent ccf9d2b commit 06d4528

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

scripts/build-externals/bundler.mts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,10 @@ ${contentWithoutStrict}`
114114
if (!quiet) {
115115
logger.log(` ✗ Failed to bundle ${packageName}: ${error.message}`)
116116
}
117-
// Create error stub.
118-
const stubContent = `'use strict'
119-
120-
// Failed to bundle ${packageName}: ${error.message}
121-
throw new Error('Failed to bundle ${packageName}')
122-
`
123-
await fs.writeFile(outputPath, stubContent)
117+
// Propagate the failure. The orchestrator wraps optional packages in
118+
// try/catch and logs a "Skipping optional package" message; required
119+
// packages bubble up so the build exits non-zero instead of silently
120+
// shipping throw-stubs that only fail later, at consumer runtime.
121+
throw error
124122
}
125123
}

0 commit comments

Comments
 (0)