Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Bunではじめる standalone CLI / start standalone-cli ...
Search
philomagi
July 21, 2026
Programming
27
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Bunではじめる standalone CLI / start standalone-cli with bun
## installerer
https://installerer.philomagi.dev/
philomagi
July 21, 2026
More Decks by philomagi
See All by philomagi
SkillとAgentを一元管理する / Centrally manage Skills and Agents
tooppoo
0
35
初めてのGitHub Actions / GitHub Actions at First
tooppoo
0
170
OSS開発を通じて考える、AI時代開発のこれから / The Future of Software Development in the AI Era
tooppoo
0
86
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
220
Multi-Agent並列開発を 安全に回すための技術 / Technology for Safely Multi-Agent Parallel Development
tooppoo
0
310
今更考える「単一責任原則」 / Thinking about the Single Responsibility Principle
tooppoo
3
1.9k
なぜ定義は問題解決に直結するのか/why-definitions-are-linked-to-problem-solving-with-tdd
tooppoo
0
110
ドメイン駆動設計のホーリズム的側面 / domain-driven-design and holism
tooppoo
0
240
アート、サイエンス、「わかりやすさ」 / art, science, "easy to understand"
tooppoo
1
21k
Other Decks in Programming
See All in Programming
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
270
初心者DevRelとして参加者だった私が、DevRel Talks!#2に登壇するまでにしてきたこと
sokohirai
0
200
Deep dive into the select statement (GopherCon UK)
jespino
0
160
不幸な GC
chencmd
0
840
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
650
高専キャリア LT 発表内容
crysta1221
6
5.3k
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
130
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
760
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1.5k
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
630
FastAPI の並行処理モデルを完全に理解する
hoto17296
9
3.3k
Press start. Python's next generation.
willingc
PRO
3
290
Featured
See All Featured
Claude Code のすすめ
schroneko
67
230k
Ethics towards AI in product and experience design
skipperchong
2
360
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
450
Testing 201, or: Great Expectations
jmmastey
46
8.3k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
500
Technical Leadership for Architectural Decision Making
baasie
3
550
Scaling GitHub
holman
464
140k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
590
Product Roadmaps are Hard
iamctodd
55
12k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
400
Optimizing for Happiness
mojombo
378
71k
Transcript
Bun ではじめる standalone CLI 2026-07-21 hokkaido.js vol.07 #hokkaido_js @Philomagi 1
/ 15
発表者 @Philomagi WEB系プログラマ 自称フロントエンド寄り 最近は Rust とか Go とか 2
/ 15
問題提起 TypeScript で CLI を書きたい だが、CLIの利用者がJavaScript開発者とは限らない 利用者にNode.jsの導入を求めたくない 自作ツール installerer を題材に考えてみる
3 / 15
None
installerer について GitHub Releases 向けの install.sh を生成するツール 当初はブラウザ上の Web UI
のみ ローカルのターミナルからも使えるよう CLI を追加 5 / 15
Web UI / CLI / core の関係 Web UI CLI(追加)
→ shared core (ランタイム中立) Web UI はそのまま、CLI を追加 6 / 15
CLI 版で目指したこと ブラウザを開かずターミナルから使えるようにする JavaScript runtime を利用者に強制しない installererのユースケースは、Node.js固有でないため GitHub Releases から一般的な
CLI として配る installerer CLIを、自身が生成した install.sh で配布する 7 / 15
Bun で single binary 化 で single binary を生成 利用者側の
Node.js や Bun が不要になる bun build --compile 正確には「利用者が runtime を別途管理しなくてよい」 Node.js開発者でなくても、 installerer を使える 8 / 15
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
なぜ Bun か 元々 package manager / test runner /
build tool として使用していた 元々Web用に作っていたロジックを、そのままCLIと共有できる TypeScript を直接 entry point にして、 single binary を生成できる Bun を使う TypeScript プロジェクトなら、single binary CLI を既存 toolchain の延長 として追加しやすい 10 / 15
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
npm 版との関係 CLI source(Node.js 互換 entry point) ↓ ↓ bundle
→ npm package Bun compile Node.js script standalone binary 補助の配布ルート メインの配布ルート ↓ ↓ 12 / 15
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
トレードオフ 利用者側の runtime 依存をなくす ↕ runtime 同梱で binary は大きくなりやすい 配布時のサイズを取るか、可搬性を取るか
基本は single binary で配布、サイズを最小化したいなら npm 経由、という棲み分け もあり得るかも 14 / 15
まとめ Bunを使うと、single binary の生成自体は比較的簡単 single binary とのトレードオフとして、バイナリ本体のサイズ増大がある Node.js runtime を利用者へ強制したくない場合、Bun
single binary は有力な選択肢 15 / 15