Kagami / gulp-ng-annotate

:pushpin: Add angularjs dependency injection annotations with ng-annotate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ignoring errors on some files

Rush opened this issue · comments

I am trying to build my project with ng-annotate as out of the filters. The problem is that some of the files are written in ES6.

I get the following error from such a file:

{ [Error: services/billingService.js: error: couldn't process source due to parse error
'import' and 'export' may appear only with 'sourceType: module' (1:0)]
  message: 'services/billingService.js: error: couldn\'t process source due to parse error\n\'import\' and \'export\' may appear only with \'sourceType: module\' (1:0)',
  showStack: false,
  showProperties: true,
  plugin: 'gulp-ng-annotate',
  __safety: { toString: [Function: bound ] } }

Is there a way to simply skip ngAnnotate for this file, for example by ignoring this error and making gulp continue?

This is not gulp-ng-annotate issue, you should solve it using gulp machinery, because plugin does the right thing here, throwing the error. You may try to add on('error') callback, see e.g. here or here.

Or, if I understand the issue correctly, you may want to use something like gulp-if to process different sets of files with different plugins.

Unfortunately there is no gulp-if that can help cause ES5 and ES6 files have the same file extension. The only way to tell that it is ES6 is that when ngAnnotate() fails in parsing. Unfortunately when it fails and I handle the error (even with gulp-plumber), the file is not being forwarded to the next pipe.

Unfortunately there is no gulp-if that can help cause ES5 and ES6 files have the same file extension

Then, possible solutions would be to put them in different folders or add extra prefix/suffix manually or transpile your sources to ES5 as recommended here.