A partial archive of https://discourse-mediawiki.wmflabs.org as of Saturday May 21, 2022.

How to see why a RL module is loaded

Osnard

Is there an easy way to see why a module is being loaded as a dependecy? So for example module “X” is never loaded by OutputPage:addModules / OutputPage:addModuleScripts or mw.loader.using (or similar). But still it is loaded on every page request. Therefore some other module must require it as a dependency.
Are there any debug logs/tools that could help me to find such a dependency?

Tgr

You could fetch the dependency tree and do some kind of pathfinding on it. I’m not aware of a better way.

Osnard

Thanks.

I found executing

for ( module in mw.loader.moduleRegistry ) {
	if( mw.loader.moduleRegistry[module].dependencies.indexOf( 'X' ) !== -1) {
		var state = mw.loader.getState( module );
		if( state === 'ready' ) {
			console.log( module );
		}
	}
}

in the JavaScript console to be helpfull.