Skip to content
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

Original prop name colliding with mangled prop name in earlier file is ignored #233

Closed
dennisss opened this issue Jan 8, 2019 · 1 comment · Fixed by #1063
Closed

Original prop name colliding with mangled prop name in earlier file is ignored #233

dennisss opened this issue Jan 8, 2019 · 1 comment · Fixed by #1063
Labels

Comments

@dennisss
Copy link

dennisss commented Jan 8, 2019

Bug report
The title of this issue is probably confusing along with the below description, so just look at the example code.

Mangling props for multiple files results in an inconsistent output when the mangled name chosen automatically for a property collides with an existing unmangled property name.

In the below example, the property i is specifically chosen as it is one of the first property names chosen by terser for a minified prop name.

Version (complete output of terser -V)
HEAD

Complete CLI command or minify() options used

terser input

  1. Existing file: ./first.js

    function fn1(obj) {
            obj.prop = 1;
            obj.i = 5;
    }
    
  2. Existing file: ./second.js

    function fn2(obj) {
            obj.prop = 1;
            obj.i = 5;
    }
    
  3. Empty file: ./cache.json

  4. Run ./bin/uglifyjs -c -m --mangle-props --name-cache cache.json -- first.js > first.min.js

  5. Run ./bin/uglifyjs -c -m --mangle-props --name-cache cache.json -- second.js > second.min.js

terser output or error

  1. Contents of ./first.min.js: function fn1(n){n.i=1,n.o=5}
  2. Contents of ./second.min.js: function fn2(n){n.i=1,n.i=5}

Expected result

  • Contents of second.min.js should be: function fn2(n){n.i=1,n.o=5}
    • The original .i should have become a .o
  • Even though unmangled 'prop' is mapped to mangled 'i', unmangled 'i' is still mapped to mangled 'o' in the first file
@fabiosantoscode
Copy link
Collaborator

Thanks for this report and sorry for the delay. I'll look into it! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants