Hey,
I'm on Mediawiki 1.27.
I've been developing a fairly robust Special Pages extension using a solid amount of
Javascript, nearly over 1000 lines currently.
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
require inside their extension since very few even use Javascript loaded through
$out->addModules. The current state of my extension works fine but it's contained
in a single Javascript file that would be extremely difficult for people to read besides
myself.
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 libraries/javascript files should be included when
`mw.loader.implement` is called for a 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.
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.
Thanks,
Garrett
Show replies by date