0.0.2 • Published 4 years ago

@hqjs/babel-plugin-add-decorators-metadata v0.0.2

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

babel-plugin-add-decorators-metadata

Add decorators metadata

Installation

npm install hqjs@babel-plugin-add-decorators-metadata

Usage

{
  "plugins": [["hqjs@babel-plugin-add-decorators-metadata"]]
}

Transformation

Transforms decorators into class metadata, takes care of wrapping providers property into an object. This transformations allow angular to use dependency injection.123

So the code

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {CoreConfig} from './app.service';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule
  ],
  providers: [
    CoreConfig
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

will turn into

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { CoreConfig } from './app.service';
import { AppComponent } from './app.component';
@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule],
  providers: [{
    provide: CoreConfig
  }],
  bootstrap: [AppComponent]
})
export class AppModule {}
AppModule.decorators = [{
  type: NgModule,
  args: [{
    declarations: [AppComponent],
    imports: [BrowserModule],
    providers: [{
      provide: CoreConfig
    }],
    bootstrap: [AppComponent]
  }]
}];