Topic on Talk:ResourceLoader/Package files

Jump to navigation Jump to search
Jdlrobson (talkcontribs)

If I define config inside a ResourceLoader module, e.g. 'config.json' => [ 'callback' => 'method' ]

but need to access this inside another RL module, what is the proposed way of doing that? Should I not use it at all or should I call mw.config.set inside my JS ?

Roan Kattouw (WMF) (talkcontribs)

I suppose this documentation neglects to mention that module.exports and require() also work at the module level. So ideally, module A would include the config blob (or a relevant subset thereof) in its module.exports, and then module B would call require('A').

As for mw.config, I think we should start slowly weaning ourselves off of that, or at least resist adding new things to it. So for backwards compatibility you would probably end up doing mw.config.set() sometimes, but I don't think it should be the preferred way of doing things.

Reply to "Sharing config"