Refactor this internal extension.json property to be exported as attribute – via ExtensionRegistry->getAttribute('ResourceModules') – instead of as wgResourceModules global.
This way, ExtensionRegistry and ExtensionProcessor will not have to read and export it unconditionally during request initialisation. Instead, it will be retrieved by ResourceLoader if and when needed only. This is a prerequisite for making it a lazy-loaded attribute.
This will help with requests where ResourceLoader is never instantiated, such as most api.php and rest.php requests, most CLI and JobRunner processes, and and possibly some of index.php requests as well.