Skip to content

Instantly share code, notes, and snippets.

@wzhudev
Last active June 15, 2025 00:37
Show Gist options
  • Save wzhudev/9297610736ecb083b08636282d251d48 to your computer and use it in GitHub Desktop.
Save wzhudev/9297610736ecb083b08636282d251d48 to your computer and use it in GitHub Desktop.
JavaScript dependency injection (DI) libraries

Compilation + Runtime

Runtime

Implementations based on reflect-metadata

Implementations not based on reflect-metadata

A benefit of using reflect-metadata is that you don't have to declare dependency for classes.

Say

@Injectable
class A {
  constructor(private readonly b: B) {}
}

The injector will know that A depends on B.

Compare to

class A {
  constructor(@Need(B) private readonly: B) {}
}
@lppedd
Copy link

lppedd commented Jun 15, 2025

While investigating for a DI framework I've also seen https://github.com/exuanbo/di-wise, which relies on https://github.com/tc39/proposal-decorators only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment