Import/export syntax is the ESM mechanism for sharing selected bindings between JavaScript modules. A module keeps its declarations private by default and exposes an interface with export; import consumes that interface. ESM uses a static module format, allowing build tools to analyze dependencies and optimize bundled code. section 1.4 section 6.4 section 6.4.2
Choose an export shape that matches the module’s responsibility:
- Use a default export when a module primarily provides one class, function, or other value. section 6.4.2
- Use named exports when a utility module provides several standalone functions, such as validation operations. section 6.4.2
- Use re-exports to assemble a public entry point from modules such as Block, Transaction, and Blockchain. section 6.4.2
- Write explicit module paths for relative, absolute, or remote resources; ESM does not retain Node.js directory-import shortcuts. section 6.4.1
Default and named exports
A class-focused module can expose one primary value: `export default class Transaction { /* ... */ }`. A utility module can expose several operations: `export const checkDifficulty = block => /* ... */` and `export const checkGenesis = block => /* ... */`. These choices make the intended module API visible while keeping supporting declarations private. section 6.4.2
export { default as Block } from './domain/Block.js'
export { default as Transaction } from './domain/Transaction.js'
export { default as Blockchain } from './domain/Blockchain.js'
Shows how re-exported domain modules form a single public API. section 6.4.2




