---
title: "buildRegistry(): TypeShade 셰이더 API의 도구 분류 함수 참조 문서"
description: "buildRegistry, TypeShade API의 도구 분류에 속하는 함수입니다. 발견한 모듈 집합을 지정된 순서에 맞춰 검증하고, 그 집합으로 레지스트리 모듈을 생성합니다."
url: https://typeshade.dev/ko/api/buildregistry/
language: ko
---

# `buildRegistry()`

함수, 도구 분류

발견한 모듈 집합을 지정된 순서에 맞춰 검증하고, 그 집합으로 레지스트리 모듈을 생성합니다. 생성된 모듈에는 id의 유니온 타입, id에서 모듈로 대응하는 레코드, 그리고 이 레코드를 채우는 import가 들어갑니다.

`import { buildRegistry } from 'typeshade'`

설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.

## 구문

```ts
function buildRegistry(
  entries: readonly RegistryEntry[],
  opts?: BuildRegistryOptions,
): BuiltRegistry
```

## 매개변수

**`entries` `readonly RegistryEntry[]`**

호출하는 쪽의 검색이 찾은 모든 모듈입니다.

**`opts` 선택 사항 `BuildRegistryOptions`**

지정된 순서, 이름 규칙, 배너의 세부 사항입니다.

## 반환값

`BuiltRegistry`

렌더링된 소스와 파일에 나타나는 순서의 id들입니다.

## 예외

**`Error`**

두 항목이 같은 id를 가질 때, 내보내기 이름이 식별자가 아닐 때, 또는 `order`와 발견한 집합이 양방향으로 어긋날 때 발생합니다. 어긋나는 방향은 두 가지입니다. 모듈을 가리키지 않는 등록 목록의 id가 있거나, 어떤 등록 목록의 id도 가리키지 않는 모듈이 있습니다. 오류 메시지는 두 종류의 불일치를 모두 나열하며, `regenerateWith` 명령이 주어졌다면 그 명령도 함께 보여 줍니다.

## 설명

이 함수는 파일 시스템에 접근하지 않습니다. 호출하는 쪽이 자신의 디렉터리를 검색하고, 모듈마다 [`RegistryEntry`](https://typeshade.dev/ko/api/registryentry/)를 하나씩 만든 뒤, 돌려받은 소스를 파일에 씁니다.

```ts
// `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',
})
```

## 함께 보기

- [`RegistryEntry`](https://typeshade.dev/ko/api/registryentry/)

## 소스

[`src/core/registry.ts`, 99행](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/registry.ts#L99), 커밋 af54ddad5 기준
