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がCommonJSをサポートする理由
Search
ytaisei
March 27, 2024
Technology
2
440
BunがCommonJSをサポートする理由
フロントエンドTechCafe〜春のBun祭りLT会〜にて使用した資料。
参考資料:
https://bun.sh/blog/commonjs-is-not-going-away
ytaisei
March 27, 2024
Tweet
Share
More Decks by ytaisei
See All by ytaisei
TanStack Routerを新規プロダクトで1年間運用してみた結果
ytaisei
1
210
Reactを段階的に覗いてみる
ytaisei
3
1.9k
Reactのトランジションを覗いてみる
ytaisei
1
2.5k
Deep Dive Into React 〜React Fiber Architectureについて〜
ytaisei
2
410
React19で状態管理はどう変わるか
ytaisei
2
190
TanStackで効率的なルーティングとデータ取得を実現
ytaisei
10
2.4k
TanStack Routerで型安全かつ効率的なルーティングを実現
ytaisei
4
2.4k
TanStack Router SPA開発の選択肢になるか(+TanStack Query)
ytaisei
2
1.6k
【2023】SWR vs TanStack Query
ytaisei
1
2.2k
Other Decks in Technology
See All in Technology
戰略轉變:從建構 AI 代理人到發展可擴展的技能生態系統
appleboy
0
190
コミュニティが持つ「学びと成長の場」としての作用 / RSGT2026
ama_ch
0
230
Java 25に至る道
skrb
3
210
I tried making a solo advent calendar!
zzzzico
0
150
純粋なイミュータブルモデルを設計してからイベントソーシングと組み合わせるDeciderの実践方法の紹介 /Introducing Decider Pattern with Event Sourcing
tomohisa
1
980
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
4
21k
Data Hubグループ 紹介資料
sansan33
PRO
0
2.6k
kintone開発のプラットフォームエンジニアの紹介
cybozuinsideout
PRO
0
510
Digitization部 紹介資料
sansan33
PRO
1
6.5k
Eight Engineering Unit 紹介資料
sansan33
PRO
0
6.2k
re:Invent2025 セッションレポ ~Spec-driven development with Kiro~
nrinetcom
PRO
2
170
BidiAgent と Nova 2 Sonic から考える音声 AI について
yama3133
2
150
Featured
See All Featured
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
1
350
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
98
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
0
1.8k
Darren the Foodie - Storyboard
khoart
PRO
2
2.1k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.1k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.1k
Building Adaptive Systems
keathley
44
2.9k
Designing Powerful Visuals for Engaging Learning
tmiket
0
200
Transcript
BunがCommonJS をサポートする理由 ytaisei(安井大晟)
ytaisei(安井大晟) • フロントエンド • 24卒CyberAgent • 株式会社AI Shift
Bunあまり知らない... ⇨LT応募する ⇨リサーチする
「CommonJS is not going away」というブログを発見 • 公式のブログ • 2023年6月なので少し古いかも
CJSとESM • CommonJS • ES Modules • require/exportsを使用 • 同期的にロード
• 元々サーバでの使用が想定されていた • import/exportを使用 • 同期・非同期でのロードに対応 • ブラウザでもネイティブサポート
CJSとESM • CommonJS • ES Modules • require/exportsを使用 • 同期的にロード
• 元々サーバでの使用が想定されていた • import/exportを使用 • 同期・非同期でのロードに対応 • ブラウザでもネイティブサポート 新規のプロジェクトであれば ESMが推奨
では、なぜCJSをサポートする?
public npm registryにおけるCommonJSの割合 • ESMの割合がかなり増えている • 依然としてCJSが67%以上 参考:https://github.com/wooorm/npm-esm-vs-cjs?tab=readme-ov-file
CommonJSの存在を尊重する姿勢
CommomJSの方がモジュールのLoadが早いケースも
CommomJSの方がモジュールのLoadが早いケースも 手元のベンチマークではCJSの方が約1.5倍早かった
Bunでは同一File内で importとrequireを使用可能 (CJSとESMの共存が可能)
結論 • BunではCJSとESMのどちらもサポートしている • CJS自体のメリットも含めて、 CJSを尊重する姿勢が記事から伺えた
Thanks!!! X: ytaisei_ Zenn: @taisei-13046