aboutsummaryrefslogtreecommitdiff
path: root/tools/node.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-01-07 08:53:29 +0000
committerGitHub <noreply@github.com>2021-01-07 16:53:29 +0800
commit6c419bc083e097337960f1a19d2c352336d75e16 (patch)
tree87febc2499af74b116f8d4b0e5fb76a910f10291 /tools/node.js
parent25321df959eb7aac7bd144be428a0aea0d29a0b9 (diff)
downloadtracifyjs-6c419bc083e097337960f1a19d2c352336d75e16.tar.gz
tracifyjs-6c419bc083e097337960f1a19d2c352336d75e16.zip
implement `UGLIFY_BUG_REPORT` (#4516)
Diffstat (limited to 'tools/node.js')
-rw-r--r--tools/node.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/node.js b/tools/node.js
index 1ebc7730..f1fb28ba 100644
--- a/tools/node.js
+++ b/tools/node.js
@@ -23,6 +23,37 @@ new Function("exports", function() {
return code.join("\n\n");
}())(exports);
+function to_comment(value) {
+ if (typeof value != "string") value = JSON.stringify(value, function(key, value) {
+ return typeof value == "function" ? "<[ " + value + " ]>" : value;
+ }, 2);
+ return "// " + value.replace(/\n/g, "\n// ");
+}
+
+if (+process.env["UGLIFY_BUG_REPORT"]) exports.minify = function(files, options) {
+ if (typeof options == "undefined") options = "<<undefined>>";
+ var code = [
+ "// UGLIFY_BUG_REPORT",
+ to_comment(options),
+ ];
+ if (typeof files == "string") {
+ code.push("");
+ code.push("//-------------------------------------------------------------")
+ code.push("// INPUT CODE", files);
+ } else for (var name in files) {
+ code.push("");
+ code.push("//-------------------------------------------------------------")
+ code.push(to_comment(name), files[name]);
+ }
+ if (options.sourceMap && options.sourceMap.url) {
+ code.push("");
+ code.push("//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9");
+ }
+ var result = { code: code.join("\n") };
+ if (options.sourceMap) result.map = '{"version":3,"sources":[],"names":[],"mappings":""}';
+ return result;
+};
+
function describe_ast() {
var out = OutputStream({ beautify: true });
function doitem(ctor) {