[Pkg-javascript-devel] Bug#1004471: Pending patch for terser-webpack-plugin in webpack 5 till a new upstream for node-terser is uploaded
Caleb Adepitan
calebpitan at gmail.com
Fri Feb 4 07:46:29 GMT 2022
Hi,
I just arrived at a working patch for terser-webpack-plugin to circumvent breaking changes in node-terser 5 which is required by the package. The available version of node-terser in debian is 4 which is behind the terser package upstream.
This patch is an ad-hoc fix for the bug pending the node-terser package is updated to a compatible version.
Here is the proposed patch:
https://salsa.debian.org/calebpitan/node-webpack/-/commit/208febe14d117dc134543fd9773c8eca02d1d68c.patch
--- a/terser-webpack-plugin/src/utils.js
+++ b/terser-webpack-plugin/src/utils.js
@@ -264,8 +264,11 @@ async function terserMinify(
// 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} */
@@ -284,7 +287,11 @@ async function terserMinify(
}
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),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x8A1B2CC96775D2D7.asc
Type: application/pgp-keys
Size: 3139 bytes
Desc: OpenPGP public key
URL: <http://alioth-lists.debian.net/pipermail/pkg-javascript-devel/attachments/20220204/644688d8/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-javascript-devel/attachments/20220204/644688d8/attachment.sig>
More information about the Pkg-javascript-devel
mailing list