Open gamtiq opened 11 years ago
Interesting iea. Where do these modules come from? Can you help me understand some use cases?
This might work (depending on your use case):
<script src="path/to/curl.js"></script>
<script>
curl({ baseUrl: '...', etc: '...' });
define("m1", obj1);
define("m2", function() { return modDef; });
define("m1/m2", obj1.obj2);
</script>
John,
Actually your code is similar to my snippet 1. I use curl along with my own framework. The framework’s loader loads some framework files before curl. Those files contain "plain js" (not AMD) organized by namespaces. As a result I have an objects hierarchy. Some objects from this hierarchy I would like to use as modules in an application for convenience purposes. To achieve this now I apply code that is alike to the snippet 1. The proposed config option would allow optimizing a little in such situation.
Heh, this may be all that's needed in the config routine:
var predefined, name = cfg['predefined']
for (name in predefined) _define(name, predefined[name]);
It seems the needed code should be a bit more complex. ;-)
var name, predefined;
if (predefined = cfg['predefined']) {
for (name in predefined) {
_define(name, predefined[name]);
}
}
Hello John,
It would be useful to have some configuration option that allows describing several predefined modules (i.e. named modules/objects that have created before curl loading). So that instead of
it could be possible to write something like the following
Best regards, Denis