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
530
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
Transcript
14 slides
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
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
640
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
Biohub - Cell Tracking During Development 5th place solution
rist
0
180
AI対話型分析を作成し、リリースするまでの話 / The Road to Release: Buiding AI Conversational Analytics
yappli_developers
0
170
マネージャーをエスパーにしない マネジメントされる側から始める、働きやすい現場づくり
comi190327
1
830
おうち環境でも「なるべく止めたくない!」 ― おうち環境の機器冗長化の理想と現実
yuutosi
1
610
IoTのデータ保存をSREの観点で考える
grimoh
1
110
Amazon Bedrock AgentCore の基礎とセキュリティ・ガバナンス
ren8k
0
200
SREのためのFinOps入門
muziyoshiz
3
1.7k
AIで実装が加速したのに、 なぜ私は仕事の大半で人と話し続けていたのか?
say_no_w
0
200
サーバーラックは作る時代! 3Dプリンターで作る10インチラックのススメ
jacopen
2
480
速くなるほど、深く考える AI時代のQAに学ぶ
kobayashiyorimitsu
0
280
Kansai WordPress Meetup@大阪『ブロックテーマを作る上で知っておくべきこと
torounit
0
260
E2E Test というハーネス — AI時代の自動テスト民主化
daishukojima
10
5.9k
Featured
See All Featured
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.9k
Product Roadmaps are Hard
iamctodd
55
13k
Un-Boring Meetings
codingconduct
0
500
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.9k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.4k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
570
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
3
3.9k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
390
WCS-LA-2024
lcolladotor
0
1k
What's in a price? How to price your products and services
michaelherold
247
13k