[GH-ISSUE #41] Bun v1.2.13: crash in @opentui/core/3d when running Sprite Animation example because console.Console is undefined #7

Closed
opened 2026-03-02 23:43:48 +03:00 by kerem · 9 comments
Owner

Originally created by @Montekkundan on GitHub (Aug 19, 2025).
Original GitHub issue: https://github.com/anomalyco/opentui/issues/41

Running the Sprite Animation example on Bun throws TypeError: undefined is not a constructor where @opentui/core/3d.js constructs new console.Console(...) and overwrites global.console.

Env

  • Bun v1.2.13 macOS arm64
  • @opentui/core 0.1.6

Repro

bun init -y
bun add @opentui/core three

index.ts:

// run the Sprite Animation example
bun run index.ts

Error

TypeError: undefined is not a constructor (new console.Console({...}))
at node_modules/@opentui/core/3d.js:36286:20
Originally created by @Montekkundan on GitHub (Aug 19, 2025). Original GitHub issue: https://github.com/anomalyco/opentui/issues/41 Running the Sprite Animation example on Bun throws `TypeError: undefined is not a constructor` where `@opentui/core/3d.js` constructs new `console.Console(...)` and overwrites `global.console`. **Env** * Bun v1.2.13 macOS arm64 * `@opentui/core` 0.1.6 **Repro** ```bash bun init -y bun add @opentui/core three ``` `index.ts`: ```ts // run the Sprite Animation example ``` ```bash bun run index.ts ``` **Error** ``` TypeError: undefined is not a constructor (new console.Console({...})) at node_modules/@opentui/core/3d.js:36286:20 ```
kerem closed this issue 2026-03-02 23:43:49 +03:00
Author
Owner

@kommander commented on GitHub (Aug 19, 2025):

Is this in a new and empty folder with bun init? What does // run the Sprite Animation example do exactly here?

<!-- gh-comment-id:3199156942 --> @kommander commented on GitHub (Aug 19, 2025): Is this in a new and empty folder with `bun init`? What does `// run the Sprite Animation example` do exactly here?
Author
Owner

@Montekkundan commented on GitHub (Aug 20, 2025):

Yes, https://github.com/Montekkundan/opentui-projects

running the same https://github.com/sst/opentui/blob/main/packages/core/src/examples/sprite-animation-demo.ts file with revised imports

<!-- gh-comment-id:3207439113 --> @Montekkundan commented on GitHub (Aug 20, 2025): Yes, https://github.com/Montekkundan/opentui-projects running the same https://github.com/sst/opentui/blob/main/packages/core/src/examples/sprite-animation-demo.ts file with revised imports
Author
Owner

@kommander commented on GitHub (Aug 20, 2025):

The issue is that the 3d entry point bundles all of core and executes certain sections twice, which shouldn't happen. Also, threejs >v0.177.0 is not yet supported. I fixed the entry point and pinned the threejs version in the optional dependencies. Will be in the v0.1.8 release coming shortly.

<!-- gh-comment-id:3208253024 --> @kommander commented on GitHub (Aug 20, 2025): The issue is that the 3d entry point bundles all of core and executes certain sections twice, which shouldn't happen. Also, threejs >v0.177.0 is not yet supported. I fixed the entry point and pinned the threejs version in the optional dependencies. Will be in the v0.1.8 release coming shortly.
Author
Owner

@KurtGokhan commented on GitHub (Aug 23, 2025):

This also happens on any code when running with Bun hot reloading and making changes to files. Is there a plan to support Bun hot reloading?

<!-- gh-comment-id:3216689274 --> @KurtGokhan commented on GitHub (Aug 23, 2025): This also happens on any code when running with Bun hot reloading and making changes to files. Is there a plan to support Bun hot reloading?
Author
Owner

@kommander commented on GitHub (Aug 23, 2025):

@KurtGokhan Not on the roadmap yet, but will be. The react/solid wrappers will support HMR though.

<!-- gh-comment-id:3216735688 --> @kommander commented on GitHub (Aug 23, 2025): @KurtGokhan Not on the roadmap yet, but will be. The react/solid wrappers will support HMR though.
Author
Owner

@KurtGokhan commented on GitHub (Aug 23, 2025):

Thanks. I created #57 to prevent the crash caused by undefined.

I also tried to make a POC for hot reload, but for some reason import.meta.hot isn't available in Bun even though the docs imply it is. Will try to follow-up later.

<!-- gh-comment-id:3216941090 --> @KurtGokhan commented on GitHub (Aug 23, 2025): Thanks. I created #57 to prevent the crash caused by `undefined`. I also tried to make a POC for hot reload, but for some reason `import.meta.hot` isn't available in Bun even though [the docs](https://bun.com/docs/bundler/hmr) imply it is. Will try to follow-up later.
Author
Owner

@msmps commented on GitHub (Aug 23, 2025):

Thanks. I created #57 to prevent the crash caused by undefined.

I also tried to make a POC for hot reload, but for some reason import.meta.hot isn't available in Bun even though the docs imply it is. Will try to follow-up later.

I'm actively working on HMR for the React reconciler as @kommander mentioned above. import.meta.hot isn't present unless using the bun full-stack server (not just the hot flag) is my understanding but I'm working through that at present and hope to ship soon 👍

<!-- gh-comment-id:3216960899 --> @msmps commented on GitHub (Aug 23, 2025): > Thanks. I created #57 to prevent the crash caused by `undefined`. > > I also tried to make a POC for hot reload, but for some reason `import.meta.hot` isn't available in Bun even though [the docs](https://bun.com/docs/bundler/hmr) imply it is. Will try to follow-up later. I'm actively working on HMR for the React reconciler as @kommander mentioned above. `import.meta.hot` isn't present unless using the bun full-stack server (not just the hot flag) is my understanding but I'm working through that at present and hope to ship soon 👍
Author
Owner

@KurtGokhan commented on GitHub (Aug 23, 2025):

I see. I actually need server-side HMR, so no luck until Bun properly supports it I guess. Found the docs saying import.meta.hot API will be added later.

<!-- gh-comment-id:3216963977 --> @KurtGokhan commented on GitHub (Aug 23, 2025): I see. I actually need server-side HMR, so no luck until Bun properly supports it I guess. Found [the docs](https://bun.com/docs/runtime/hot#http-servers) saying `import.meta.hot` API will be added later.
Author
Owner

@kommander commented on GitHub (Aug 23, 2025):

I'll consider this solved for now and would move HMR to other issues.

<!-- gh-comment-id:3217303757 --> @kommander commented on GitHub (Aug 23, 2025): I'll consider this solved for now and would move HMR to other issues.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#7
No description provided.