On 05/05/2017 01:22 PM, George, Garrett J. (JSC-CB111)[SGT, INC] wrote:
I'm on Mediawiki 1.27.
I've been developing a fairly robust Special Pages extension using a solid amount of
I would prefer to improve my code's readability and organization by using the modular
design seen in modern projects through CommonJS or RequireJS. It may be a problem with how
I'm using `require` but I'm stuck trying to even find examples of people using
$out->addModules. The current state of my extension works fine but it's contained
You can specify multiple files for the "scripts" and "styles" options
which are then loaded in order. Extension:VisualEditor's extension.json
has quite a few examples.
The problem is that the dependency key in
ResourceModules inside of extension.json only works for modules that have already been
loaded. In `ResourceModules` the dependency tag is less about code order of execution when
ResourceLoader calls `mw.loader.implement` and more about which globally accessible
module. ResourceLoader doesn't do any sort of callback. So if my module X has module Y
as a dependency it won't recognize Y isn't loaded, find Y, load Y, then return to
loading X. It just stops when it finds Y isn't loaded and throws a fatal error about
module Y not being loaded.
If X has specified a dependency upon Y in extension.json, it should load
Y before X. Are you experiencing something different? Or did you mean
Also a sidenote, from very initial testing calling
`$out->addModules()` loads them into ResourceLoader in alphabetical order. Which is
weird and doesn't make sense to me. I had dependency problems and I simply changed one
module from starting with a Q to starting with an A and it was sent to mw.loader.implement
before another module starting after A.
This is expected I think, as it assumes that you'll set your modules'
dependencies in extension.json (or mw.loader.using).