The journeyman’s guide to modules in Node.js
summary
Explains why Node.js keeps two systems: CommonJS stays synchronous with inline execution and a module cache, while ES Modules use asynchronous fetch with getModuleJob for async load and later synchronous evaluation; Node signals ESM via the .mjs extension and relies on dynamic import for interop with CommonJS. Describes VM internals (isolates, contexts, module map cache) and a concrete improvement—exposing a VM compile API to replace insecure string wrapping—and notes cyclic import interop remains unresolved.
AI-written summary · about
chapters (14)
- 0:00Introduction and disclaimer
- 1:03Speaker introduction
- 2:31Why discuss Node.js modules
- 5:01History of JavaScript modules
- 10:44Birth of CommonJS in Node.js
- 15:23AMD and bundlers era
- 19:34Universal Module Definition attempt
- 20:36ES Modules introduction
- 23:05How module systems work in Node.js
- 33:28CommonJS loader deep dive
- 36:20ES Modules vs CommonJS comparison
- 38:48Interoperability challenges
- 40:35Closing remarks and thanks
- 41:17Q&A: Future of Node.js modules
related talks
29mExtra Special Modules
26mNode Es Modules - Something Almost, but not Quite Entirely Unlike Commonjs
32mPlease Wait... Loading: A Talk of Two Loaders
22mPlease wait... loading: a tale of two loaders
32mES Modules in Node JS
48mESM: EcmaScript Modules in browser and NodeJS. It's about time!
31mECMAScript Modules: Past, Present, and Future
34mNode.js: Path to ES6 modules
