opentui
opentui copied to clipboard
Feature request: Remove top-level await to enable bytecode compilation
Bun's bytecode compilation reduces startup from ~520ms to ~44ms but requires no top-level await. This is blocking https://github.com/sst/opencode/issues/4843
There are 3 top-level await locations:
yoga-layout WASM
https://github.com/sst/opentui/blob/5dbe0b4be9b647f2d10ac90b63acdecf1a6998d8/packages/core/src/index.ts#L18
yoga-layout uses async WebAssembly.instantiate() internally. Consider using FFI to native Yoga instead.
Platform import
https://github.com/sst/opentui/blob/5dbe0b4be9b647f2d10ac90b63acdecf1a6998d8/packages/core/src/zig.ts#L22
Can use sync require() instead.
Native lib path resolution
https://github.com/sst/opentui/blob/5dbe0b4be9b647f2d10ac90b63acdecf1a6998d8/packages/core/scripts/build.ts#L139-L142
Can use sync require.resolve() instead.
The platform import and native lib path are straightforward. Yoga is the main blocker.