prefix for mangle property names#1475
Conversation
|
Previous post #1472 |
|
To consider this PR we would need |
|
Could you please remove the [Harmony] prefix in the title if you intend this to be merged to the branch master? |
| it("Should add prefix \"__\" for mangle properties (not quoted)", function() | ||
| { | ||
| var js = 'a["foo"] = "bar"; a.color = "red"; x = {"bar": 10};'; | ||
| var result = Uglify.minify(js, { |
There was a problem hiding this comment.
There's a formatting issue. Please use spaces instead of tabs.
|
Also would need documentation in README.md |
|
Could you please change the |
| } | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Please only have a single empty line between tests.
| 'a["foo"]="bar",a.a="red",x={"bar":10};'); | ||
| }); | ||
|
|
||
| it("Should add prefix \"__\" for mangle properties (not quoted)", function() { |
There was a problem hiding this comment.
Please remove \"__\" from description.
| 'a["foo"]="bar",a.__a="red",x={"bar":10};'); | ||
| }); | ||
|
|
||
| it("Should add prefix \"__\" for mangle properties (with quoted)", function() { |
There was a problem hiding this comment.
Please remove \"__\" from description.
| .describe("reserve-domprops", "Make (most?) DOM properties reserved for --mangle-props") | ||
| .describe("mangle-props", "Mangle property names (0 - disabled, 1 - mangle all properties, 2 - mangle unquoted properies)") | ||
| .describe("mangle-regex", "Only mangle property names matching the regex") | ||
| .describe("mangle-prefix", "Prefix of the mangle properties") |
There was a problem hiding this comment.
Please rename this flag to mangle-props-prefix in bin/uglifyjs. The property name in lib/propmangle.js is fine.
| } | ||
| }); | ||
| assert.strictEqual(result.code, | ||
| 'a["foo"]="bar",a.__a="red",x={"bar":10};'); |
There was a problem hiding this comment.
please collapse lines 78 and 79 into one line
| } | ||
| }); | ||
| assert.strictEqual(result.code, | ||
| 'a["__a"]="bar",a.__b="red",x={"__c":10};'); |
|
@dabretin I apologize for not raising this issue earlier - I'm afraid I don't understand the use case of this PR: Why would anyone want to add a prefix to the mangled property name? That just wastes space in the minified output. |
|
It can enable to restrict access at runtime to properties. |
| notation. You can override these by setting | ||
| them explicitly on the command line. | ||
| --mangle-regex Only mangle property names matching the regex | ||
| --mangle-props-prefix Prefix of the mangle properties |
There was a problem hiding this comment.
more apt description: "Prefix added to the property name after mangling."
|
Need a command line test in |
| .describe("reserve-domprops", "Make (most?) DOM properties reserved for --mangle-props") | ||
| .describe("mangle-props", "Mangle property names (0 - disabled, 1 - mangle all properties, 2 - mangle unquoted properies)") | ||
| .describe("mangle-regex", "Only mangle property names matching the regex") | ||
| .describe("mangle-props-prefix", "Prefix of the mangle properties") |
There was a problem hiding this comment.
Please make this description match the README.
|
This PR will not be approved without a command line test for |
| @@ -0,0 +1,28 @@ | |||
| var Test = function() | |||
| { | |||
| this.someVar = 123; | |||
There was a problem hiding this comment.
Please use kick brace style throughout this file:
var Test = function() {
| this.someVar = 123; | ||
| }; | ||
|
|
||
|
|
There was a problem hiding this comment.
Just use a single empty line between functions.
| this.someVar = 123; | ||
| }; | ||
|
|
||
|
|
There was a problem hiding this comment.
Please use a single empty line between functions throughout the file.
|
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. |
|
I'm not confortable with git so sorry in advance for my (probably stupid) questions... |
|
I think it's done :) |
|
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. |
7d1c0a7 to
b468103
Compare
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
prefixinmangle_properties)