olov / ng-annotate

Add, remove and rebuild AngularJS dependency injection annotations
MIT License
2.03k stars 150 forks source link

Feat support acorn options sourceType and ecmaVersion #259

Closed Mischi closed 7 years ago

Mischi commented 7 years ago

Hi,

can we add support for the acorn options sourceType and ecmaVersion?

  • sourceType: Indicate the mode the code should be parsed in. Can be either "script" or "module". This influences global strict mode and parsing of import and export declarations.
  • ecmaVersion Indicates the ECMAScript version to parse. Must be either 3, 5, 6 (2015), 7 (2016), or 8 (2017). This influences support for strict mode, the set of reserved words, and support for new syntax features. Default is 7. [acorn]

This would allow us to annotate code with es6 modules like in the following snippet:

var AppController = (function () {
    function AppController($scope) {
        "ngInject";
        this.$scope = $scope;
        this.title = 'AppController';
    }
    AppController.prototype.$onInit = function () {
        console.log(this.$scope);
    };
    return AppController;
}());
export { AppController };

Currently if only need sourcetype: "module" but i thought it would be a good idea to support ecmaversion too. What do you think?

Cheers, Fabian

CC @loxy

omsmith commented 7 years ago

Closing as per #245 #253. May be available in a replacement project, or could otherwise be contributed there.

Thanks