From 6052240e86e95e0c36b6759a428e649cac1604cd Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 27 Jan 2022 19:53:06 +0100 Subject: [PATCH] Properly remove lazy-loaded modules from the bundle --- wcfsetup/install/files/js/require.build.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/require.build.js b/wcfsetup/install/files/js/require.build.js index cbec15a255..6b2cd55384 100644 --- a/wcfsetup/install/files/js/require.build.js +++ b/wcfsetup/install/files/js/require.build.js @@ -1,4 +1,6 @@ (function () { + const excludedModules = []; + var config = { mainConfigFile: 'require.config.js', generateSourceMaps: true, @@ -69,6 +71,7 @@ if ((matches = contents.match(/@woltlabExcludeBundle\s+(tiny|all)/))) { switch (matches[1]) { case 'all': + excludedModules.push(module.replace(/\.js$/, '')); return false; case 'tiny': return moduleName !== 'WoltLabSuite.Core.tiny.min'; @@ -84,7 +87,14 @@ } return moduleContents; - } + }, + onBuildWrite(moduleName, path, contents) { + if (excludedModules.includes(moduleName)) { + return ""; + } + + return contents; + }, }; var _isSupportedBuildUrl = require._isSupportedBuildUrl; -- 2.20.1