From 59a9ec518f2dd2959189673ae640230f77a492c0 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 30 May 2018 18:44:29 +0100 Subject: [PATCH] resourceloader: Create mediawiki.base.js and move mw.inspect to it As a first step to splitting the 'mediawiki' module, start by splitting the file. The two files (like the other files in the same directory) are still concatenated and run at the same time. The only difference being that the private variables aren't available, and it forces us to think about not being able to call the methods during initialisation given the base file will execute after the main one, making its methods not yet available during the split time between the two. From the perspective of regular modules, this changes nothing as it will still load as one atomic unit defining the same public API as before. Bug: T192623 Change-Id: I552ae02e49c4d30070e166a504f454e334e8e75e --- resources/Resources.php | 1 + resources/src/mediawiki/mediawiki.base.js | 34 +++++++++++++++++++++++ resources/src/mediawiki/mediawiki.js | 11 -------- 3 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 resources/src/mediawiki/mediawiki.base.js diff --git a/resources/Resources.php b/resources/Resources.php index e624dc3c5e..b32bbcd78f 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -856,6 +856,7 @@ return [ 'resources/src/mediawiki/mediawiki.js', 'resources/src/mediawiki/mediawiki.requestIdleCallback.js', 'resources/src/mediawiki/mediawiki.errorLogger.js', + 'resources/src/mediawiki/mediawiki.base.js', ], 'debugScripts' => 'resources/src/mediawiki/mediawiki.log.js', 'targets' => [ 'desktop', 'mobile' ], diff --git a/resources/src/mediawiki/mediawiki.base.js b/resources/src/mediawiki/mediawiki.base.js new file mode 100644 index 0000000000..b68d779358 --- /dev/null +++ b/resources/src/mediawiki/mediawiki.base.js @@ -0,0 +1,34 @@ +/*! + * This file is currently loaded as part of the 'mediawiki' module and therefore + * concatenated to mediawiki.js and executed at the same time. This file exists + * to help prepare for splitting up the 'mediawiki' module. + * This effort is tracked at https://phabricator.wikimedia.org/T192623 + * + * In short: + * + * - mediawiki.js will be reduced to the minimum needed to define mw.loader and + * mw.config, and then moved to its own private "mediawiki.loader" module that + * can be embedded within the StartupModule response. + * + * - mediawiki.base.js and other files in this directory will remain part of the + * "mediawiki" module, and will remain a default/implicit dependency for all + * regular modules, just like jquery and wikibits already are. + */ +/* globals mw */ +( function () { + /** + * @class mw + * @singleton + */ + + /** + * @inheritdoc mw.inspect#runReports + * @method + */ + mw.inspect = function () { + var args = arguments; + mw.loader.using( 'mediawiki.inspect', function () { + mw.inspect.runReports.apply( mw.inspect, args ); + } ); + }; +}() ); diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index b00cbffcb0..a2af443ed7 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -2226,17 +2226,6 @@ return registry[ moduleName ].module.exports; }, - /** - * @inheritdoc mw.inspect#runReports - * @method - */ - inspect: function () { - var args = slice.call( arguments ); - mw.loader.using( 'mediawiki.inspect', function () { - mw.inspect.runReports.apply( mw.inspect, args ); - } ); - }, - /** * On browsers that implement the localStorage API, the module store serves as a * smart complement to the browser cache. Unlike the browser cache, the module store -- 2.20.1