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
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
310
Optunaの最新リリースv5.0について
pfn
PRO
0
120
M5Stackで作る BLEマウス GPSログの世界
tomokusaba
PRO
0
450
データエンジニアの次の戦場は "プロセスエンジニアリング"
sansantech
PRO
1
120
LambdaWebFunctionsを試してみた / exploring-lambda-web-functions
koukihosaka
1
360
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
200
オントロジーって 結局なにもの? AI エージェントに「意味」を渡す知識設計の話
greenmidori
0
240
Active Record Connection Adaptersにおける長年の課題に再び取り組む
yahonda
0
330
OptunaHub: ブラックボックス最適化のためのプラットフォーム
pfn
PRO
0
150
CloudWatch Logsのコスト最適化:どこまでAIに任せてどこから人間が承認すべきか
yama3133
0
120
トークン化預金DCJPYの取り組みと活用ユースケース
finengine
0
190
SAENM ~Jupyterで残すPoCの試行錯誤、未来の自分と仲間を助ける記録!~
terapyon
0
160
Featured
See All Featured
Evolving SEO for Evolving Search Engines
ryanjones
0
330
The Cost Of JavaScript in 2023
addyosmani
55
10k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Building Flexible Design Systems
yeseniaperezcruz
330
41k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
560
Ruling the World: When Life Gets Gamed
codingconduct
0
410
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Marketing to machines
jonoalderson
1
5.9k
Designing for Timeless Needs
cassininazir
1
530
GitHub's CSS Performance
jonrohan
1033
470k
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