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がCommonJSをサポートする理由
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ytaisei
March 27, 2024
Technology
520
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
BunがCommonJSをサポートする理由
フロントエンドTechCafe〜春のBun祭りLT会〜にて使用した資料。
参考資料:
https://bun.sh/blog/commonjs-is-not-going-away
ytaisei
March 27, 2024
More Decks by ytaisei
See All by ytaisei
TanStack Routerを新規プロダクトで1年間運用してみた結果
ytaisei
1
610
Reactを段階的に覗いてみる
ytaisei
3
2.2k
Reactのトランジションを覗いてみる
ytaisei
1
2.8k
Deep Dive Into React 〜React Fiber Architectureについて〜
ytaisei
2
630
React19で状態管理はどう変わるか
ytaisei
2
260
TanStackで効率的なルーティングとデータ取得を実現
ytaisei
10
2.7k
TanStack Routerで型安全かつ効率的なルーティングを実現
ytaisei
4
2.6k
TanStack Router SPA開発の選択肢になるか(+TanStack Query)
ytaisei
2
1.9k
【2023】SWR vs TanStack Query
ytaisei
1
2.4k
Other Decks in Technology
See All in Technology
デザインレビューは自動化できるのか?─ Flutter × Figma で UI 品質保証を考える
techiro
2
800
Don't write the architecture only in the prompt.
neohsu
0
310
増え続けるプロダクトの品質をどう担保するか。ProductSpecとTypeScriptによる取り組み
joere
3
570
「いつか使う」の「いつか」は来ない 〜AI駆動開発における「作らない」判断について〜
ikki0006
0
150
Active Directory と Entra ID のむむむな関係
murachiakira
PRO
3
1.7k
推論基盤と Scale-Up Interconnect の現状と制約から俯瞰する技術動向
markunet
2
830
詳解 never 型 - ボトム型の性質を深掘り
nealle
0
160
AX時代の自治体支援リソース再配分と役割分担の再構成:戦略とロードマップ(概要)
sishi2026
0
200
E2Eってつらくないですか?E2Eの管理コストを下げる手段とその実践
akaboshinit
6
3k
AWS構成から考えるWebセキュリティ ― WordPressの構築経験から考える公開範囲と更新運用【JAWS FESTA 2026 in AKITA】
cscengineer
PRO
1
310
Autonomous AI Lakehouse - Live AI Hubから始めるセキュアなAIデータ活用 -
oracle4engineer
PRO
3
190
慶應義塾大学 AI実践05 論文執筆の仕組み化
keio_smilab
PRO
7
3.7k
Featured
See All Featured
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
240
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
48k
The Cost Of JavaScript in 2023
addyosmani
56
10k
How to make the Groovebox
asonas
2
2.5k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.3k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
370
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.9k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Designing for Performance
lara
612
70k
Producing Creativity
orderedlist
PRO
348
41k
My Coaching Mixtape
mlcsv
0
380
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.5k
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