Provides a simple runtime module loading utility supporting both import() (dynamic ESM import) and require() (CommonJS require) modes, with optional memory usage tracking after each module load.
- Minimal surface: Single
loadModule(opts)function exported. Options specifyname(module path/name), and optionalmode("import"|"require"). - Memory diff logging: Logs heap usage difference before and after module load at
DEBUGlevel for diagnostics. - Plain JavaScript: Implemented in
.jswith.d.tstypes — no TypeScript compilation needed, directly consumable as-is.
| File | Lines | Role |
|---|---|---|
src/index.js |
34 | loadModule function implementation. |
src/index.d.ts |
— | TypeScript type declarations. |
- Minimal dependencies: only
@scramjet/obj-logger. - Used where dynamic module loading is needed at runtime (e.g., plugin or adapter loading).