Last active
December 14, 2015 16:53
-
-
Save nantunes/c4eb68c32843ccd43c7b to your computer and use it in GitHub Desktop.
Intercept requirejs calls and output info to console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var req_original = { | |
completeLoad: require.s.contexts._.completeLoad, | |
load: require.s.contexts._.load, | |
execCb: require.s.contexts._.execCb | |
}; | |
require.s.contexts._.completeLoad = _completeLoad.bind(require.s.contexts._); | |
require.s.contexts._.load = _load.bind(require.s.contexts._); | |
require.s.contexts._.execCb = _execCb.bind(require.s.contexts._); | |
function _completeLoad(moduleName) { | |
console.log('Completed load of ' + moduleName); | |
return req_original.completeLoad(moduleName); | |
} | |
function _load(id, url) { | |
console.log(' Loading ' + id + ' from ' + url); | |
return req_original.load(id, url); | |
} | |
function _execCb(name, callback, args, exports) { | |
console.log('Initializing ' + name); | |
return req_original.execCb(name, callback, args, exports); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment