Created
July 31, 2017 18:01
-
-
Save CapacitorSet/40ac6e1c2bebd64d5508029c8fdd9b4c to your computer and use it in GitHub Desktop.
Revisions
-
CapacitorSet created this gist
Jul 31, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ // A standalone script that replicates the preprocessing stage in box-js. const unsafe = true; const code = require("fs").readFileSync(process.argv[2], "utf8"); const result = require("uglify-es").minify(code, { compress: { passes: 3, booleans: true, cascade: true, collapse_vars: true, comparisons: true, conditionals: true, dead_code: true, drop_console: false, evaluate: true, if_return: true, inline: true, join_vars: false, // readability keep_fargs: unsafe, // code may rely on Function.length keep_fnames: unsafe, // code may rely on Function.prototype.name keep_infinity: true, // readability loops: true, negate_iife: false, // readability properties: true, pure_getters: false, // many variables are proxies, which don't have pure getters /* If unsafe preprocessing is enabled, tell uglify-es that Math.* functions * have no side effects, and therefore can be removed if the result is * unused. Related issue: mishoo/UglifyJS2#2227 */ pure_funcs: unsafe ? // https://stackoverflow.com/a/10756976 Object.getOwnPropertyNames(Math).map(key => `Math.${key}`) : null, reduce_vars: true, /* Using sequences (a; b; c; -> a, b, c) provides some performance benefits * (https://github.com/CapacitorSet/box-js/commit/5031ba7114b60f1046e53b542c0e4810aad68a76#commitcomment-23243778), * but it makes code harder to read. Therefore, this behaviour is disabled. */ sequences: false, toplevel: true, typeofs: false, // typeof foo == "undefined" -> foo === void 0: the former is more readable unsafe, unused: true, }, output: { beautify: true, comments: true, }, }); console.log(result.code);