depend.js 608 B

123456789101112131415161718192021222324252627
  1. /** @license
  2. * Plugin to load JS files that have dependencies but aren't wrapped into
  3. * `define` calls.
  4. * Author: Miller Medeiros
  5. * Version: 0.1.0 (2011/12/13)
  6. * Released under the MIT license
  7. */
  8. define(function () {
  9. var rParts = /^(.*)\[([^\]]*)\]$/;
  10. return {
  11. //example: depend!bar[jquery,lib/foo]
  12. load : function(name, req, onLoad, config){
  13. var parts = rParts.exec(name);
  14. req(parts[2].split(','), function(){
  15. req([parts[1]], function(mod){
  16. onLoad(mod);
  17. });
  18. });
  19. }
  20. };
  21. });