Skip to content

Commit

Permalink
Add DI adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
amanteaux committed Jan 24, 2023
1 parent 5a7343b commit 4bae5e3
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 7 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,25 @@ After ttypescript is installed, you can reference the transformer in your `tscon
{
"compilerOptions": {
"plugins": [
{ "transform": "ts-transformer-class-name" }
{ "transform": "ts-transformer-classname", "import": "classNameTransformer" }
]
}
}
```

DI Compiler adapter
-------------------
The adapter for DI [Compiler](https://github.com/wessberg/DI-compiler) is now provided. To use it:
```json
{
"compilerOptions": {
"plugins": [
{ "transform": "ts-transformer-classname", "import": "diTransformerAdapter" }
]
}
}
```

Release process
---------------
1. run `npm login`
2. run `npm run release` <= yarn **must not** be used
Run `yarn release`
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"main": "build/cjs/index.js",
"typings": "build/esm/index.d.ts",
"module": "build/esm/index.js",
"dependencies": {
"@wessberg/di-compiler": "^2.2.6"
},
"peerDependencies": {
"plume-ts-di": "^1.0.2",
"typescript": "^4.1.3"
Expand Down
5 changes: 2 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
import { classNameTransformer } from "./lib/classNameTransformer";

export default classNameTransformer;
export { classNameTransformer } from './lib/classNameTransformer';
export { diTransformerAdapter } from './lib/diTransformerAdapter';
9 changes: 9 additions & 0 deletions src/lib/diTransformerAdapter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { di } from '@wessberg/di-compiler';
import * as ts from 'typescript';

/**
* Transformer used for dependency injection
*/
export function diTransformerAdapter(program: ts.Program) {
return di({ program });
}
Loading

0 comments on commit 4bae5e3

Please sign in to comment.