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

[ES6] destructuring regression in collapse_vars: ERROR: sym.definition is not a function #2896

Closed
kzc opened this issue Feb 8, 2018 · 22 comments

Comments

@kzc
Copy link
Contributor

kzc commented Feb 8, 2018

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
@YounesM
Copy link

YounesM commented Feb 8, 2018

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.

@falsandtru
Copy link

I reverted the version to v3.3.9 and it works well.

@toddself
Copy link

toddself commented Feb 8, 2018

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.

@djyde
Copy link

djyde commented Feb 9, 2018

When to bump version code?

@satazor
Copy link

satazor commented Feb 11, 2018

@alexlamsl could you please release a new version? A lot of webpack based projects are experiencing failed builds because of this :(

@gimdongwoo
Copy link

Please, release a new version :(

@arackaf
Copy link

arackaf commented Feb 12, 2018

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

@chenyong
Copy link

@arackaf those versions do not fix my error...

@arackaf
Copy link

arackaf commented Feb 12, 2018

@chenyong - did you clear your node_modules and then re-install?

@marcoscaceres
Copy link

Just noting the affects parcel too, not just webpack.

@riyazpanarwala
Copy link

I also getting an error while creating bundle.js through webpack using this plugin.

@svalchinov
Copy link

@arackaf's solution worked for me only after removing node_modules and re-installing.

@arackaf
Copy link

arackaf commented Feb 13, 2018

Just to clarify, it won't work for anyone without clearing node_modules and re-installing.

@joe-re
Copy link

joe-re commented Feb 13, 2018

it seems like this is fixed only harmony branch.
ref: #2897

now if you use harmony branch, it'll be fixed.

npm install git://github.com/mishoo/UglifyJS2.git#harmony --save

@riyazpanarwala
Copy link

Please fix it in main branch so everyone can use it.

@marcoscaceres
Copy link

Any ETA on v3.3.11?

@johman10
Copy link

johman10 commented Feb 14, 2018

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.

@YounesM
Copy link

YounesM commented Feb 14, 2018

@johman10 That's because the npm version has been reverted to 3.3.9
image

benjamn pushed a commit to meteor/meteor that referenced this issue Mar 27, 2018
PR #9652 by @klaussner upgraded `uglify-es` from 3.2.2 to 3.3.10 to fix
issue #9647, but 3.3.9 is the latest version published to npm, and 3.3.10
seems to suffer from this bug: mishoo/UglifyJS#2896

For that reason, I think it might be best to downgrade `uglify-es` to
3.3.9, at least until 3.3.11 is published.

Since this bug causes `uglify-es` to throw during minification, the
`meteorJsMinify` function falls back to Babel's minifier, which is known
to use massive amounts of memory, and may be contributing to OOM problems
such as #9568. In other words, there's a chance that this downgrade will
help with #9568.
benjamn added a commit to meteor/meteor that referenced this issue Mar 28, 2018
* Downgrade uglify-es from 3.3.10 to 3.3.9 (latest published).

PR #9652 by @klaussner upgraded `uglify-es` from 3.2.2 to 3.3.10 to fix
issue #9647, but 3.3.9 is the latest version published to npm, and 3.3.10
seems to suffer from this bug: mishoo/UglifyJS#2896

For that reason, I think it might be best to downgrade `uglify-es` to
3.3.9, at least until 3.3.11 is published.

Since this bug causes `uglify-es` to throw during minification, the
`meteorJsMinify` function falls back to Babel's minifier, which is known
to use massive amounts of memory, and may be contributing to OOM problems
such as #9568. In other words, there's a chance that this downgrade will
help with #9568.

* Also bump standard-minifier-js package version.
gnarula added a commit to gnarula/cothority that referenced this issue Apr 9, 2018
v3.3.10 breaks support for destructured assignments,
ref: mishoo/UglifyJS#2896. Downgrading to 3.3.9 fixes the issue.
@Casedy
Copy link

Casedy commented Apr 27, 2018

@mishoo Is there any way to install the package through yarn?

@tehsenaus
Copy link

As a more permanent fix, you might want to try:
https://github.com/webpack-contrib/babel-minify-webpack-plugin

@pbadenski
Copy link

pbadenski commented May 10, 2018

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

@incraigulous
Copy link

@pbadenski's solution of using resolutions did not work for me. Installing with NPM instead of Yarn did however.

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

No branches or pull requests