code: function setPkgConfig(loader, pkgName, cfg, prependConfig) {
    var pkg;
  
    // first package is config by reference for fast path, cloned after that
    if (!loader.packages[pkgName]) {
      pkg = loader.packages[pkgName] = cfg;
    }
    else {
      var basePkg = loader.packages[pkgName];
      pkg = loader.packages[pkgName] = {};
  
      extendPkgConfig(pkg, prependConfig ? cfg : basePkg, pkgName, loader, prependConfig);
      extendPkgConfig(pkg, prependConfig ? basePkg : cfg, pkgName, loader, !prependConfig);
    }
    
    // main object becomes main map
    if (typeof pkg.main == 'object') {
      pkg.map = pkg.map || {};
      pkg.map['./@main'] = pkg.main;
      pkg.main['default'] = pkg.main['default'] || './';
      pkg.main = '@main';
    }
  
    return pkg;
  }
docs: deeply-merge (to first level) config with any existing package config