Skip to content

Identifier missed when shortening names. #727

@jdsutton

Description

@jdsutton

Input Code

Description: Identifier names are compressed, but the final "query" at the end of the function is not, resulting in a fun bug in our production environment =)

static getAsObj() {
        let query = {};
        const qstr = window.location.search.substring(1);
        const a = (qstr[0] === '?' ? qstr.substr(1) : qstr).split('&');
        for (let i = 0; i < a.length; i++) {
            const b = a[i].split('=');
            query[decodeURIComponent(b[0])] = decodeURIComponent(b[1] || '');
        }
        return query;
    }

Actual Output

function getAsObj(){for(var e,t=window.location.search.substring(1),n=('?'===t[0]?t.substr(1):t).split('&'),a={},d=0;d<n.length;d++)e=n[d].split('='),a[decodeURIComponent(e[0])]=decodeURIComponent(e[1]||'');return query}

Expected Output

function getAsObj(){for(var e,t=window.location.search.substring(1),n=('?'===t[0]?t.substr(1):t).split('&'),a={},d=0;d<n.length;d++)e=n[d].split('='),a[decodeURIComponent(e[0])]=decodeURIComponent(e[1]||'');return a}

Details

Configuration:

# Remove comments babel plugin
REMOVE_COMMENTS=$(shell realpath ./node_modules/babel-plugin-remove-comments)
# Babel preset env
BABEL_PRESETS=$(shell realpath ./node_modules/babel-preset-env),$(shell realpath ./node_modules/babel-preset-minify)
# Babel executable
BABEL="./node_modules/.bin/babel [file] --out-file [file] --minified --presets $(BABEL_PRESETS) --plugins $(REMOVE_COMMENTS)"

Other presets: listed in config
Environment: Slurp (proprietary, does not affect babel)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions