From df058edf2283c5c0fa255a5db5cb45b089a8c3d6 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 19 Jun 2024 12:21:10 +0200 Subject: [PATCH] Update the regular expression in `tweakWebpackOutput` to support minified-legacy builds (issue 18290) --- gulpfile.mjs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/gulpfile.mjs b/gulpfile.mjs index 73cbf6a2c0211..ee966b2ed45b7 100644 --- a/gulpfile.mjs +++ b/gulpfile.mjs @@ -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) {