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
JavaScript Modules & Current Updates
Search
Rizqy Hidayat
November 23, 2021
Programming
0
89
JavaScript Modules & Current Updates
Rizqy Hidayat
November 23, 2021
Tweet
Share
More Decks by Rizqy Hidayat
See All by Rizqy Hidayat
HTMX: Back to Basic
rizqyhi
0
44
Exploring PEMPA Architecture on Dicoding.com
rizqyhi
0
28
Menjelajah Dunia Frontend Lebih Jauh
rizqyhi
0
9
Introduction to Open Source & Hacktoberfest
rizqyhi
0
94
Frontend is Enough
rizqyhi
0
28
Other Decks in Programming
See All in Programming
組込みだけじゃない!TinyGo で始める無料クラウド開発入門
otakakot
2
360
Goで実践するドメイン駆動開発 AIと歩み始めた新規プロダクト開発の現在地
imkaoru
4
890
あなたとKaigi on Rails / Kaigi on Rails + You
shimoju
0
180
『毎日の移動』を支えるGoバックエンド内製開発
yutautsugi
2
280
Devvox Belgium - Agentic AI Patterns
kdubois
1
140
CSC305 Lecture 10
javiergs
PRO
0
220
チームの境界をブチ抜いていけ
tokai235
0
210
PHPに関数型の魂を宿す〜PHP 8.5 で実現する堅牢なコードとは〜 #phpcon_hiroshima / phpcon-hiroshima-2025
shogogg
1
330
オープンソースソフトウェアへの解像度🔬
utam0k
17
3.1k
Flutterで分数(Fraction)を表示する方法
koukimiura
0
140
ソフトウェア設計の実践的な考え方
masuda220
PRO
4
630
AI駆動で0→1をやって見えた光と伸びしろ
passion0102
1
800
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.3k
How to Ace a Technical Interview
jacobian
280
24k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3k
YesSQL, Process and Tooling at Scale
rocio
173
15k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
127
54k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
49
51k
Building an army of robots
kneath
305
46k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.7k
Six Lessons from altMBA
skipperchong
29
4k
Become a Pro
speakerdeck
PRO
29
5.6k
Transcript
JavaScript Modules & Current Updates Rizqy Hidayat PRODUCT ENGINEER, DICODING
Aloha 👋 Rizqy Hidayat PRODUCT ENGINEER, DICODING
[email protected]
- @rizqyhi
Prehistoric module Era 🦕 • • • JavaScript doesn't have
built-in support for modules Modular files, global scope Dependencies should be loaded before and configured manually
None
COMMONJS AMD UMD ESM Used in NodeJS (server) Used in
browser (client) Works for both node & browser Newest stanndard on ES6 ✨ History of Modules in JavaScript
CommonJS • • • Standard used in NodeJS for working
with modules Load modules synchronously Simple syntax
Asynchronous Module Definition (AMD) • • • • Alternative to
CommonJS, usually used in browser Needs library to handle module resolution Load modules asynchronously Slightly complex syntax
What if our library used by many teams? And they
used CommonJS and AMD?
Universal Module Definition (UMD) • • • Unify CommonJS and
AMD More complex syntax Use build tool to help generate exported modules
None
EcmaScript Module (ESM) • • • • Part of ES6/ES2015
standard The best from both CommonJS and AMD: Simple syntax Load module asynchronously
Use ESM in Browser Now • • • Import directly
from file/CDN No transpilation needed No need to bundle
None
Does it work on old browsers? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
ESM in Older Browser • • • Write code in
ES6 Transpile to ES5 Bundle into one file or split into chunks
Takeaways • • • • • Use ESM to work
with modules Write JavaScript in newest standard Or TypeScript if necessary Transpile to older format when in needs to support old browsers Use best tools available that suites your needs
Thanks!