module-registry

작성자: cloudflare

workerd에서 모듈 레지스트리를 작업할 때 로드 — 모듈 해석, 컴파일, 평가, 등록을 읽기, 수정, 디버깅, 검토하는 경우…

npx skills add https://github.com/cloudflare/workerd --skill module-registry

Module Registry Context

When working with any code related to module resolution, compilation, evaluation, or registration in workerd, you must read the relevant reference documents before making changes or providing analysis. These documents capture the design decisions, data flow, thread safety model, and integration points that are not obvious from reading the source alone.

Reference Documents

Read these documents (using the Read tool) before proceeding with any module registry work:

  1. docs/reference/detail/new-module-registry.md — The new jsg::modules::ModuleRegistry implementation. Covers the two-layer architecture (shared ModuleRegistry + per-isolate IsolateModuleRegistry), bundle types, resolution priority, compile cache, evaluation flow, and thread safety model. Read this first for any work on the new registry.

  2. docs/reference/detail/legacy-module-registry.md — The legacy ModuleRegistryImpl<TypeWrapper> implementation. Covers the per-isolate design, ModuleInfo structure, DynamicImportHandler, and how it interfaces with V8. Read this when working on code that still uses the legacy path, or when understanding the dispatch between legacy and new.

  3. docs/reference/detail/v8-module-internals.md — How V8 handles modules internally. Covers v8::Module status transitions, InstantiateModule, Evaluate, SyntheticModule, resolve callbacks, and import.meta. Read this when debugging V8 module state issues, understanding callback contracts, or working on the boundary between workerd and V8.

When to Read Which

TaskDocuments to read
Modifying new registry resolution or cachingnew-module-registry, v8
Adding a new built-in modulenew-module-registry, legacy-module-registry
Debugging module-not-found errorsall three
Modifying legacy registry codelegacy-module-registry, v8
Understanding legacy-to-new dispatchall three
Working on import.meta behaviornew-module-registry, v8
Working on CJS/require() interopnew-module-registry, legacy-module-registry
Debugging module evaluation failuresnew-module-registry, legacy-module-registry, v8
Reviewing a PR that touches module codeall three
Working on compile cache or cross-isolate sharingnew-module-registry
Working on dynamic importall three
Working on source phase imports (Wasm)new-module-registry, v8

Key Source Files

These are the primary files involved in module handling:

  • src/workerd/jsg/modules-new.h / .c++ — New registry implementation
  • src/workerd/jsg/modules.h / .c++ — Legacy registry implementation
  • src/workerd/jsg/resource.h:1913–1922 — Legacy vs new dispatch at context creation
  • src/workerd/jsg/jsg.c++:357–395Lock::resolveModule dispatch
  • src/workerd/jsg/setup.h:291–297isUsingNewModuleRegistry() flag
  • src/workerd/io/worker-modules.hnewWorkerModuleRegistry construction
  • src/workerd/api/modules.h — Built-in module registration (both legacy and new)
  • src/workerd/jsg/observer.hResolveObserver metrics interface

Procedure

  1. Read the relevant reference documents listed above for your task.
  2. Identify whether the code path uses the new or legacy registry (check isUsingNewModuleRegistry() usage in the surrounding code).
  3. Proceed with your work, using the reference documents to inform your understanding of data flow, thread safety, and integration contracts.

Do not skip reading the reference documents. The module registry has subtle invariants around thread safety, V8 module status transitions, and evaluation context (IoContext suppression) that are easy to violate without full context.

cloudflare의 다른 스킬

workerd-api-review
cloudflare
workerd 코드 리뷰를 위한 성능 최적화, API 설계 및 호환성, 보안 취약점, 표준 사양 준수. tcmalloc 인식…
official
workerd-safety-review
cloudflare
메모리 안전성, 스레드 안전성, 동시성, 그리고 workerd 코드 리뷰를 위한 중요 탐지 패턴. V8/KJ 경계 위험 요소, 수명 관리 등을 다룹니다.
official
reproduce
cloudflare
cloudflare/agents GitHub 이슈를 재현하기 위해 최소한의 Agents/Worker 프로젝트를 스캐폴딩하고 임시 Cloudflare 계정에 배포한 후 보고합니다…
official
local-explorer
cloudflare
로컬 탐색기 또는 로컬 API에 제품/리소스를 추가하는 방법. 새로운 로컬 API나 UI 라우트를 구현할 때 사용합니다.
official
commit-categories
cloudflare
커밋을 체인지로그와 "새로운 기능" 요약으로 분류하는 규칙입니다. 체인지로그 또는 whats-new 명령에서 커밋을 분류하기 전에 반드시 로드되어야 합니다. 제공하는 기능:
official
architecture
cloudflare
코드베이스를 처음 탐색할 때, 새 클라이언트 메서드를 추가할 때, 새 컨테이너 핸들러/서비스를 추가할 때, 또는 요청 흐름을 이해할 때 사용합니다.
official
changesets
cloudflare
변경셋을 생성하거나, 릴리즈를 준비하거나, 버전을 올릴 때 사용합니다. 참조할 패키지, 사용자 대상 변경셋 설명 작성 방법 등을 다룹니다.
official
pr
cloudflare
클라우드플레어 문서 변경 사항에 대한 GitHub 풀 리퀘스트를 생성하고 업데이트합니다. 열기, 생성, 제출, 업데이트, 편집, 제목 또는 설명 작성 요청 시 로드됩니다…
official