Compdi

Zero-overhead, compile-time dependency injection for TypeScript.

Compdi rewrites typed macro calls during your build. The generated code directly constructs and wires your dependencies, so your application ships without a runtime container, decorator metadata, or string tokens.

Get started

Build your first dependency graph in a few minutes.

Choose a lifecycle

Compare singleton, transient, and scoped dependencies.

API reference

Browse public macro signatures and examples.

Why Compdi?

  • Compile-time erasure — macro calls become ordinary JavaScript before runtime.
  • Type-safe dependencies — constructor and factory parameters drive TypeScript inference.
  • No metadata runtime — no reflect-metadata, parameter decorators, or container lookup.
  • Explicit lifecycles — singleton, transient, scoped, and application teardown APIs.
  • Build-tool support — Vite, Rollup, Rolldown, Rspack, and esbuild.

Install

pnpm add compdi

Continue with the quick start to wire your first dependency graph.