mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Update the regular expression in tweakWebpackOutput
to support minified-legacy builds (issue 18290)
This commit is contained in:
parent
9dbe4c246b
commit
df058edf22
1 changed files with 4 additions and 15 deletions
19
gulpfile.mjs
19
gulpfile.mjs
|
@ -450,21 +450,10 @@ function checkChromePreferencesFile(chromePrefsPath, webPrefs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function tweakWebpackOutput(jsName) {
|
function tweakWebpackOutput(jsName) {
|
||||||
const replacer = [
|
return replace(
|
||||||
" __webpack_exports__ = {};", // Normal builds.
|
/((?:\s|,)__webpack_exports__)(?:\s?)=(?:\s?)({};)/gm,
|
||||||
",__webpack_exports__={};", // Minified builds.
|
(match, p1, p2) => `${p1} = globalThis.${jsName} = ${p2}`
|
||||||
];
|
);
|
||||||
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;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createMainBundle(defines) {
|
function createMainBundle(defines) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue