Documents injecute 1.x · Migrating from 0.x
Skip to content

Comparison ​

How injecute compares with other ways to do dependency injection in TypeScript. Every claim about another library links to its docs, README or source in Sources, checked against the versions in the first table. Found something wrong or out of date? Tell us in Discussions.

Wiring ​

LibraryVersionHow a service gets its dependenciesA missing registration is…Decorators / reflect-metadata
injecute1.0Each registration lists its dependency keys: addSingleton('users', Repo, ['db'])a compile error ("Did you mean …?")none
typed-inject5.0.0A static inject = ['db'] as const array on the class or functiona compile errornone
needle-di1.2.1inject(Token) in constructor defaults or fields, or providers bound by handa runtime error (token types are checked)optional standard decorators, no reflect-metadata
Awilix13.0.5By name: a destructured "cradle" object, or parsed parameter names; loadModules globsa runtime error (the container type grows since v13, asClass isn't typed)none
InversifyJS8.2.3@injectable() / @inject(id) and container.bind(id)a runtime error (opt-in typed binding map)required for decorator injection
tsyringe4.10.0@injectable() and emitted constructor types; @inject(token) for other tokensa runtime errorrequired
NestJS12.3.2@Injectable() providers in modules, resolved by constructor typea runtime error at bootstraprequired
Effect4.1.1Services (Context.Service) used with yield*, provided by layersa compile error (unmet requirements stay in the type)none

Lifetimes, async and disposal ​

LibraryScoped servicesA singleton that depends on a scoped serviceAsync servicesDisposal
injecuteScopes: a fork with its own servicesa compile error for a scope-only key; a scope that re-registers a root key must say replace: true, and the error names the root services that keep the root's instanceAsyncDIContainer awaits every dependency; async singletons in any containerdispose() / await using (Symbol.dispose), lifecycle hooks
typed-injectChild injectors; Singleton and Transientnot documentednot documentedinjector.dispose() calls dispose() methods
needle-diChild containers; every provider is a singleton per containernot documentedasync providers with getAsync()not documented
AwilixSCOPED lifetime with createScope()a runtime error in strict mode (opt-in, off by default)not built in (a third-party package)dispose() with per-registration disposers
InversifyJSChild containers; "Request" means one get() callnot handledgetAsync()onDeactivation / @preDestroy on unbind; Symbol.dispose through a plugin
tsyringeContainerScoped in child containersnot handlednonedispose() calls dispose() methods
NestJSScope.REQUEST, durable providersprevented: a request-scoped dependency makes its consumers request-scoped tooasync factory providerslifecycle hooks (not called for request-scoped providers)
EffectNo named scope: provide the service or layer per unit of worknot documentedlayers are built from effectsscopes and finalizers (acquireRelease)

Size ​

The size of a small app that registers a value and a service that depends on it, resolves the service and prints it: bundled with esbuild 0.28 for the browser, minified and gzipped, each bundle run to check it prints the right value.

LibraryBundle (gzipped)Runtime dependenciesModule formats
typed-inject1.4 kBnoneESM
needle-di2.7 kBnoneESM (npm and JSR)
Awilix3.6 kB (browser build, without loadModules)fast-glob (Node.js build)CommonJS, ESM, browser
injecute6.3 kB (error hints are left out in browser bundles)noneESM (npm and JSR)
tsyringe9.2 kB with the reflect-metadata polyfill it needstslib, plus a Reflect polyfillCommonJS, ES5 ESM
InversifyJS22.9 kB@inversifyjs/* packagesESM
Effect59.7 kB (the Effect runtime)noneESM
NestJSnot comparable: a server framework5 small packages; reflect-metadata, rxjs as peersESM

Versions and dependencies are from the npm registry.

Where injecute is different ​

  • Explicit scopes that can't leak. A root service can't name a key that only a scope registers, and a scope that re-registers a root key gets an error naming the root services that keep the root's instance. Of the libraries above, NestJS prevents the leak by making consumers request-scoped, Awilix detects it in strict mode, and the rest don't handle it.
  • A whole-graph check in one test. checkWiring() reports every missing key and every failing factory at once.
  • Errors with codes and pages. Every error has a stable code, the resolution path, and a page that says how to fix it.
  • Lifecycle and disposal built in. dispose(), await using, and startup and shutdown hooks without a framework.
  • Docs for coding agents in the package. llms.txt, the docs of the installed version and an Agent Skill ship with it (AI agents).

Sources ​

typed-inject ​

needle-di ​

Awilix ​

InversifyJS ​

tsyringe ​

NestJS ​

Effect ​

injecute ​

Released under the MIT License.