"Unexpected token: punc ())" when building for production

In my case it was a leftover comma at the end of a list of functions inside a custom .js file in \src directory.

The tip of by --source-map=true and also setting --build-optimizer=false in angular.json helped me a lot.


After upgrading to angular 8 during production build, I was getting "Error in common-es2015.xxx.js from Terser Unexpected token: Punc(;) [common-es2015.xxx.js] "

After setting sourceMap to true in angular.json file - configurations- production section, compiler displayed actual file name with error line number. It was due to an extra semicolon in a variable declaration in the class file.

putGamma: any = 0.0;; 

It all started with this warning:

enter image description here

It was this missing comma, which I put there to silence the warning, which rendered my project uncompileable.

I was only able to locate this issue by using --source-map but also setting --build-optimizer=false

ng build --prod --named-chunks --verbose --build-optimizer=false --source-map

Tags:

Angular

Eslint