diff --git a/gulpfile.js b/gulpfile.js index e6739ccd9258e..a953db9fedd6e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -909,18 +909,30 @@ function parseMinified(dir) { console.log("### Minifying js files"); var Terser = require("terser"); - // V8 chokes on very long sequences. Works around that. - var optsForHugeFile = { compress: { sequences: false } }; + var options = { + compress: { + // V8 chokes on very long sequences, work around that. + sequences: false, + }, + keep_classnames: true, + keep_fnames: true, + }; - fs.writeFileSync(dir + "/web/pdf.viewer.js", Terser.minify(viewerFiles).code); - fs.writeFileSync(dir + "/build/pdf.min.js", Terser.minify(pdfFile).code); + fs.writeFileSync( + dir + "/web/pdf.viewer.js", + Terser.minify(viewerFiles, options).code + ); + fs.writeFileSync( + dir + "/build/pdf.min.js", + Terser.minify(pdfFile, options).code + ); fs.writeFileSync( dir + "/build/pdf.worker.min.js", - Terser.minify(pdfWorkerFile, optsForHugeFile).code + Terser.minify(pdfWorkerFile, options).code ); fs.writeFileSync( dir + "image_decoders/pdf.image_decoders.min.js", - Terser.minify(pdfImageDecodersFile).code + Terser.minify(pdfImageDecodersFile, options).code ); console.log(); diff --git a/src/display/api.js b/src/display/api.js index c94bf977fe307..ff17ffec8afb4 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -2271,11 +2271,16 @@ class WorkerTransport { reason = new UnknownErrorException(ex.message, ex.details); break; } - if ( - typeof PDFJSDev === "undefined" || - PDFJSDev.test("!PRODUCTION || TESTING") - ) { - assert(reason instanceof Error, "DocException: expected an Error."); + if (!(reason instanceof Error)) { + const msg = "DocException - expected a valid Error."; + if ( + typeof PDFJSDev === "undefined" || + PDFJSDev.test("!PRODUCTION || TESTING") + ) { + unreachable(msg); + } else { + warn(msg); + } } loadingTask._capability.reject(reason); });