This question describes how to fetch all loaded modules by requirejs: require.js: Access all loaded modules
Is there any way to only fetch the required modules in the current scope? I.e. foo
and bar
below:
define(['foo', 'bar'], function(ko) {
var allDefinedModules = require.s.contexts._.defined;
// how to fetch only foo and bar?
});
I know that I can filter the list with a hard coded check for the two modules, but I want to know if there's a better way.