andrey-skl / ng-annotate-loader

Webpack loader to annotate angular applications
MIT License
120 stars 28 forks source link

Es6 + Webpack + Babel cannot make this work #30

Open zambov opened 8 years ago

zambov commented 8 years ago

Hi all,

cannot make this work, i have all the time unkjnown provider. Here is my webpack conf:

{
   test: /\.js$/,
   exclude: /(node_modules|bower_components)/,
   loader: 'ng-annotate!babel-loader?presets[]=es2015&presets[]=stage-2&compact=false'
},

Here is my controller:

/* @ngInject / /*

class ProvaController {

constructor($log) {

    $log.debug('Instatiated the ProvaController');
    this.name = "ProvaController";
};

}

export default ProvaController;

But i've tried also:

/*
* @author Trilogis developer
* prova
* 
* This is a module generated with trilogis template module scaffolder
*/

class ProvaController {

    constructor($log) {
'ngInject';

        $log.debug('Instatiated the ProvaController');
        this.name = "ProvaController";
    };
}

export default ProvaController;

Any ideas?

thinkingmedia commented 7 years ago

I don't think ngAnnotate works with classes. You have to use ngInject() to manually inject dependencies.

zambov commented 7 years ago

Thank you for your reply! I've done it manually.

thinkingmedia commented 7 years ago

I switched from the loader to the https://github.com/jeffling/ng-annotate-webpack-plugin as it has better support for ES6 features. Import and export work as an example.