Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 #3

Merged
merged 6 commits into from
Sep 3, 2017
Merged

V2 #3

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ Simply do: `npm install @wessberg/di-compiler`.

## Usage
```typescript
import {compile, getIntro} from "@wessberg/di-compiler";

// The 'compile' method will upgrade all service registrations and 'get' calls
// throughout the code
const compiled = compile(
"a_file.ts", `
class Foo implements IFoo {}
DIContainer.registerSingleton<IFoo, Foo>();
`);

// The intro is a map between interface names and the constructor arguments
// of their concrete implementations. Should only be injected once in your code
// and at best in top of your bundle.
const intro = getIntro();
import {DICompiler} from "@wessberg/di-compiler";

// Instantiate the compiler
const compiler = new DICompiler();

// The 'compile' method will upgrade all 'registerSingleton', 'registerTransient', 'get' and 'has' calls throughout the code
// and resolve the constructor arguments of all classes that matches the provided services
const compiled = compiler.compile({
file: "a_file.ts",
code: `class Foo implements IFoo {}
DIContainer.registerSingleton<IFoo, Foo>();`
});
compiled.code; // The updated code
compiled.hasChanged; // is true if the source code was upgraded
compiled.map // Holds a SourceMap reflecting the changes
```

If you are using [Rollup](https://github.com/rollup/rollup), then use [rollup-plugin-di](https://github.com/wessberg/rollup-plugin-di) to compile your code automatically as part of your bundle, rather than using this compiler.
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wessberg/di-compiler",
"version": "1.0.47",
"version": "1.0.50",
"description": "The compiler for https://www.npmjs.com/package/@wessberg/di",
"scripts": {
"test": "NODE_ENV=TEST time ava --fail-fast",
Expand Down Expand Up @@ -43,21 +43,19 @@
"compiler"
],
"devDependencies": {
"@types/node": "^8.0.25",
"@wessberg/di": "^1.0.22",
"@types/node": "^8.0.26",
"@wessberg/ts-config": "0.0.23",
"ava": "^0.22.0",
"conventional-changelog-cli": "latest",
"conventional-changelog-cli": "^1.3.3",
"husky": "latest",
"tslint": "^5.7.0",
"typescript": "^2.5.1"
"typescript": "^2.5.2"
},
"dependencies": {
"@wessberg/codeanalyzer": "^1.0.61",
"@wessberg/compiler-common": "^1.0.0",
"@wessberg/globalobject": "^1.0.7",
"@wessberg/type": "^0.0.81",
"@wessberg/typedetector": "^1.0.6",
"@types/chalk": "^0.4.31",
"@wessberg/codeanalyzer": "^1.0.63",
"@wessberg/type": "0.0.87",
"chalk": "^2.1.0",
"magic-string": "^0.22.4",
"tslib": "^1.7.1"
},
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

124 changes: 0 additions & 124 deletions src/Compiler/Compiler.ts

This file was deleted.

18 changes: 0 additions & 18 deletions src/Compiler/Interface/ICompiler.ts

This file was deleted.

63 changes: 0 additions & 63 deletions src/DI.ts

This file was deleted.

Loading