Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token punc «,», expected punc «:» #1653

Closed
jmesa-sistel opened this issue Mar 24, 2017 · 1 comment
Closed

Unexpected token punc «,», expected punc «:» #1653

jmesa-sistel opened this issue Mar 24, 2017 · 1 comment

Comments

@jmesa-sistel
Copy link

Bug
uglify-js 2.8.15

  • JavaScript input: create file test.js with the next code
function f1 (variable) {
  return variable*2
}

function f2 () {
  return false
}

module.exports = {
  f1,
  f2
}
  • The uglifyjs CLI command executed
    uglify-js test.js

  • An example of JavaScript output produced and/or the error or warning.

SyntaxError: Unexpected token punc «,», expected punc «:»
    at JS_Parse_Error.get (eval at <anonymous> (C:\Users\jmesa.SISTEL\AppData\Roaming\npm\node_modules\uglify-js\tools\node.js:27:1), <anonymous>:86:23)
    at C:\Users\jmesa.SISTEL\AppData\Roaming\npm\node_modules\uglify-js\bin\uglifyjs:384:39
    at time_it (C:\Users\jmesa.SISTEL\AppData\Roaming\npm\node_modules\uglify-js\bin\uglifyjs:620:15)
    at C:\Users\jmesa.SISTEL\AppData\Roaming\npm\node_modules\uglify-js\bin\uglifyjs:345:9
    at tryToString (fs.js:448:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:435:12)

To fix the code I have 2 workaround: use acorn (uglify-js --acorn test.js)
or I modifify the code like this:

module.exports = {
  f1:f1,
  f2:f2
}

The problem is that code like this is inside a lot of external modules and I want to use webpack uglify plugin.

@alexlamsl
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants