Skip to the page

Tooling & testing · Concept

ES modules vs CommonJS

The 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

  1. Static vs dynamic structure; live bindings vs copied values.
  2. import() for code splitting; top-level await.
  3. Dual packages: the exports field, "type": "module", and the dual-package hazard.
  4. 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 default confusion

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 voice

Practise 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.

Start your free interview