Split code across files with CommonJS.
- export with
module.exports = ...orexports.x = ... - import with
const x = require('./file') - each file is its own module (own scope)
- ESM alternative:
import/exportwith"type": "module"
See examples/.
Split a 50-line file into 3 modules.