babel / minify

:scissors: An ES6+ aware minifier based on the Babel toolchain (beta)
https://babeljs.io/repl
MIT License
4.4k stars 225 forks source link

Minification breaks code #902

Closed jdsutton closed 6 years ago

jdsutton commented 6 years ago
  1. Configuration - babel-minify configuration or babelrc
  2. Whether you used it with other presets/plugins - like es2015 or env
    {
    "presets": ["env", "minify"],
    "comments": false
    }
  3. Environment: gulp, rollup, webpack, babel-cli, etc...? babel-cli, canary version of minify, or 0.4.3

Input Code

function bar() {
  return 10;
}

function foo () {

        var x = bar();

        while (false) { // Or complex boolean expression.

        }

        return {'a': x};
    }

Actual Output

'use strict';function bar(){return 10}function foo(){return{a:a}}

Expected Output

'use strict';function bar(){return 10}function foo(){a=bar();return{a:a}}

Details

Anybody know of a working minifier I can use...?

boopathi commented 6 years ago

The latest master returns this -

function bar() {
  return 10;
}

function foo() {
  var a = bar();
  return {
    a: a
  };
}

I also published 0.5.0 from master. Please comment to reopen if the issue persists.