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
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
570
Reactを段階的に覗いてみる
ytaisei
3
2.2k
Reactのトランジションを覗いてみる
ytaisei
1
2.7k
Deep Dive Into React 〜React Fiber Architectureについて〜
ytaisei
2
600
React19で状態管理はどう変わるか
ytaisei
2
250
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.3k
Other Decks in Technology
See All in Technology
hackers_champloo_2026_tidb
makocchi
0
160
JAWS-UGグッズ職人仕事の流儀
kentapapa
0
100
DevelopersIO 2026 知識の地図を描く ─ オントロジーとは何か?
ishikawa_satoru
1
1.7k
OptunaHub: ブラックボックス最適化のためのプラットフォーム
pfn
PRO
0
140
「Docker Desktop不要の時代」は 来たのか?
ueponx
0
770
Rust で関数型ドメインモデリング
takonda
0
140
触りたくないデータに、どう触るか AI時代のRBACアクセスガバナンス
ivry_presentationmaterials
0
260
夫婦で子育てするための育児標準化
codmoninc
PRO
0
330
Claude Code本は、どのように執筆チームで書かれたか
oikon48
1
380
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
120
AI導入は済んだ。次は統制を作り替える番だ_AI×開発組織 Summit 2026
techtekt
PRO
0
210
パッチ更新でterraform initが落ちた日
grimoh
1
140
Featured
See All Featured
The World Runs on Bad Software
bkeepers
PRO
72
12k
Code Review Best Practice
trishagee
74
20k
Are puppies a ranking factor?
jonoalderson
2
4.1k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
630
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
Optimizing for Happiness
mojombo
378
71k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
The Curious Case for Waylosing
cassininazir
1
570
Context Engineering - Making Every Token Count
addyosmani
9
1.2k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.3k
Why Our Code Smells
bkeepers
PRO
340
58k
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