src/lib/index.js
function loadContracts(loaders, base, sourceMap, environment, callback) { // eslint-disable-line
  var outputContracts = cloneDeep(base); // eslint-disable-line
  const errMsgBase = 'while processing entry data, ';
  if (!Array.isArray(loaders)) { return callback(error(`${errMsgBase}loaders must be type Array, got ${typeof loaders}`)); }

  // process loaders
  try {
    loaders.forEach((loaderConfig) => {
      // require the loader for use
      const loader = requireLoader(loaderConfig);

      // filtered sourcemap based on regex/include
      const filteredSourceMap = filterSourceMap(loaderConfig.test,
        loaderConfig.include,
        sourceMap,
        loaderConfig.exclude);

      // get loaded contracts
      const loadedEnvironment = loader(cloneDeep(filteredSourceMap), loaderConfig, environment);

      // output the new contracts
      outputContracts = Object.assign({}, cloneDeep(outputContracts), cloneDeep(loadedEnvironment));
    });

    // transform final contracts output
    callback(null, outputContracts);
  } catch (loaderError) {
    callback(error(`${errMsgBase}loader error: ${loaderError}`));
  }
}
function loadContracts(loaders, base, sourceMap, environment, callback) { // eslint-disable-line
  var outputContracts = cloneDeep(base); // eslint-disable-line
  const errMsgBase = 'while processing entry data, ';
  if (!Array.isArray(loaders)) { return callback(error(`${errMsgBase}loaders must be type Array, got ${typeof loaders}`)); }

  // process loaders
  try {
    loaders.forEach((loaderConfig) => {
      // require the loader for use
      const loader = requireLoader(loaderConfig);

      // filtered sourcemap based on regex/include
      const filteredSourceMap = filterSourceMap(loaderConfig.test,
        loaderConfig.include,
        sourceMap,
        loaderConfig.exclude);

      // get loaded contracts
      const loadedEnvironment = loader(cloneDeep(filteredSourceMap), loaderConfig, environment);

      // output the new contracts
      outputContracts = Object.assign({}, cloneDeep(outputContracts), cloneDeep(loadedEnvironment));
    });

    // transform final contracts output
    callback(null, outputContracts);
  } catch (loaderError) {
    callback(error(`${errMsgBase}loader error: ${loaderError}`));
  }
}
function loadContracts ( loaders , base , sourceMap , environment , callback ) { // eslint-disable-line var outputContracts = cloneDeep ( base ) ; // eslint-disable-line const errMsgBase = 'while processing entry data, ' ; if ( ! Array . isArray ( loaders ) ) { return callback ( error ( ` ${ errMsgBase } ${ typeof loaders } ` ) ) ; } // process loaders try { loaders . forEach ( ( loaderConfig ) => { // require the loader for use const loader = requireLoader ( loaderConfig ) ; // filtered sourcemap based on regex/include const filteredSourceMap = filterSourceMap ( loaderConfig . test , loaderConfig . include , sourceMap , loaderConfig . exclude ) ; // get loaded contracts const loadedEnvironment = loader ( cloneDeep ( filteredSourceMap ) , loaderConfig , environment ) ; // output the new contracts outputContracts = Object . assign ( { } , cloneDeep ( outputContracts ) , cloneDeep ( loadedEnvironment ) ) ; } ) ; // transform final contracts output callback ( null , outputContracts ) ; } catch ( loaderError ) { callback ( error ( ` ${ errMsgBase } ${ loaderError } ` ) ) ; } }
Load contracts from the sourcemap, start from base

@method loadContracts
@param {Array} loaders the array of loaders
@param {Object} base the base contracts object from which to assign to
@param {Object} sourceMap the sourcemap from load time
@param {Object} environment the environments object
@param {Function} callback the method callback that returns the contracts
@callback {Object} contracts the loaded contracts
Load contracts from the sourcemap start from base