simone-sanfratello / json-stringify-extended

JSON.stringify any data types
17 stars 1 forks source link

es6 support for function compress #3

Closed haifeng239 closed 6 years ago

haifeng239 commented 6 years ago

dig some digging. looks like uglifyjs released uglify-es

Here's an example of code that breaks with uglify-js but works with uglify-es

var uglify = require('uglify-es');

fn = function () {
  var world = 'world';
  return `hello ${world}`;
}

input = "var ___ = " + fn.toString();
output = uglify.minify(input)
if(output.error) {
  console.log(output.error);
}
else {
  output = output.code
  output = output.replace('var ___=', '');
  output = output.replace(/;$/, '');
}
console.log(input);
console.log(output);
haifeng239 commented 6 years ago

downgraded my coffee script to 1.x so it doesn't compile with ES6. This is less of a concern for me now.

haifeng239 commented 6 years ago

looks like you already did this. closing issue