loadModuleDefault
loadModuleDefault<
T>(absPath,kind,options?):Promise<T>
Defined in: core/src/config-loader.ts:200
임의 모듈 파일 (TS/JS/JSON) 의 default export 를 로드. loadConfig 의 디스패치 로직을
generic 화 — workspace (#2111) 등 config 와 다른 export shape 에서 재사용.
분기:
.json:readFileSync+JSON.parse.ts/.mts/.cts: NAPItranspile()self-compile → tmp.mjs→ dynamic import (cleanup 포함).mjs/.js/.cjs: 직접 dynamic import
존재 여부는 사전 stat 으로 확인하지 않고 read/import 의 ENOENT 를 catch — TOCTOU 회피
- 1 syscall 절감.
Type Parameters
섹션 제목: “Type Parameters”T
호출자가 기대하는 default export 타입. 런타임 검증은 allowArray 외에는 없음.
Parameters
섹션 제목: “Parameters”absPath
섹션 제목: “absPath”string
절대 경로.
kind
섹션 제목: “kind”모듈 종류 — 에러 메시지/임시 파일명에 사용.
options?
섹션 제목: “options?”allowArray: true 면 default export 가 배열일 때도 통과 (workspace 용).
allowArray?
섹션 제목: “allowArray?”boolean
Returns
섹션 제목: “Returns”Promise<T>
default export (또는 default 가 없으면 namespace 객체).
Throws
섹션 제목: “Throws”@zntc/core: <kind> file not found: <path> — 파일 부재
Throws
섹션 제목: “Throws”@zntc/core: failed to parse JSON <kind> ... — JSON 파싱 실패
Throws
섹션 제목: “Throws”@zntc/core: <kind> compile failed in ... — TS self-compile 실패 (ZNTC parser 에러)
Throws
섹션 제목: “Throws”@zntc/core: <kind> must export an object or function (got X) — default 가 잘못된 타입
Throws
섹션 제목: “Throws”@zntc/core: unsupported <kind> extension "<ext>" — 지원 안 하는 확장자