Skip to content

Display full error messages when the build fails in electrobun build or electrobun dev.#367

Open
chrisvariety wants to merge 1 commit intoblackboardsh:mainfrom
chrisvariety:error-messages
Open

Display full error messages when the build fails in electrobun build or electrobun dev.#367
chrisvariety wants to merge 1 commit intoblackboardsh:mainfrom
chrisvariety:error-messages

Conversation

@chrisvariety
Copy link
Copy Markdown

runBuild can throw other types of errors, e.g. AggregateError.

Currently those errors are just swallowed, leading to the output of a failed build being:

$ electrobun dev
Using config file: electrobun.config.ts
Bundle failed

This fix displays the full error by aligning the dev and build commands with dev --watch which already logs errors in a similar manner:

$ electrobun dev
Build failed: 1 | import foo from 'bar';foo();
                    ^
error: Could not resolve: "bar". Maybe you need to "bun install"?
    at /Users/chrismcc/workspace/src/my-hello-world-app/src/bun/index.ts:1:17

…` or `electrobun dev`.

`runBuild` can throw other types of errors, e.g. [AggregateError](https://github.com/oven-sh/bun/blob/1afabdde2eb7fe609933b770364611854f8e8dda/src/bundler/bundle_v2.zig#L2275).

Currently those errors are just swallowed, leading to the output of a failed build being:

```
$ electrobun dev
Using config file: electrobun.config.ts
Bundle failed
```

This fix displays the full error by aligning the `dev` and `build` commands with `dev --watch` which [already logs errors in a similar manner](https://github.com/blackboardsh/electrobun/blob/fc3e62da6335845f02d9ed7e5d3d9480c741f08a/package/src/cli/index.ts#L4370):

```
$ electrobun dev
Build failed: 1 | import foo from 'bar';foo();
                    ^
error: Could not resolve: "bar". Maybe you need to "bun install"?
    at /Users/chrismcc/workspace/src/my-hello-world-app/src/bun/index.ts:1:17
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant