0

I'm following the instructions to get advanced JS bundling done. I have been doing this over a year without much difficulty. This time around, I find the error below and I would like to know if there is a solution to this. Thanks.

SyntaxError: Unexpected token: name (url)

A line appearing after this line seems to give some clue as to what could be done to fix this.

If the source uses ES2015 or later syntax, please pass "optimize: 'none'" to r.js and use an ES2015+ compatible minifier after running r.js. The included UglifyJS only understands ES5 or earlier syntax.

The command below causes this error.

r.js -o build.js

1 Answer 1

1

It appears you have some Javascript that is using ES6 or newer syntax and the version of UglifyJS does not support this.

It looks like version 3.13.0 does support ES6 so I suggest either upgrading to that, using an alternative. If that is not possible then you will need to re-write your JS to ES5 standards. To find the code responsible try searching your codebase for name (url).

If it is already written to ES5 then you most likely have a syntax error so you'll need to find that.

Another option is to set optimize: "none" although I'm unsure what affect on the bundle that will have, it sounds like the files will not be minified if that value is "none".

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.