Loading
The modern way JavaScript files share code using import and export — like a newer, smarter version of the postal system between files.
The official JavaScript module system (import/export) standardized in ES2015. ESM supports static analysis, enabling tree-shaking and top-level await. In Node.js, ESM is activated by .mjs extension or type: 'module' in package.json.
ESM defines a three-phase loading pipeline: construction (parse and build module graph), instantiation (allocate memory for live bindings), and evaluation (execute top-down). Live bindings mean importers see the exporter's current value, not a copy. Top-level await blocks the evaluation of dependent modules in the graph. Import assertions (with { type: 'json' }) and import attributes provide module type metadata for non-JS resources.