From 23b60dc1975db38c280d8a123aff97544d1673e0 Mon Sep 17 00:00:00 2001
From: HelenHuang <LinHuang@pollex.com.tw>
Date: 星期四, 09 六月 2022 15:34:21 +0800
Subject: [PATCH] TODO#139890 FAQ 常見問題 1-文案調整

---
 PAMapp/node_modules/terser-webpack-plugin/node_modules/terser/lib/minify.js |   50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/PAMapp/node_modules/terser-webpack-plugin/node_modules/terser/lib/minify.js b/PAMapp/node_modules/terser-webpack-plugin/node_modules/terser/lib/minify.js
index 3b7efb3..82d9ca3 100644
--- a/PAMapp/node_modules/terser-webpack-plugin/node_modules/terser/lib/minify.js
+++ b/PAMapp/node_modules/terser-webpack-plugin/node_modules/terser/lib/minify.js
@@ -61,7 +61,54 @@
     };
 }
 
-async function minify(files, options) {
+function log_input(files, options, fs, debug_folder) {
+    if (!(fs && fs.writeFileSync && fs.mkdirSync)) {
+        return;
+    }
+
+    try {
+        fs.mkdirSync(debug_folder);
+    } catch (e) {
+        if (e.code !== "EEXIST") throw e;
+    }
+
+    const log_path = `${debug_folder}/terser-debug-${(Math.random() * 9999999) | 0}.log`;
+
+    options = options || {};
+
+    const options_str = JSON.stringify(options, (_key, thing) => {
+        if (typeof thing === "function") return "[Function " + thing.toString() + "]";
+        if (thing instanceof RegExp) return "[RegExp " + thing.toString() + "]";
+        return thing;
+    }, 4);
+
+    const files_str = (file) => {
+        if (typeof file === "object" && options.parse && options.parse.spidermonkey) {
+            return JSON.stringify(file, null, 2);
+        } else if (typeof file === "object") {
+            return Object.keys(file)
+                .map((key) => key + ": " + files_str(file[key]))
+                .join("\n\n");
+        } else if (typeof file === "string") {
+            return "```\n" + file + "\n```";
+        } else {
+            return file; // What do?
+        }
+    };
+
+    fs.writeFileSync(log_path, "Options: \n" + options_str + "\n\nInput files:\n\n" + files_str(files) + "\n");
+}
+
+async function minify(files, options, _fs_module) {
+    if (
+        _fs_module
+        && typeof process === "object"
+        && process.env
+        && typeof process.env.TERSER_DEBUG_DIR === "string"
+    ) {
+        log_input(files, options, _fs_module, process.env.TERSER_DEBUG_DIR);
+    }
+
     options = defaults(options, {
         compress: {},
         ecma: undefined,
@@ -84,6 +131,7 @@
         warnings: false,
         wrap: false,
     }, true);
+
     var timings = options.timings && {
         start: Date.now()
     };

--
Gitblit v1.8.0