opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Remove top-level awaits to enable bytecode compilation

Open remorses opened this issue 1 month ago • 0 comments

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.

remorses avatar Nov 28 '25 15:11 remorses