On 23 Mar 2015, at 13:56, Brad Jorsch (Anomie) <bjorsch@wikimedia.org> wrote:

On Mon, Mar 23, 2015 at 3:08 AM, Krinkle <krinklemail@gmail.com> wrote:
Nothing is loaded by default.

If you make use of interfaces provided by a module, you must add a dependency on that module.

I must have misunderstood something. If all dependencies have to be declared then why does ResourcesTest::testIllegalDependencies() explicitly complain about 'jquery' and 'mediawiki'?


jquery and mediawiki are not modules. They are raw files leveraging parts of ResourceLoader to deliver itself. Obviously it can't load itself, so it wouldn't make sense as a dependency. It's part of the base environment. If you're registering a module and managed to get it loaded, by definition it must already be there.

Similar to how websites using RequireJS wouldn't have one add a dependency on "requirejs" on every module that calls require() somewhere. Granted, our base module provides a fair bit more than just mw.loader but the paradigm does apply.

We could refer to them as the "base" environment. But not "default" or "modules", that would understandably be confusing.

-- Krinkle

PS: In theory one could make them no-ops removed at run time server-side, but would just be wasted efforts for developer and server. I won't make the same mistake most C-family language designers made when allowing the curly brace to be placed either at the end or on the next line. We could've done it the way of needing to depend on jquery, but we didn't. Better one way consistent, than two ways (which isn't a way). A minor confusion here and there is I think worth it, compared to the wasted efforts, bikeshedding  and stronger confusion about why they are and sometimes aren't.