-
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
Property mangling does not always mangle global properties #5953
Comments
So this would work as you expected if we use $ cat test.js
self.MyGlobal = 1;
console.log(self.MyGlobal);
console.log(self.MyGlobal2); $ uglify-js test.js -b --mangle-props
self.l = 1;
console.log(self.l);
console.log(self.MyGlobal2); $ uglify-js test.js -b --mangle-props globals
self.l = 1;
console.log(self.l);
console.log(self.o); I realise I have yet to make a new release which includes that feature, will do in the next few days. As for your concern on consistency, $ cat one.js
self.MyGlobal = 1;
$ cat two.js
console.log(self.MyGlobal); $ uglify-js one.js --name-cache names.json --mangle-props
self.l = 1;
$ uglify-js two.js --name-cache names.json --mangle-props
console.log(self.l); |
Thanks, let me know when the next version is out and I'll check again with the new |
@alexlamsl - any chance of a new version update soon? The last version came out in August and we're interested in trying the latest changes. |
@alexlamsl - any chance of releasing a new version? We're still interested in trying this. |
I tested with the latest commit and the new // input
const myGlobal = globalThis.myGlobal;
myGlobal.callSomeFunction(); // output
{const t=globalThis.l6;t.callSomeFunction()} Observed result: the name of It looks like it's a shallow-only mode - it doesn't seem to propagate changes to further properties, which is what we need. Otherwise once again properties are minified at the original definition but not in other scripts, which breaks code. @alexlamsl - we are willing to pay for further work and maintenance on UglifyJS - please get in touch with me at [email protected] if you are interested. |
Uglify version (
uglifyjs -V
) 3.19.3JavaScript input
The
uglifyjs
CLI command executed orminify()
options used.uglifyjs input.js --mangle-props --beautify --output output.js
JavaScript output or error produced.
Expected result: both self.MyGlobal and self.MyGlobal2 to be treated consistently, both being renamed to a shorter property.
Observed result: only self.MyGlobal is mangled. For some reason self.MyGlobal2 is not mangled. Perhaps this is because the parser has not seen an assignment to the global property yet.
Impact: This breaks property mangling when using multiple files or a shared nameCache: it's possible MyGlobal2 was assigned to in a different script. For example if input1.js does
self.MyGlobal2 = 2
, then input2.js doesconsole.log(self.MyGlobal2)
, the properties are not consistently mangled and the output is broken. Therefore to ensure property mangling works in these cases, UglifyJS must consistently mangle all global properties regardless of whether they are assigned to or only read from.The text was updated successfully, but these errors were encountered: