0

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.

Community
  • 1
  • 1
filur
  • 2,116
  • 6
  • 24
  • 47
  • 1
    "foo" & "bar" are parameters of your function ("foo" is actually aliased `ko` in this code). – Amit Feb 01 '16 at 12:04
  • 1
    @Amit The difference is that `require.s.contexts._.defined` provides me with an object with keys equal to the string in the array, while `arguments` would just provide me with an array of the module values. – filur Feb 01 '16 at 13:21

0 Answers0