Maybe I missed this in the documentation somewhere but here goes. I've got a core controller that takes care of managing modules. I have about 20 modules so far and would like to be able to easily configure them to be loaded by the core. This means I have a large array or lots of calls to require. Is it acceptable/good practise to create a list of modules in a literal object and then have a module load it's dependencies from that? Here's an example of what I mean:
Config.js
modules = [
'moduleA',
'moduleB',
'moduleC'
];
Core.JS
define(
['config'],
function(config) {
// Somewhere in here I parse the list and require() each one ?
return {
startAll : function() {
console.log('starting all modules.');
// Then call a method common to all 'modules' in the list above.
}
}
};
}
);
I'm not sure if this is such a good idea as I'm new to RequireJS but I like the idea of being able to configure which modules are loaded from one place. In my case by module I am referring to UI widgets that I have written more specifically.