Skip to content

NeoSyringeCompile-Time DI

Zero-overhead dependency injection that shifts resolution from Runtime to Build-Time. No reflection, no decorators, just pure TypeScript.

NeoSyringe

Why Choose NeoSyringe?

Traditional DI containers like InversifyJS and tsyringe rely on runtime resolution:

  • ❌ Ship DI container logic to the browser
  • ❌ Errors happen at runtime
  • ❌ Interfaces are erased, requiring manual Symbols
  • ❌ Need decorators and reflect-metadata

NeoSyringe is different. It works as a compiler plugin:

  • ✅ Generate optimized factories at build time
  • ✅ Errors detected in your IDE
  • ✅ Automatic interface IDs
  • ✅ Pure TypeScript, no decorators

Quick Example

typescript
// Pure TypeScript - no decorators!
interface ILogger {
  log(msg: string): void;
}

class ConsoleLogger implements ILogger {
  log(msg: string) { console.log(msg); }
}

class UserService {
  constructor(private logger: ILogger) {}
}

// Configure the container
import { defineBuilderConfig, useInterface } from '@djodjonx/neosyringe';

export const container = defineBuilderConfig({
  name: 'AppContainer',
  injections: [
    { token: useInterface<ILogger>(), provider: ConsoleLogger },
    { token: UserService }
  ]
});

// Use it with full type safety
const userService = container.resolve(UserService);
// Type: UserService ✅ - Full auto-completion!

Zero DI library shipped to production! The build plugin replaces your defineBuilderConfig(...) with an optimized container class — no runtime overhead, no reflection, no magic.

Released under the MIT License.