buildRegistry()
함수, 도구 분류
Validate a discovered module set against a curated order and render a registry module from it: a union type of the ids, a record from id to module, and the imports feeding it.
import { buildRegistry } from 'typeshade'
시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
function buildRegistry( entries: readonly RegistryEntry[], opts?: BuildRegistryOptions,): BuiltRegistry매개변수
entriesreadonly RegistryEntry[]every module the caller’s scan discovered.
opts선택 사항BuildRegistryOptionscurated order, naming, and banner details.
반환값
the rendered source and the ids in file order.
예외
Errorwhen two entries share an id, when an export name is not an identifier, or when
orderand the discovered set disagree in either direction: a curated id that names no module, or a module that no curated id names. The error message lists both kinds of mismatch, and theregenerateWithcommand when one was given.
설명
The function does not touch the filesystem. The caller scans its own directories,
builds one RegistryEntry per module, and writes the returned source to a file.
// `scanExamples` and `CURATED_IDS` are the caller's: a directory walk that returns// RegistryEntry[], and the hand-written id order it must agree with.const { source } = buildRegistry(scanExamples('./examples'), { order: CURATED_IDS, valueType: 'ShaderExample', imports: ["import type { ShaderExample } from './_shared.js'"], regenerateWith: 'bun scripts/gen-registry.ts > examples/registry.generated.ts',})함께 보기
소스
src/core/registry.ts, 99행, 커밋 c66579bf 기준