A dynamic module system determines dependencies and module interfaces programmatically at runtime. Code or a module loader creates the module definition in memory, allowing conditional access to modules or parts of modules. section 6.3
Dynamic and static systems differ in how they express module boundaries:
- CommonJS and RequireJS use ordinary JavaScript function calls such as require(...). section 6.3
- ESM uses native import and export syntax, placing imports statically so runtimes and tools can map dependencies ahead of execution. section 6.3
- Dynamic loading supports conditional inclusion, while static definitions support preloading and removal of unreachable package code. section 6.3
CommonJS state versus ESM bindings
A CommonJS calculator exports feePercent, netTotal, and setFeePercent. Changing a destructured feePercent locally does not change the value used by netTotal; calling setFeePercent does. The ESM version exposes the same operations, and its imported feePercent reflects the setter’s update.
