custom declarative linking function
function linkDeclarativeModule(load, loads, loader) {
      // only link if already not already started linking (stops at circular)
      if (load.module)
        return;

      // declare the module with an empty depMap
      var depMap = [];
      var sys = __global.System;
      __global.System = loader;
      var registryEntry = load.declare.call(__global, depMap);

      __global.System = sys;

      var moduleDependencies = [];

      // module is just a plain object, until we evaluate it
      var module = registryEntry.exports;

      console.assert(!load.module, 'Load module already declared!');

      load.module = {
        name: load.name,
        dependencies: moduleDependencies,
        execute: registryEntry.execute,
        exports: module,
        evaluated: false
      };

      // now link all the module dependencies
      // amending the depMap as we go
      for (var i = 0; i < load.dependencies.length; i++) {
        var depName = load.dependencies[i].value;
        var depModule;
        // if dependency already a module, use that
        if (loader.modules[depName]) {
          depModule = loader.modules[depName];
        }
        // otherwise we need to link the dependency
        else {
          for (var j = 0; j < loads.length; j++) {
            if (loads[j].name != depName)
              continue;
            
            linkDeclarativeModule(loads[j], loads, loader);
            
            depModule = loads[j].exports || loads[j].module;
          }
        }

        console.assert(depModule, 'Dependency module not found!');
        console.assert(depModule.exports, 'Dependency module not found!');

        if (registryEntry.exportStar && indexOf.call(registryEntry.exportStar, load.dependencies[i].key) != -1) {
          // we are exporting * from this dependency
          (function(depModuleModule) {
            for (var p in depModuleModule) (function(p) {
              // if the property is already defined throw?
              defineProperty(module, p, {
                enumerable: true,
                get: function() {
                  return depModuleModule[p];
                },
                set: function(value) {
                  depModuleModule[p] = value;
                }
              });
            })(p);
          })(depModule.exports);
        }

        moduleDependencies.push(depModule);
        depMap[i] = depModule.exports;
      }

      load.status = 'linked';
    }