babel-plugin-static-injector
v0.0.4
Published
Static injector
Downloads
5
Maintainers
Readme
babel-plugin-static-injector
Adds a call to an inject method of "injector-runtime"
Example
In
import ParentClass from "./parent_class";
class MySimpleClass {
constructor (Service1, Service2) {
}
}
class MyClass extends ParentClass {
constructor (a, b, c, d) {
super(a,b,c);
}
}
Out
import Injector from "injector-runtime";
import ParentClass from "./parent_class";
class MySimpleClass {
constructor(Service1, Service2) {
[Service1, Service2] = Injector.inject(["Service1", "Service2"], [Service1, Service2]);
}
}
class MyClass extends ParentClass {
constructor(a, b, c, d) {
[a, b, c, d] = Injector.inject(["a", "b", "c", "d"], [a, b, c, d]);
super(a, b, c);
}
}
Installation
$ npm install babel-plugin-static-injector
Usage
Via .babelrc
(Recommended)
.babelrc
{
"plugins": ["static-injector"]
}
Via CLI
$ babel --plugins static-injector script.js
Via Node API
require("babel-core").transform("code", {
plugins: ["static-injector"]
});