UglifyJS is a JavaScript parser, minifier, compressor and beautifier toolkit.
A transform to make UglifyJS work in CommonJS.
npm i uglify-js-export
import UglifyJS from 'uglify-js-export';
const code = "function add(first, second) { return first + second; }";
const result = UglifyJS.minify(code);
console.log(result.error); // runtime error, or `undefined` if no error
console.log(result.code); // minified output: function add(n,d){return n+d}
Licensed under the MIT License.