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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
ytaisei
March 27, 2024
Technology
2
450
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
230
Reactを段階的に覗いてみる
ytaisei
3
1.9k
Reactのトランジションを覗いてみる
ytaisei
1
2.5k
Deep Dive Into React 〜React Fiber Architectureについて〜
ytaisei
2
430
React19で状態管理はどう変わるか
ytaisei
2
190
TanStackで効率的なルーティングとデータ取得を実現
ytaisei
10
2.5k
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
Kiro IDEのドキュメントを全部読んだので地味だけどちょっと嬉しい機能を紹介する
khmoryz
0
130
Tebiki Engineering Team Deck
tebiki
0
23k
GSIが複数キー対応したことで、俺達はいったい何が嬉しいのか?
smt7174
3
130
Bill One 開発エンジニア 紹介資料
sansan33
PRO
4
17k
あたらしい上流工程の形。 0日導入からはじめるAI駆動PM
kumaiu
5
720
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.3k
Amazon Bedrock AgentCore 認証・認可入門
hironobuiga
2
490
Frontier Agents (Kiro autonomous agent / AWS Security Agent / AWS DevOps Agent) の紹介
msysh
3
130
CDKで始めるTypeScript開発のススメ
tsukuboshi
1
250
3分でわかる!新機能 AWS Transform custom
sato4mi
1
320
toCプロダクトにおけるAI機能開発のしくじりと学び / ai-product-failures-and-learnings
rince
6
5.3k
月間数億レコードのアクセスログ基盤を無停止・低コストでAWS移行せよ!アプリケーションエンジニアのSREチャレンジ💪
miyamu
0
710
Featured
See All Featured
Making Projects Easy
brettharned
120
6.6k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
210
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
0
310
Joys of Absence: A Defence of Solitary Play
codingconduct
1
280
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
260
How to optimise 3,500 product descriptions for ecommerce in one day using ChatGPT
katarinadahlin
PRO
0
3.4k
Agile that works and the tools we love
rasmusluckow
331
21k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
170
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
160
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
How to Talk to Developers About Accessibility
jct
2
120
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