[PR #4868] Remove top-level awaits to enable bytecode compilation #11148

Closed
opened 2026-02-16 18:15:56 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4868

State: closed
Merged: No


Currently this PR is not enough to enable bytecode compiliation

  • opentui also needs to remove top level awaits
  • bun --bytecode works by compiling to commonjs. some dependencies have bugs that do not allow it. Throwing the error Expected CommonJS module to have a function wrapper. This us often caused by the use of import.meta.url or other ESM only code. This needs more investigation

Preparation for enabling bytecode compilation (faster startup times).

Related to #4843 and https://github.com/sst/opentui/pull/356

  • global/index.ts: Wrapped async initialization code in an IIFE instead of top-level await
  • index.ts: Changed await cli.parse() to Promise.resolve(cli.parse()).catch().finally() pattern
  • worker.ts: Removed await from Log.init() call (fire-and-forget)

Once opentui PR lands and Bun types are updated, bytecode can be enabled in build.ts with bytecode: true.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4868 **State:** closed **Merged:** No --- Currently this PR is not enough to enable bytecode compiliation - opentui also needs to remove top level awaits - bun --bytecode works by compiling to commonjs. some dependencies have bugs that do not allow it. Throwing the error `Expected CommonJS module to have a function wrapper`. This us often caused by the use of `import.meta.url` or other ESM only code. This needs more investigation Preparation for enabling bytecode compilation (faster startup times). Related to #4843 and https://github.com/sst/opentui/pull/356 - **global/index.ts**: Wrapped async initialization code in an IIFE instead of top-level await - **index.ts**: Changed `await cli.parse()` to `Promise.resolve(cli.parse()).catch().finally()` pattern - **worker.ts**: Removed `await` from `Log.init()` call (fire-and-forget) Once opentui PR lands and Bun types are updated, bytecode can be enabled in `build.ts` with `bytecode: true`.
yindo added the pull-request label 2026-02-16 18:15:56 -05:00
yindo closed this issue 2026-02-16 18:15:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11148