Skip to content

Commit

Permalink
Keep the original class/function names when minifying code (issue 12209)
Browse files Browse the repository at this point in the history
While this will obviously increase the size of the output of `gulp minified`/`gulp minified-es5` *slightly*, the resulting files are still a lot smaller than the non-minified builds.

See https://github.com/terser/terser#minify-options for information about various Terser options.
  • Loading branch information
Snuffleupagus committed Aug 13, 2020
1 parent e50cb4c commit ea5581b
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit ea5581b

Please sign in to comment.