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

Some yield in generator doesn't be mangled #120

Open
IsvaraWoo opened this issue May 5, 2016 · 0 comments
Open

Some yield in generator doesn't be mangled #120

IsvaraWoo opened this issue May 5, 2016 · 0 comments

Comments

@IsvaraWoo
Copy link

IsvaraWoo commented May 5, 2016

I use esmangle in NodeJS to compress following js:

function f(){
    return function *(next){
        var prev = next;
        prev = f.call(this, prev);
        yield *prev;
    };
}

I get the result as:

function f(){return function*(b){var a=b;a=f.call(this,a),yield*prev}}

The (last one) prev in source doesn't be mangled.

Compressor code in NodeJS:

var esprima = require('esprima');
var esmangle = require('esmangle');
var escodegen = require('escodegen');
var ast = esprima.parse(code);
// Get optimized AST
var optimized = esmangle.optimize(ast, null);
// gets mangled AST
var result = esmangle.mangle(optimized);
console.log(escodegen.generate(result, {
    format: {
        renumber: true,
        hexadecimal: true,
        escapeless: true,
        compact: true,
        semicolons: false,
        parentheses: false
    }
}));  // dump AST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant