Similar to T289865, we would like to avoid loading both the @wikimedia/codex-search and @wikimedia/codex modules.
Some ideas for how we might do this:
- @wikimedia/codex-search could have a skipFunction that checks if mw.loader.getState( '@wikimedia/codex' ) === 'ready', and if so, returns true and sets module.exports = require( '@wikimedia/codex' )
- This requires allowing skipFunctions to set module.exports, which they're currently not able to do
- This would prevent codex-search from being loaded when codex has already finished loading, but not when it's started loading but hasn't arrived yet
- We could add some code to resources/src/codex/codex.js that does something like mw.loader.implement( '@wikimedia/codex-search', function( $, jQuery, require, module ) { module.exports = codex; } );
- Like #1, this wouldn't address the case where codex-search wants to load when codex has already been requested but is still underway