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