Bug report or feature request?
bug
ES5 or ES6+ input?
ES6
Uglify version (uglifyjs -V)
uglify-es 3.3.10
JavaScript input
caught by harmony "npm test" reminify:
$ cat mangle_destructuring_decl.js
function test(opts) {
let a = opts.a || { e: 7, n: 8 };
let { t, e, n, s = 5 + 4, o, r } = a;
console.log(t, e, n, s, o, r);
}
test({a: { t: 1, e: 2, n: 3, s: 4, o: 5, r: 6 }});
test({});
$ cat mangle_destructuring_decl.js | bin/uglifyjs -c
ERROR: sym.definition is not a function
at may_modify
This breaks https://github.com/webpack-contrib/uglifyjs-webpack-plugin I had to manually revert the packages dependencies to v3.3.4 to be able to build the project again.
I reverted the version to v3.3.9 and it works well.
Getting this with a file that just uses arrow functions -- no other es6 syntax.
Correction -- changed input to be es5 syntax (var statements, no arrow functions, etc) -- it's still giving this error.
When to bump version code?
@alexlamsl could you please release a new version? A lot of webpack based projects are experiencing failed builds because of this :(
Please, release a new version :(
For those finding their way here from Google, this appears to be a suitable workaround for your package.json
"uglify-es": "3.3.9",
"uglifyjs-webpack-plugin": "1.1.8",
EDIT this appears to not work for everyone. Sorry! Needless to say the only chance this will have of working will be if you clear node_modules and then re-run npm i
@arackaf those versions do not fix my error...
@chenyong - did you clear your node_modules and then re-install?
Just noting the affects parcel too, not just webpack.
I also getting an error while creating bundle.js through webpack using this plugin.
@arackaf's solution worked for me only after removing node_modules and re-installing.
Just to clarify, it won't work for anyone without clearing node_modules and re-installing.
it seems like this is fixed only harmony branch.
ref: https://github.com/mishoo/UglifyJS2/pull/2897
now if you use harmony branch, it'll be fixed.
npm install git://github.com/mishoo/UglifyJS2.git#harmony --save
Please fix it in main branch so everyone can use it.
Any ETA on v3.3.11?
I found something interesting regarding this.
This issue only seem to exist when installing via Yarn. Whenever I use NPM instead of Yarn it seems to work as expected. I have been switching between them for the sake of testing it and it seems pretty consistent. As if NPM installs differently than Yarn or something?
If you really need a fix now, switching to npm install might help you. Please not that your yarn.lock won't work in that case.
@johman10 That's because the npm version has been reverted to 3.3.9

@mishoo Is there any way to install the package through yarn?
As a more permanent fix, you might want to try:
https://github.com/webpack-contrib/babel-minify-webpack-plugin
Solution for Yarn, add following in your package.json file:
"resolutions": {
"uglify-es": "3.3.9"
}
It will make sure any package depending on uglify-es will resolve to 3.3.9 ( https://yarnpkg.com/lang/en/docs/selective-version-resolutions/)
/cc @johman10 @Casedy
@pbadenski's solution of using resolutions did not work for me. Installing with NPM instead of Yarn did however.
Most helpful comment
Please, release a new version :(