As part of the work of the frontend standards group https://gerrit.wikimedia.org/r/#/c/260071/ adds require and module.exports to MediaWiki ResourceLoader. This will make it easier to share code outside MediaWiki and with nodejs systems as well as discouraging the overloading of the mediawiki variable.
I'm looking for code review at the moment. If you are familiar with ResourceLoader's internals I'd appreciate your input.
See https://phabricator.wikimedia.org/T108655 for further background