v1.0.2Latest / April 2026
Modules
Gun works best with explicit ES module imports and a stable project graph.
Imports
Use static imports for local files and packages:
import { createServer } from 'http'
import { loadConfig } from './config'
Static imports let Gun check the whole graph before build time.
Exports
Named exports are easiest to inspect and test:
export function normalizePath(value: string) {
return value.replace(/\\+/g, '/')
}
Default exports are supported, but use them intentionally for a module's primary value.
Dynamic loading
Runtime-generated module names are hard to validate:
await import(`./plugins/${name}.js`)
Prefer an explicit registry:
const plugins = { csv, json, xml }
const plugin = plugins[name]
Package boundaries
Keep adapters around packages that touch the filesystem, network, or native behavior. A small adapter makes compatibility changes local.