-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Bug with hoist_funs? #1903
Comments
Note |
The problem stems from the fact that I'd suggest using As you discovered changing it to |
Duplicate of harmony bug #1358 @alexlamsl What should we do with this fake ES5 |
I am rather "uninformed" with the different types of javascript. Didn't realize const was not part of ES5. I was thinking perhaps if the compiler detects a reference to a const variable within a function, simply leave the function where it is, instead of moving it. Why does uglifyjs even move functions? |
It provides better gzip compression when |
My main goal here is to just minify any javascript file safely regardless of ES5, ES6, etc Would this be sufficient options in your opinon?
|
@kzc now that I read up on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const I'm thoroughly surprised support for I think I'll need to get an idea on how often that feature is actually used in the field, which I expect is not frequent enough if IE10- aren't cool with it. But the nuclear option is certainly on the table for this feature on |
@zylongaming1 ES6 language features would trip up even the parser for |
so uglify-es is able to parse es5, and es6 with no issues? |
|
@alexlamsl I don't have a strong opinion on this matter. Obviously Maybe such use of |
@kzc change of scope with I am more than happy to remove What I'm wondering is whether there are significant amount of code out there which claims to be ES5 but uses |
I think that's the best option. There will still be fireworks but it will be easier to explain with the |
2.8.24 is released on Github. When will it be published on npm? I think this is the bug that broke all my recent production builds . |
@jampy not sure exactly what you mean, but if you are looking for https://github.com/mishoo/UglifyJS2/blob/v2.x/README.md#note As for the actual release itself - it was going through CI before I head out. When I get back in a few hours' time I will press the button 😉 |
Fixed in |
Bug report or feature request?
Bug
ES5 or ES6+ input?
ES5
Uglify version (
uglifyjs -V
)uglify-js@2.8.23
JavaScript input
The
uglifyjs
CLI command executed orminify()
options used.UglifyJS.minify("path-to-file.js");
JavaScript output or error produced.
which the output jsbeautifys to:
It appears adding the following option
"hoist_funs": false
resolves the issue, as the function is able to read the const variable properlyI'm not entirely sure if this is intended, but if it is then hoist_funs should be disabled by default at the very least.
The text was updated successfully, but these errors were encountered: