Skip to content

Commit 5d00796

Browse files
committed
feat: show error if bundle fails
1 parent a4f6ccc commit 5d00796

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

src/commands/generate-wrangler.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,23 @@ export const generateWranglerCommand = defineCommand({
3434
await fs.mkdir(tempDir, { recursive: true });
3535

3636
// Bundling wrangler.ts to clean ESM
37-
const buildResult = await Bun.build({
38-
entrypoints: [wranglerTsPath],
39-
outdir: tempDir,
40-
target: "node",
41-
format: "esm",
42-
});
37+
let buildResult: Bun.BuildOutput | undefined
38+
try {
39+
buildResult = await Bun.build({
40+
entrypoints: [wranglerTsPath],
41+
outdir: tempDir,
42+
target: "node",
43+
format: "esm",
44+
});
45+
} catch (error) {
46+
console.error(error);
47+
}
48+
49+
if (!buildResult) {
50+
throw new Error(
51+
`Failed to bundle wrangler.ts. Unknown error.`,
52+
);
53+
}
4354

4455
if (!buildResult.success) {
4556
console.log(buildResult.logs);

0 commit comments

Comments
 (0)