https://github.com/unlight/inject-compile-time
Play with Custom Transformer for Typescript that enables compile-time Dependency Injection
https://github.com/unlight/inject-compile-time
Last synced: 10 months ago
JSON representation
Play with Custom Transformer for Typescript that enables compile-time Dependency Injection
- Host: GitHub
- URL: https://github.com/unlight/inject-compile-time
- Owner: unlight
- Created: 2021-12-11T19:35:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-14T17:23:37.000Z (over 4 years ago)
- Last Synced: 2025-08-07T05:31:50.220Z (10 months ago)
- Language: TypeScript
- Size: 173 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Peers
- https://github.com/YePpHa/ts-di-transformer
- https://github.com/wessberg/DI
## https://github.com/YePpHa/ts-di-transformer
```sh
npx webpack && node dist/main.js
```
```ts
class App {
constructor(todo) {
this._todo = todo;
}
}
bootstrap.resolve(app_1.App, [Symbol.for("ITodoService#0978228a")]);
```
### Pros/cons
[-] Do not enable `transpileOnly` - will not work
[+] Maybe better for NestJS
```ts
@Module({
imports: [],
controllers: [AppController],
providers: [
{
provide: InterfaceSymbol(),
useClass: TodoService,
},
],
})
export class AppController {
constructor(@Inject(InterfaceSymbol()) private readonly todoService: ITodoService) { }
}
```
## https://github.com/wessberg/di-compiler
```sh
npx webpack && node dist/bundle.js
```
```ts
class App {
constructor(todo) {
this._todo = todo;
}
static get [Symbol.for("___CTOR_ARGS___")]() { return [`ITodoService`]; }
}
```
## Resouces
- https://github.com/TypeStrong/ts-node#third-party-compilers
- https://github.com/nonara/ts-patch#configuring