angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.56k stars 3.01k forks source link

Uglify version 1.0.17 #3693

Closed Bildelsbasen closed 6 years ago

Bildelsbasen commented 6 years ago

Im having trouble using uglify on version 1.0.17. Getting following error: JS_Parse_Error { message: 'Unexpected token: punc ())'

stack: 'Error\n at new JS_Parse_Error (/node_modules/grunt-contrib-uglify/node_modules/uglify-js/lib/parse.js:196:18)

Best regards Andreas

mistic100 commented 6 years ago

Somehow the problem seems to be with the TS compilation of ui-router/core

This line https://github.com/ui-router/core/blob/master/src/common/common.ts#L512 is compiled to

         result.push(
            args.map(function(array) {
              return array[i];
            }), // <= extra comma
          );
ohadcn commented 6 years ago

this breaks my entire build I've locked my system to 1.0.15 for now

bobbyziom commented 6 years ago

@mistic100 exactly the same for me with.

To run this version i needed to exclude it from grunt-contrib-concat, and extend the import manually afterwards.

Need to lock my dependencies!

westy92 commented 6 years ago

@mistic100 great find! Could this potentially be a TypeScript bug? According to the tsconfig.json, the project is targeting ES5: https://github.com/ui-router/core/blob/master/tsconfig.json#L7.

According to MDN, "ECMAScript 2017 allows trailing commas in function parameter lists." https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas#Trailing_commas_in_functions

westy92 commented 6 years ago

I copied the export function arrayTuples(...args: any[]): any[] { function to its own file and also copied the tsconfig.json. The resulting transpiled js did not have the trailing comma:

            default:
                result.push(args.map(function (array) { return array[i]; }));
                break;

Something else must be adding it?

paulodrade commented 6 years ago

Any update on this bug?

This is breaking my build. I need to go back to v1.0.15 (since v1.0.16 is not available to download).

Thanks

mistic100 commented 6 years ago

It was probably fixed by https://github.com/ui-router/core/commit/578dc091914faac9954f9aed4765007b5c1acf76 and https://github.com/angular-ui/ui-router/commit/5fb93d042d5833514357d6e7956a4cf85be26900

now we need a release :-)

r3plica commented 6 years ago

Can confirm that I am getting this too. Took me ages to find out the cause.....

christopherthielen commented 6 years ago

This was a puzzler because the published code on NPM doesn't have any trailing commas. Then I remembered that I added a git precommit hook which runs prettier on all staged files for commit. Finally I remembered that the uirouter bower publish script commits the bundled files to git, and prettier was being run on them.

This issue only affects bower users. (please stop using bower 😉)

I will fix this issue and publish a new release ASAP.