resourceloader: Implement modern module loading (2/2)
authorjdlrobson <jdlrobson@gmail.com>
Fri, 22 Jan 2016 19:29:28 +0000 (11:29 -0800)
committerJdlrobson <jrobson@wikimedia.org>
Wed, 13 Apr 2016 15:43:41 +0000 (15:43 +0000)
commitbc4e07b6f63b0865a14aef981366a79d10329c87
treebd0c90c0869df6af511a491423ff986b68c0393a
parent8cb8af442a84ad73bd0d07e661056ef7c7a5ab3f
resourceloader: Implement modern module loading (2/2)

* Send 'module' and 'require' parameters to module closures.
  This depends on Ia925844cc22f143 being deployed one cycle earlier.
* Patch Moment and OOjs to ensure these libraries continue to expose
  their module as globals as well. AMD/UMD-compatible libraries
  only expose a global *OR* an export, not both. We need both
  for back-compat.
* Update pluralRuleParser to make use of module export to allow
  usage via require().

To test, check out the patch and run:
> mw.loader.load('moment');
> mw.loader.require('moment')()
> mw.loader.require('moment')('2011-04-01').fromNow()

Bug: T108655
Change-Id: Idbd054880ee70d659ec760aef8fcb38d0704a394
13 files changed:
includes/resourceloader/ResourceLoader.php
resources/Resources.php
resources/src/mediawiki.libs/CLDRPluralRuleParser.js
resources/src/mediawiki/mediawiki.js
resources/src/moment-global.js [new file with mode: 0644]
resources/src/oojs-global.js [new file with mode: 0644]
tests/phpunit/includes/OutputPageTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderTest.php
tests/qunit/QUnitTestResources.php
tests/qunit/data/defineCallMwLoaderTestCallback.js [new file with mode: 0644]
tests/qunit/data/requireCallMwLoaderTestCallback.js [new file with mode: 0644]
tests/qunit/suites/resources/mediawiki/mediawiki.test.js
tests/qunit/suites/resources/test.sinonjs/index.js [new file with mode: 0644]