Understand the difference between CommonJS and ES Module bindings
A fundamental difference between CommonJS (CJS) and ES Modules (ESM) is how they handle exported values. CJS exports a value copy (snapshot); if the original value changes after the export, the consumer still holds the old value. ESM uses live bindings (references); if the exported value changes in the source module, the consumer sees the updated value immediately.
// CommonJS: Exports a snapshot of the value
let count = 0;
setTimeout(() => count = 1, 100);
module.exports = { count };
// Consumer receives { count: 0 }, it will never become 1
// ESM: Exports a live binding
export let count = 0;
setTimeout(() => count = 1, 100);
// Consumer using 'import { count }' will see count become 1 after 100ms