From: Alexander Ebert Date: Fri, 26 Jun 2015 12:58:26 +0000 (+0200) Subject: Fixed build config and moved inline script into require.linearExecution.js X-Git-Tag: 3.0.0_Beta_1~2241^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0795d1801cb9a7dbdd929d52e50046a7a7e0efdd;p=GitHub%2FWoltLab%2FWCF.git Fixed build config and moved inline script into require.linearExecution.js --- diff --git a/wcfsetup/install/files/js/require.build.js b/wcfsetup/install/files/js/require.build.js index 54f1619695..12255c132a 100644 --- a/wcfsetup/install/files/js/require.build.js +++ b/wcfsetup/install/files/js/require.build.js @@ -13,7 +13,8 @@ }, include: [ "requireLib", - "require.config" + "require.config", + "require.linearExecution" ], excludeShallow: [ 'WoltLab/_Meta' @@ -49,7 +50,7 @@ } } - return 'define([' + global.allModules.map(function (item) { return "'" + item.replace(/\\/g, '\\\\').replace(/'/g, "\\'") + "'"; }).join(', ') + '], function() { });'; + return 'define([' + global.allModules.map(function (item) { return "'" + item.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\.js$/, '') + "'"; }).join(', ') + '], function() { });'; } return contents; diff --git a/wcfsetup/install/files/js/require.linearExecution.js b/wcfsetup/install/files/js/require.linearExecution.js new file mode 100644 index 0000000000..375e8353ea --- /dev/null +++ b/wcfsetup/install/files/js/require.linearExecution.js @@ -0,0 +1,32 @@ +(function(window) { + var orgRequire = window.require; + var queue = []; + var counter = 0; + + window.require = function(dependencies, callback) { + if (!Array.isArray(dependencies)) { + return orgRequire.apply(window, arguments); + } + + var i = counter++; + queue.push(i); + + orgRequire(dependencies, function() { + var args = arguments; + + queue[queue.indexOf(i)] = function() { callback.apply(window, args); }; + + executeCallbacks(); + }); + }; + + function executeCallbacks() { + while (queue.length) { + if (typeof queue[0] !== 'function') { + break; + } + + queue.shift()(); + } + }; +})(window);