-
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
Unwind IIFE class patterns #2332
Comments
You may implement this by enhancing |
It's more complicated than it first appears. Hoisting the function may require renaming it or it may conflict with a symbol in the outer scope. Presently In the current code base function inlining only works on single statement functions (this includes an All of this could be done of course, it's just not easy to get all the corner cases right. |
I guess it depends how detection of the "class pattern" can be done. Or is it possible to safely do such optimization on things other than "class pattern". Talking purely about this specific scenario of "class pattern" we do not have to introduce any new identifier to the outer scope. The IIFE could be unwinded to: var n = function (){};n.prototype.method=function(){},instance=new n which doesnt introduce any new identifiers than whats outputted today.
could u elaborate?
Agreed, I would love to help with implementing this, but Im afraid I'm just not able to dive to yet another codebase right now 😢 . Possible gains from having this feature implemented are probably quite big in es6 classes / TS world (most of the newer projects), so I hope somebody could try to work on this some day. EDIT:// Im not sure what phases of the compiler are there, but this should ofc should be performed after dropping |
If a multiline function is inlined/hoisted from within a single statement An alternative approach - scan each function to see whether it produces any external side effects beyond the function and mark it internally as equivalent to |
feature request
ES5
Uglify version (
uglifyjs -V
)latest (testes on
uglify-es
too)JavaScript input
The
uglifyjs
CLI command executed orminify()
options used.JavaScript output
Requested JavaScript output
Something along this:
The text was updated successfully, but these errors were encountered: