Skip to content

Commit

Permalink
Update the regular expression in tweakWebpackOutput to support mini…
Browse files Browse the repository at this point in the history
…fied-legacy builds (issue 18290)
  • Loading branch information
Snuffleupagus committed Jun 19, 2024
1 parent 9dbe4c2 commit df058ed
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 df058ed

Please sign in to comment.