File: terser-webpack-plugin.patch

package info (click to toggle)
node-webpack 5.97.1%2Bdfsg1%2B~cs11.18.27-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 59,064 kB
  • sloc: javascript: 185,073; makefile: 16; sh: 6
file content (31 lines) | stat: -rw-r--r-- 1,085 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Description: Circumvent breaking change in node-terser which is required by node-terser-webpack plugin as reported in this bug (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1004471) as a hack fix pending a new upstream be uploaded for node-terser
Author: Caleb Adepitan <calebpitan@gmail.com>
--- a/terser-webpack-plugin/src/utils.js
+++ b/terser-webpack-plugin/src/utils.js
@@ -264,8 +264,11 @@
 
   // Let terser generate a SourceMap
   if (sourceMap) {
-    // @ts-ignore
-    terserOptions.sourceMap = { asObject: true };
+    const pkg = require("terser/package.json")
+    if (parseInt(pkg.version) > 4) {
+      // @ts-ignore
+      terserOptions.sourceMap = { asObject: true };
+    }
   }
 
   /** @type {ExtractedComments} */
@@ -299,7 +302,11 @@
   }
 
   const [[filename, code]] = Object.entries(input);
-  const result = await minify({ [filename]: code }, terserOptions);
+  let result = minify({ [filename]: code }, terserOptions);
+
+  if (result instanceof Promise) {
+    result = await result
+  }
 
   return {
     code: /** @type {string} **/ (result.code),