npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@spirex/di

v1.1.1

Published

Powerful, type-safe, flexible, and lightweight dependency injection library designed for JS/TS projects of any complexity.

Downloads

328

Readme

NPM Type Definitions NPM Version GitHub License Codecov

SpireX/DI

@spirex/di is a powerful, lightweight, and predictable dependency injection library for JavaScript and TypeScript.

It enforces strict TypeScript typing through a TypeMap, uses an immutable container built via a fluent builder API, and supports modular, reusable configurations. With zero dependencies, advanced scope management, and extensible middleware, it keeps your code clean, testable, and flexible without imposing any runtime boilerplate.

Fully plug & play and production-ready, SpireX/DI is ideal for enterprise projects, helping teams manage complex service graphs effortlessly while simplifying long-term maintenance.

Features

  • Immutable container — no hidden runtime mutations;
  • Maximum type safety — full autocompletion & compile-time checks;
  • Modular — static & dynamic modules;
  • Advanced scope management with auto-dispose;
  • Lifecycle management — singleton, lazy, scope, transient;
  • Middleware support;
  • Named bindings, aliases & conflict resolution strategies;
  • Zero dependencies, runs on pure JS, only ~9.3KB (~3.4kb gzipped).

Installing

# npm
npm i @spirex/di

# yarn
yarn add @spirex/di

Quick Start

import { diBuilder, factoryOf } from "@spirex/di";

class Gateway { ... }

class Service {
    static inject = ['gateway'] as const
    constructor(gateway: Gateway) {...}
    doSomething(): void { ... }
}

// Create a DI container with strict type mapping
const container = diBuilder<{
    gateway: Gateway; // Key 'gateway' maps to Gateway instance
    service: Service; // Key 'service' maps to Service instance
}>()
    // Bind 'service' to a factory
    // that resolves its dependencies from the container
    .bindFactory("service", factoryOf(Service))

    // Bind 'gateway' to a Gateway factory
    .bindFactory("gateway", factoryOf(Gateway))

    // Build the container;
    // after this, it becomes immutable & ready to use
    .build();

// Retrieve the 'service' instance from the container
const service = container.get("service");

Explanation:

  1. We define Gateway and Service classes. Service depends on Gateway.
  2. We create a strictly typed container using diBuilder().
  3. .bindFactory is used to register services with dependencies.
  4. .build() finalizes the container.
  5. .get("service") returns the fully constructed Service with Gateway automatically injected.

Documentation

Documentation is a work in progress! Some topics are not yet covered. For the most up-to-date documentation, please refer to the repository.

Integrations & Extensions

Container is designed to be fully extensible and works seamlessly with additional packages to enhance functionality:

| Package | Description | | ------- | ----------- | | @spirex/di-dynamic | SpireX/DI Dynamic Modules - allowing you to load parts of your container asynchronously at runtime. | | @spirex/di-react | SpireX/DI for React - provides a fully typed, declarative, and scoped DI system built on top of the React Context API and hooks. | | @spirex/di-svelte | SpireX/DI for Svelte - provides Svelte integration for injecting dependencies into components.| | @spirex/di-angular-bridge | Using SpireX/DI as a domain-level service container with standard Angular DI access. | | @spirex/di-config | SpireX/DI Config - provides a middleware that configures services right after they are created. |

License

@spirex/di is released under the MIT License.

You are free to use, modify, and distribute the library in both personal and commercial projects.