Live Bindings

ES module imports are live bindings rather than copied snapshots. An imported binding reflects changes made to the exported binding by the exporting module. However, the importing module cannot directly reassign the imported binding.

This behavior is important for understanding shared module state and circular dependencies.

Live Export
// counter.js
export let count = 0;
export function increment() {
  count++;
}

// app.js
import { count, increment } from './counter.js';
console.log(count);
increment();
console.log(count);
💡 The imported count binding reflects the current exported binding after increment changes it.
Key Takeaways
  • ES module imports are live bindings.
  • Imported bindings cannot be reassigned by the importer.
  • Live bindings influence circular dependency behavior.
Knowledge Check

Are ES module imports simple copied values?