andrey-skl / ng-annotate-loader

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

Don't ignore errors from ng-annotate #39

Closed bluetech closed 7 years ago

bluetech commented 7 years ago

If ngAnnotate() fails, it returns an object like this (please ignore this particular error - just an example):

{ errors:
   [ 'error: couldn\'t process source due to parse error',
     '\'import\' and \'export\' may appear only with \'sourceType: module\' (1:0)' ] }

When this happens, the loader returns the original file. Instead, it should report an error and fail.

andrey-skl commented 7 years ago

Sorry, it is unclear from code, but how do it fails? Does webpack throw red-color error to console?

bluetech commented 7 years ago

(The test failure seems unrelated.)

For the example above it looks like this:

Hash: 2cc26f28ae9ad76f7c58
Version: webpack 2.4.1
Time: 217ms
        Asset     Size  Chunks             Chunk Names
       foo.js  2.79 kB       0  [emitted]  foo
   [0] ./src/foo.js 160 bytes {0} [built] [failed] [1 error]

ERROR in ./src/foo.js
Module build failed: error: couldn't process source due to parse error,'import' and 'export' may appear only with 'sourceType: module' (1:0)

The errors are printed in red.

Note that I have no idea about webpack, I'm just trying it for the first time, and looked up how errors are supposed to be handled here. If anyone can do it better, that would be great.

andrey-skl commented 7 years ago

Awesome! Thank you, I'll check the tests.