bowser icon indicating copy to clipboard operation
bowser copied to clipboard

Extra comma breaks the production build in angular cli app

Open milen-yordanov opened this issue 5 years ago • 5 comments

See: https://github.com/lancedikson/bowser/blob/2.6.0/src/parser.js#L454 There is an extra comma on the line end.

The library is used in Angular 7 cli project. The production build with ng build --prod

fails with an error: Unexpected token: punc ())

Removing the extra comma fixes the error.

The issue is very similar to: https://stackoverflow.com/questions/54380816/unexpected-token-punc-when-building-for-production

milen-yordanov avatar Sep 10 '19 08:09 milen-yordanov

@milen-yordanov, must be fixed with the 2.6.1 release, please check it out :)

lancedikson avatar Sep 10 '19 18:09 lancedikson

The issue is still present in 2.6.1 See: https://github.com/lancedikson/bowser/blob/2.6.1/src/parser.js#L454 The extra comma on the line end is still there.

milen-yordanov avatar Sep 11 '19 08:09 milen-yordanov

Ok, I was expecting that angular would take a ES5 version of bowser, since 2.6.1 introduces the "browser" property, which points to es5.js. Anyway, I will take a look at the codestyle again or maybe will fix the bundling so, that it would include a standard ES2015 code, which doesn't break any linters. But, you mentioned production only. Does it work in dev mode?

lancedikson avatar Sep 11 '19 10:09 lancedikson

The extra comma breaks the optimized webpack build. Yes, it breaks only the production build. The dev build does not include optimize+uglify+minify and it works.

I just tried 2.6.1 and the the prod build succeeded. But it could be just a coincidence. Version 2.5.4 works fine and version 2.6.0 breaks the build and all these have that extra comma.

Anyway I suggest that comma to be removed.

milen-yordanov avatar Sep 12 '19 07:09 milen-yordanov

This also breaks compiling with google closure compiler

jwoodhull avatar Jun 08 '21 21:06 jwoodhull