Tooling & testing · Concept
ES modules vs CommonJS
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voiceThe interviewer asks
Differences between CommonJS and ES modules? Why does it matter for bundle size and for Node?
Then
Follow-ups the interviewer asks next
- Static vs dynamic structure; live bindings vs copied values.
import()for code splitting; top-level await.- Dual packages: the
exportsfield,"type": "module", and the dual-package hazard. require(esm)support in recent Node versions.
The answer
What a strong answer covers
- ESM: static imports, so tree shaking works; async loading; strict by default
- CJS: runtime
require, synchronous,module.exports - Interop rules and
defaultconfusion
The red pen
Common traps
Avoid:"they're the same thing with different syntax".
Practise this out loud
Say your answer out loud to an AI interviewer that follows up, and get a score for it.
Practise by voicePractise questions like this out loud
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.