UglifyJS icon indicating copy to clipboard operation
UglifyJS copied to clipboard

prefix for mangle property names

Open dabretin opened this issue 8 years ago • 14 comments

It could be very useful to set profix of mangle names. It could permit to restrict access (at runtime) to "private" properties/methods on proxified objects.

Sorry for the double post... I have previously done an error (no default value for prefix in mangle_properties)

dabretin avatar Feb 08 '17 15:02 dabretin

Previous post #1472

dabretin avatar Feb 08 '17 15:02 dabretin

~~Could you please close #1472 if this PR replaces it?~~

To consider this PR we would need bin/uglifyjs and minify() tests in test/mocha/, as well as tests in test/compress/.

kzc avatar Feb 08 '17 15:02 kzc

Could you please remove the [Harmony] prefix in the title if you intend this to be merged to the branch master?

kzc avatar Feb 08 '17 15:02 kzc

Also would need documentation in README.md

kzc avatar Feb 08 '17 16:02 kzc

Could you please change the bin/uglifyjs flag name to mangle-props-prefix?

kzc avatar Feb 08 '17 16:02 kzc

@dabretin I apologize for not raising this issue earlier - I'm afraid I don't understand the use case of this PR:

https://github.com/mishoo/UglifyJS2/pull/1472#issuecomment-278281444

Why would anyone want to add a prefix to the mangled property name? That just wastes space in the minified output.

kzc avatar Feb 08 '17 16:02 kzc

It can enable to restrict access at runtime to properties. After mangle, it's not possible to detect the "private" orientation of a property. The only possibility seems to be a prefix of the obfuscated properties...

dabretin avatar Feb 08 '17 16:02 dabretin

Need a command line test in test/mocha/ to test the new bin/uglifyjs flag. See test/mocha/cli.js for an example.

kzc avatar Feb 08 '17 17:02 kzc

This PR will not be approved without a command line test for bin/uglifyjs.

example: https://github.com/mishoo/UglifyJS2/blob/1eaa211e0932105439d98d4f03a981f157f0a77c/test/mocha/cli.js#L93-L102

kzc avatar Feb 08 '17 20:02 kzc

This PR appears to be low risk and now has sufficient tests and documentation.

Please squash into a single commit and assign an appropriate commit comment.

Thanks.

kzc avatar Feb 09 '17 02:02 kzc

I'm not confortable with git so sorry in advance for my (probably stupid) questions... Is the last comment for me ? If it is...how can I do that ?

dabretin avatar Feb 09 '17 08:02 dabretin

@dabretin hope these help: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html https://help.github.com/articles/about-git-rebase/

alexlamsl avatar Feb 09 '17 08:02 alexlamsl

I think it's done :)

dabretin avatar Feb 09 '17 13:02 dabretin

If this PR gets in I think it could very well be the last new mangle option. They are getting harder to support and test with each new addition and combination.

kzc avatar Feb 09 '17 20:02 kzc