Node Es Modules - Something Almost, but not Quite Entirely Unlike Commonjs
summary
NodeJS is adding native ES Modules with concrete rules: files ending .mjs are ESM, .js remain CommonJS; ESM uses export/import, CJS uses require. ESM gives live bindings (imports stay synced) and does static asynchronous loading so dynamic import returns a Promise, changing execution order. Interop is limited: ESM can default-import CJS, CJS must use dynamic import for ESM. Migration options include codemods, renaming files to .mjs, or publishing dual-mode libraries by compiling ESM to companion CJS outputs with Babel. Experimental flag remains.
AI-written summary · about
chapters (8)
- 0:00Intro
- 0:30ES Modules
- 2:06File extensions
- 3:47Named exports
- 4:31Default exports
- 5:52Export variables
- 7:19Binding
- 17:05Migration
related talks
29mExtra Special Modules
32mES Modules in Node JS
32mPlease Wait... Loading: A Talk of Two Loaders
22mPlease wait... loading: a tale of two loaders
48mESM: EcmaScript Modules in browser and NodeJS. It's about time!
46mThe journeyman’s guide to modules in Node.js
48mTomorrow's ES modules today
31mECMAScript Modules: Past, Present, and Future
