1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #18292 from Snuffleupagus/tweakWebpackOutput-improve-regex

Update the regular expression in `tweakWebpackOutput` to support minified-legacy builds (issue 18290)
This commit is contained in:
Tim van der Meij 2024-06-19 14:26:20 +02:00 committed by GitHub
commit b7d194f3c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -450,21 +450,10 @@ function checkChromePreferencesFile(chromePrefsPath, webPrefs) {
}
function tweakWebpackOutput(jsName) {
const replacer = [
" __webpack_exports__ = {};", // Normal builds.
",__webpack_exports__={};", // Minified builds.
];
const regex = new RegExp(`(${replacer.join("|")})`, "gm");
return replace(regex, match => {
switch (match) {
case " __webpack_exports__ = {};":
return ` __webpack_exports__ = globalThis.${jsName} = {};`;
case ",__webpack_exports__={};":
return `,__webpack_exports__=globalThis.${jsName}={};`;
}
return match;
});
return replace(
/((?:\s|,)__webpack_exports__)(?:\s?)=(?:\s?)({};)/gm,
(match, p1, p2) => `${p1} = globalThis.${jsName} = ${p2}`
);
}
function createMainBundle(defines) {