Skip to content

Add a guide to shipping a program as a binary - #204

Open
brainkim wants to merge 3 commits into
mainfrom
docs/binaries
Open

brainkim wants to merge 3 commits into
mainfrom
docs/binaries

Conversation

@brainkim

Copy link
Copy Markdown
Member

Adds docs/guides/08-binaries.md, one guide covering both runtimes, and links it from Getting Started.

What it covers

  • Bun: bun build --compile, --minify, cross-compiling with --target, embedding a file with type: "file" and showing it through a file: URL, and keeping the image decode worker.
  • Node: bundling to one CommonJS file with esbuild, node --build-sea (Node 25.5 and later), the --experimental-sea-config and postject steps for earlier versions, signing on macOS, embedding assets and serving them to the page through a "fetch" listener.
  • Differences: a table up front, and a section on what a Node executable goes without (the image worker, pty embeds).

What was checked

Every command and code block was built and run as written against the published 0.2.7, on macOS arm64 with Bun 1.4.4 and Node 26.13:

  • the sample program as a Bun binary and as a Node executable, including a minified build of each
  • the postject flow for older Node, run on Node 26
  • the embedded image examples on both runtimes, checked by the red cells they draw
  • the worker shim in a Bun binary, confirmed by a log line from the worker
  • a pty embed: it runs in a Bun binary and fires error in a Node executable
  • that an unsigned Node executable is killed on macOS

Not run: the cross-compiled Linux binary (it was built, and file reports an x86-64 ELF), anything on Linux or Windows, and the executable field for building a Node executable for another platform, which is described from Node's documentation.

One thing to look at

A compiled Bun program loses the image worker, because TermDOM looks for image-decode.worker.js beside itself and the compiler does not embed it. The guide's fix is a one-line file of that name beside the entry that imports the package's worker by its path in node_modules. It works, but it makes a file name inside the package something users depend on. A public export for the worker would be the cleaner contract; the guide documents what works today.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GVbRv5n8btiCtaRBtLrLig

How to build one executable file from a TermDOM program with Bun's
compiler and with Node's single executable applications: the commands,
embedding files the page shows, keeping the image worker in a Bun build,
signing on macOS, and what a Node executable goes without.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GVbRv5n8btiCtaRBtLrLig

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant