Skip to content

Feature request: Remove top-level await to enable bytecode compilation #355

@remorses

Description

@remorses

Bun's bytecode compilation reduces startup from ~520ms to ~44ms but requires no top-level await. This is blocking anomalyco/opencode#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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions