Skip to content

Commit

Permalink
Merge pull request #18292 from Snuffleupagus/tweakWebpackOutput-impro…
Browse files Browse the repository at this point in the history
…ve-regex

Update the regular expression in `tweakWebpackOutput` to support minified-legacy builds (issue 18290)
  • Loading branch information
timvandermeij committed Jun 19, 2024
2 parents 764e67e + df058ed commit b7d194f
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b7d194f

Please sign in to comment.