Middle
What is the difference between modularity systems?
sobes.tech AI
Answer from AI
There are two main module systems in JavaScript: CommonJS (CJS) and ES Modules (ESM).
| Feature | CommonJS (CJS) | ES Modules (ESM) |
|---|---|---|
| Import syntax | require() |
import |
| Export syntax | module.exports or exports |
export |
| Loading | Synchronous | Asynchronous |
| Node.js support | Native, without flags | Requires .mjs extension or ` |