You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not a bug, just a suggestion for a (hopefully) straightforward but potentially useful feature. This is a kind of a follow-on from #5937.
Uglify version (uglifyjs -V) 3.19.3
Proposal
Property mangling is not safe to run on all JavaScript code: things like dynamic string property accesses can cause code to be broken after property mangling. Sometimes code has to be specially written to ensure it is not broken by property mangling. Other optimizations like renaming local variables are always safe since they cannot be dynamically referenced by string.
As noted in #5937 the restrictions of private properties - notably that they cannot be accessed dynamically by string, and cannot have name collisions even with base classes - means that just like with local variables, it is actually always safe to mangle them. It is not possible for mangling private property names to break code, at least with the current features of JavaScript.
If you have a large amount of third-party JavaScript code to minify and you don't know if it supports property mangling, it should still always be safe to mangle only private properties. Therefore it would be useful to have a setting that allows UglifyJS to mangle only private properties without mangling any other kinds of properties.
JavaScript demonstration code
Properties not mangled at all (always safe)
classTest{foo;
#bar;}
Property mangling enabled (may break some JavaScript code)
classTest{a;
#a;}
Only private property mangling enabled - new proposed mode which is also always safe
classTest{foo;
#a;}
The text was updated successfully, but these errors were encountered:
This is not a bug, just a suggestion for a (hopefully) straightforward but potentially useful feature. This is a kind of a follow-on from #5937.
Uglify version (
uglifyjs -V
) 3.19.3Proposal
Property mangling is not safe to run on all JavaScript code: things like dynamic string property accesses can cause code to be broken after property mangling. Sometimes code has to be specially written to ensure it is not broken by property mangling. Other optimizations like renaming local variables are always safe since they cannot be dynamically referenced by string.
As noted in #5937 the restrictions of private properties - notably that they cannot be accessed dynamically by string, and cannot have name collisions even with base classes - means that just like with local variables, it is actually always safe to mangle them. It is not possible for mangling private property names to break code, at least with the current features of JavaScript.
If you have a large amount of third-party JavaScript code to minify and you don't know if it supports property mangling, it should still always be safe to mangle only private properties. Therefore it would be useful to have a setting that allows UglifyJS to mangle only private properties without mangling any other kinds of properties.
JavaScript demonstration code
Properties not mangled at all (always safe)
Property mangling enabled (may break some JavaScript code)
Only private property mangling enabled - new proposed mode which is also always safe
The text was updated successfully, but these errors were encountered: