I mean How can an extension's ResourceLoader module have a soft dependency on a module provided by another extension?
If ext.eventLogging is available on this wiki, I want to use its functionality in my extension's JS. But my JS can live without it. Extensions with similar soft dependencies on ClickTracking express it as a hard requirement, which makes them harder to use on other wikis.
Thanks.
On Sun, Jan 27, 2013 at 5:07 PM, Brian Wolff bawolff@gmail.com wrote:
I'm confused. You want your extension to load the module only if the extension is loaded? If your extension isnt loaded than what is loading your module.
If you only want to load the module for certain configurations, that sounds like a job for $wgExtensionFunctions -bawolff On 2013-01-27 8:58 PM, "S Page" spage@wikimedia.org wrote:
How can an extension have a soft requirement on a module, so that it only adds that module to its ResourceLoader dependencies if the extension providing that module is loaded?
For example, there's no sense in depending on ext.eventLog if the wiki doesn't load Extension:EventLogging, but if it's available then you want the module sent to the browser along with your code. (Obviously your JS would check to see if the module's functions are available before invoking them.)
I think your extension can't change dependencies when specifying its module in $wgResourceModules[], it has to do it later. Maybe in a ResourceLoaderRegisterModules hook (although RL runs that before it registers the static wgResourceModules array), or possibly in a setup function you add to $wgExtensionFunctions
Or, in each onHook handler where you call addModule(), you could test there and add the optional module.
Thanks for any insight, I'll add it to mediawiki.org.
-- =S Page software engineer on Editor Engagement Experiments