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

It's not recognizing "let" keyword, any plans to support it ? #480

Closed
sohansoni opened this issue Jul 3, 2017 · 13 comments
Closed

It's not recognizing "let" keyword, any plans to support it ? #480

sohansoni opened this issue Jul 3, 2017 · 13 comments

Comments

@sohansoni
Copy link

It's not recognizing "let" keyword, any plans to support it ?

for e.g. my code is as below
for (let key in item) {

and error is as below:
{ message: 'Unexpected token name «key», expected punc «;»',

@alexlamsl
Copy link
Contributor

uglify-js does not support ES6 - you will need uglify-es for that, which means using the harmony branch of this project:

https://github.com/gruntjs/grunt-contrib-uglify/tree/harmony

@sohansoni
Copy link
Author

Thanks, Does uglify-es have backward compatibility for ES5 code as well ?

@alexlamsl
Copy link
Contributor

Yes.

@sohansoni
Copy link
Author

How do I get the harmony branch , because when I do npm install grunt-contrib-uglify --save-dev its giving me uglify-js instead of uglify-es ?

@chsyzxcv
Copy link

hi sohansoni,
do you find out how to install grunt-contrib-uglify harmony branch ? i am having the same issue as well..

@phoenixdev-kl
Copy link

Found it on https://stackoverflow.com/questions/44848273/how-to-integrate-uglify-es-in-grunt

npm install git://github.com/gruntjs/grunt-contrib-uglify.git#harmony --save-dev

If you are behind a firewall like me, please also notice npm/npm#5257. The following worked fine for me:

git config --global url."https://github.com/".insteadOf [email protected]:
git config --global url."https://".insteadOf git://

@liquidvisual
Copy link

liquidvisual commented Nov 6, 2017

Thanks for this! Was searching for so long, I thought I was never going to find the answer.

liquidvisual added a commit to liquidvisual/swell-0917 that referenced this issue Nov 6, 2017
@Kerwood
Copy link

Kerwood commented Dec 22, 2017

When is harmony branch going to be master and published to npm?
Its nice that we have the opportunity to download and use uglify-es manually, but it gives some challenges if your using a automated pipeline..

@samir-mahendra
Copy link

I have a weird issue with the "harmony" branch as of 3 days ago. Two different functions are getting uglified into the exact same method name, which causes my code to break.

I found that this older commit from the "harmony" branch gets me back to where I was before:

npm install git://github.com/gruntjs/grunt-contrib-uglify.git#c2ccee1b61a585c5f4fca00da8f79cc1db37048b --save-dev

There is probably a more recent commit, but this worked, so I am using it for now.

If I have time, I'll try to put together a minimum reproducible test case. I'm seeing it in an Angular JS project that uses this dependency: https://github.com/chieffancypants/angular-hotkeys. At first I thought it was due to a change to angular-hotkeys, but then realized it only happened with the uglified code.

@liquidvisual
Copy link

I also experienced various errors with everything breaking suddenly, the following fixed it for me:

package.json

"grunt-contrib-uglify-es": "github:gruntjs/grunt-contrib-uglify#harmony",

grunt.js

grunt.loadNpmTasks('grunt-contrib-uglify-es');

.babelrc

{
	sourceType: 'script',
	  presets: [
	    ['env', {modules: false}],
	  ]
}

@induratized
Copy link

induratized commented Jan 25, 2019

Use - https://www.npmjs.com/package/terser

npm install terser

It's APIs are compatible with UglifyJS@3 and supports ES6+

@AkashNeil
Copy link

I had a similar issue (i.e. not supporting ES6) and fixed it as follows:

npm install grunt-contrib-uglify-es --save-dev

@sitthykun
Copy link

Terser is adaptive to ES6+

npm install terser

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

10 participants