Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Bunではじめる standalone CLI / start standalone-cli ...

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

Bunではじめる standalone CLI / start standalone-cli with bun

philomagi

July 21, 2026

Transcript

15 slides
  1. installerer について GitHub Releases 向けの install.sh を生成するツール 当初はブラウザ上の Web UI

    のみ ローカルのターミナルからも使えるよう CLI を追加 5 / 15
  2. Web UI / CLI / core の関係 Web UI CLI(追加)

    → shared core (ランタイム中立) Web UI はそのまま、CLI を追加 6 / 15
  3. Bun で single binary 化 で single binary を生成 利用者側の

    Node.js や Bun が不要になる bun build --compile 正確には「利用者が runtime を別途管理しなくてよい」 Node.js開発者でなくても、 installerer を使える 8 / 15
  4. single binary生成例 bun build --compile \ --target=bun-linux-x64-baseline \ --outfile=installerer \

    packages/cli/src/node/main.ts ./installerer --version で single binary を生成 --target で対象とするOS・アーキテクチャを指定できる --compile 9 / 15
  5. なぜ Bun か 元々 package manager / test runner /

    build tool として使用していた 元々Web用に作っていたロジックを、そのままCLIと共有できる TypeScript を直接 entry point にして、 single binary を生成できる Bun を使う TypeScript プロジェクトなら、single binary CLI を既存 toolchain の延長 として追加しやすい 10 / 15
  6. runtime との距離 shared core はランタイム中立 共通のコア部分は Node.js / Bun /

    ブラウザ固有 API に依存しない 配布 binary は別途 runtime を求めない Bun runtime は binary の中に同梱される 利用者が installerer のためだけに runtime を入れなくて良い npm 版は Node.js CLI として作る = Node.js runtime 前提 npm を使っているから、Node.js runtime を前提にして問題ない runtime 同梱を回避 11 / 15
  7. npm 版との関係 CLI source(Node.js 互換 entry point) ↓ ↓ bundle

    → npm package Bun compile Node.js script standalone binary 補助の配布ルート メインの配布ルート ↓ ↓ 12 / 15
  8. single binaryの配布ルート target 別に native runner で実行 bun build --compile

    Bun 固有 → target 別 binary → archive (tar.gz) → sha256 checksum ↓ release.yml → archive + checksum → install.sh で導入 → GitHub Release binaryを GitHub Releaseから ダウンロード Bun 固有は build script のみ 13 / 15
  9. トレードオフ 利用者側の runtime 依存をなくす ↕ runtime 同梱で binary は大きくなりやすい 配布時のサイズを取るか、可搬性を取るか

    基本は single binary で配布、サイズを最小化したいなら npm 経由、という棲み分け もあり得るかも 14 / 15

More Decks by philomagi

Other Decks in Programming