From 126f42a266c492bbfa081771c5c260efa0556e40 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 25 Oct 2020 13:37:22 +0100 Subject: [PATCH] Only ignore the `src/core/{glyphlist, unicode}.js` files, during building of `pdf.worker.js`, when source-maps are enabled This produces a slightly smaller built `pdf.worker.js` file, for e.g. the `gulp mozcentral` build-target. --- gulpfile.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index d6e841470..a8344793c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -185,6 +185,19 @@ function createWebpackConfig(defines, output) { !bundleDefines.TESTING; var skipBabel = bundleDefines.SKIP_BABEL; + // `core-js` (see https://github.com/zloirock/core-js/issues/514), + // `web-streams-polyfill` (already using a transpiled file), and + // `src/core/{glyphlist,unicode}.js` (Babel is too slow for those when + // source-maps are enabled) should be excluded from processing. + const babelExcludes = [ + "node_modules[\\\\\\/]core-js", + "node_modules[\\\\\\/]web-streams-polyfill", + ]; + if (enableSourceMaps) { + babelExcludes.push("src[\\\\\\/]core[\\\\\\/](glyphlist|unicode)"); + } + const babelExcludeRegExp = new RegExp(`(${babelExcludes.join("|")})`); + // Required to expose e.g., the `window` object. output.globalObject = "this"; @@ -209,11 +222,7 @@ function createWebpackConfig(defines, output) { rules: [ { loader: "babel-loader", - // `core-js` (see https://github.com/zloirock/core-js/issues/514), - // `web-streams-polyfill` (already using a transpiled file), and - // `src/core/{glyphlist,unicode}.js` (Babel is too slow for those) - // should be excluded from processing. - exclude: /(node_modules[\\\/]core-js|node_modules[\\\/]web-streams-polyfill|src[\\\/]core[\\\/](glyphlist|unicode))/, + exclude: babelExcludeRegExp, options: { presets: skipBabel ? undefined : ["@babel/preset-env"], plugins: [