Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Bunではじめる standalone CLI / start standalone-cli ...
Search
philomagi
July 21, 2026
Programming
58
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
Transcript
15 slides
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
More Decks by philomagi
See All by philomagi
SkillとAgentを一元管理する / Centrally manage Skills and Agents
tooppoo
0
76
初めてのGitHub Actions / GitHub Actions at First
tooppoo
0
230
OSS開発を通じて考える、AI時代開発のこれから / The Future of Software Development in the AI Era
tooppoo
0
130
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
250
Multi-Agent並列開発を 安全に回すための技術 / Technology for Safely Multi-Agent Parallel Development
tooppoo
0
390
今更考える「単一責任原則」 / Thinking about the Single Responsibility Principle
tooppoo
3
2k
なぜ定義は問題解決に直結するのか/why-definitions-are-linked-to-problem-solving-with-tdd
tooppoo
0
120
ドメイン駆動設計のホーリズム的側面 / domain-driven-design and holism
tooppoo
0
250
アート、サイエンス、「わかりやすさ」 / art, science, "easy to understand"
tooppoo
1
21k
Other Decks in Programming
See All in Programming
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
3
240
数行の変更でDockerビルドを最大91%高速化~GitLab CIの実行基盤を社内40リポジトリに展開するまで~
picopico
3
1k
Getting Started with Vibe Coding
miccheng
0
250
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
340
Kiro Crewによる開発体験ーKiro CrewでStrands Decider 2B に関する技術検証をやってみた
satoshi256kbyte
1
200
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
1.1k
はじめてのPLATEAU
nokonoko1203
1
670
RaspberryPi 5で軽くはじめるk3sとtailscaleを用いたホームサーバー構築 (1)
nasum
0
450
将来の標準フォーマッター?ktfmtを深堀る
t45k
1
250
AIが実装を担う時代の「技術設計」と「チームマネジメント」
kamina_zzz
2
460
どうしても Eloquent でリポジトリパターンをやりたいんだ #phpcon_niigata / phpcon-niigata-2026
shogogg
0
690
How SRE Grew Out of Server-Side Work and Became the Team's Own / サーバサイドから始まったSREを チームに渡すまで
maaaato
1
280
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.3k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
121
130k
Everyday Curiosity
cassininazir
0
420
Thoughts on Productivity
jonyablonski
76
5.5k
Navigating Weather and Climate Data
rabernat
0
600
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
910
SEO for Brand Visibility & Recognition
aleyda
0
4.9k
Building Applications with DynamoDB
mza
96
7.3k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1.1k
4 Signs Your Business is Dying
shpigford
187
23k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
360
Google's AI Overviews - The New Search
badams
0
1.7k