opencode
opencode copied to clipboard
Remove top-level awaits to enable bytecode compilation
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 ofimport.meta.urlor 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()toPromise.resolve(cli.parse()).catch().finally()pattern -
worker.ts: Removed
awaitfromLog.init()call (fire-and-forget)
Once opentui PR lands and Bun types are updated, bytecode can be enabled in build.ts with bytecode: true.