Installation
The core package has no runtime dependencies and works with SWC and TypeScript's decorator support.
Requirements
TypeScript 5.0 or higher
SWC or TypeScript compiler with decorator support enabled
Scaffold an app (recommended)
The fastest path is the app CLI:
That writes a tsconfig.json with @di-framework/tsc (plugins), @di-framework/cli, and sample src/index.ts (ttsc and TypeScript 7+ come with @di-framework/tsc). Scripts call di-framework build/di-framework check (which run ttsc). Runtime parameter checks are injected on emit (bun run build). See CLI for check/build and Runtime type checks.
Install the Package
or with yarn:
or with bun:
Configuration
TypeScript Configuration
Ensure your tsconfig.json has the following settings:
Apps from di-framework init also include plugins: [{ "transform": "@di-framework/tsc" }] and emit via ttsc. For manual setup of runtime parameter checks, see Runtime type checks.
SWC Configuration
If you're using SWC, ensure your .swcrc has decorator support enabled:
No Additional Dependencies
The decorators are fully integrated with SWC's native support - no need for reflect-metadata or any other polyfill. This keeps your bundle size small and your dependencies minimal.
Import paths and container singleton
Always import from the scoped package @di-framework/core/* to ensure a single global container instance. Mixing different import IDs (e.g., di-framework/* or relative paths to sources) can load a second copy of the library and create a second global container instance.
Correct:
Avoid:
Verify Installation
Create a simple test file to verify the installation:
Run the file with your TypeScript runner (ts-node, tsx, bun, etc.):
Optional Packages
The core package stands alone. Companion packages add data access, HTTP, GraphQL, events, sockets, RPC, configuration, authentication, and AI support:
Package | Docs |
|---|---|
| |
| Runtime type checks (default in |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
Next Steps
Now that you have the framework installed, learn how to use it:
Quick Start - Learn the basics with simple examples
CLI - App
init/check/buildand maintainermxAPI Reference - Complete API documentation