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.
This commit is contained in:
Jonas Jenwald 2020-10-25 13:37:22 +01:00
parent 56fa6d414c
commit 126f42a266

View File

@ -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: [