Skip to content

Commit

Permalink
removes strict mode during minify
Browse files Browse the repository at this point in the history
  • Loading branch information
Illyism committed Jun 1, 2021
1 parent 706c27b commit 226106d
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1072,25 +1072,35 @@ async function parseMinified(dir) {
keep_fnames: true,
};

/**
* Minifies the code and removed strict mode.
* We are removing strict mode to bypass unsafe-eval restrictions in regenerator-runtime.
* @param {string} file
*/
const minifyAndRemoveStrict = async (file) => {
const result = (await Terser.minify(file, options)).code
return result.replace(/"use strict";/gm, '');
}

fs.writeFileSync(
dir + "/web/pdf.viewer.js",
(await Terser.minify(viewerFiles, options)).code
await minifyAndRemoveStrict(viewerFiles)
);
fs.writeFileSync(
dir + "/build/pdf.min.js",
(await Terser.minify(pdfFile, options)).code
await minifyAndRemoveStrict(pdfFile)
);
fs.writeFileSync(
dir + "/build/pdf.worker.min.js",
(await Terser.minify(pdfWorkerFile, options)).code
await minifyAndRemoveStrict(pdfWorkerFile)
);
fs.writeFileSync(
dir + "/build/pdf.sandbox.min.js",
(await Terser.minify(pdfSandboxFile, options)).code
await minifyAndRemoveStrict(pdfSandboxFile)
);
fs.writeFileSync(
dir + "image_decoders/pdf.image_decoders.min.js",
(await Terser.minify(pdfImageDecodersFile, options)).code
await minifyAndRemoveStrict(pdfImageDecodersFile)
);

console.log();
Expand Down

0 comments on commit 226106d

Please sign in to comment.