Language concepts
Module live binding
A static import resolves to a binding owned by another module. Subsequent changes made by the exporter are observable through the imported name. Copying a primitive into a local variable does not create a live binding. Multi-file example: save each listed file separately, then run the entry file with Node.js. See the packaged fixture for the original files.
Formal Syntax & Structure
javascript syntaxjavascript
import { value } from "./dependency.mjs";Working Example
Example Snippetjavascript
// File: counter.mjsexport let count = 0;export function inc() { count++; }
// File: main.mjsimport { count, inc } from "./counter.mjs";const snapshot = count;inc(); inc();console.log(count, snapshot);