Require the loader

@method requireLoader
@param {Object} loaderConfig the loader config
@return {Object} loader the required loader
163617
function requireLoader(loaderConfig) {
  const errMsgBase = `while requiring loader ${JSON.stringify(loaderConfig)} config,`;
  if (typeof loaderConfig !== 'object') { throw error(`${errMsgBase}, config must be object, got ${typeof loaderConfig}`); }
  if (typeof loaderConfig.loader !== 'string') { throw error(`${errMsgBase}, config.loader must be String, got ${JSON.stringify(loaderConfig.loader)}`); }

  return require(loaderConfig.loader); // eslint-disable-line
}
1273301
function moduleLoaded(resolve, requires, modName, data, loadedModuleData, alreadyMinified){
    // Check for any modules used from this module that we don't already have
    var newRequires = getModulesRequired(data);
    console.log(" - "+modName+" requires "+JSON.stringify(newRequires));
    // if we need new modules, set them to load and get their promises
    var newPromises = [];
    for (var i in newRequires) {
      if (requires.indexOf(newRequires[i])<0) {
        console.log("   Queueing "+newRequires[i]);
        requires.push(newRequires[i]);
        newPromises.push(loadModule(requires, newRequires[i], loadedModuleData));
      } else {
        console.log("   Already loading "+newRequires[i]);
      }
    }

    var loadProcessedModule = function (module) {
      // add the module to the beginning of our array
      if (Espruino.Config.MODULE_AS_FUNCTION)
        loadedModuleData.unshift("Modules.addCached(" + JSON.stringify(module.name) + ",function(){" + module.code + "});");
      else
        loadedModuleData.unshift("Modules.addCached(" + JSON.stringify(module.name) + "," + JSON.stringify(module.code) + ");");
      // if we needed to load something, wait until we have all promises complete before resolving our promise!
      Promise.all(newPromises).then(function(){ resolve(); });
    }
    if (alreadyMinified)
      loadProcessedModule({code:data,name:modName});
    else
      Espruino.callProcessor("transformModuleForEspruino", {code:data,name:modName}, loadProcessedModule);
  }
462124
function requirejs(deps, callback, errback) {
  if (!Array.isArray(deps)) throw new Error('missing deps array');
  if (callback && typeof callback !== 'function') throw new Error('callback is not a function');
  if (errback && typeof errback !== 'function') throw new Error('errback is not a function');

  // return AMD require function or commonjs require function
  function requireFunc() {
    if (typeof arguments[0] === 'string') {
      const dep = arguments[0];
      const got = defined(dep);
      if (got) return got.val;
      throw new Error(`commonjs dependency "${dep}" is not prepared.`);
    }

    return requirejs.apply(null, arguments);
  }

  requireFunc.toUrl = toUrl;

  const depValues = serialResults(deps, d => {
    if (d === 'require') return requireFunc;
    if (d instanceof RegExp) {
      const expanded = [...userSpace.ids(), ...packageSpace.ids()].filter(id => id.match(d));
      return serialResults(expanded, e => userSpace.req(e));
    }
    return userSpace.req(mappedId(d));
  });

  const finalize = results => {
    if (callback) return callback.apply(_global, results);
    else return results;
  };

  const errHandler = err => {
    if (errback) return errback(err);
    else console.error(err); // eslint-disable-line no-console
  };

  if (depValues && typeof depValues.then === 'function') {
    // asynchronous callback
    return depValues.then(finalize, errHandler);
  }

  // synchronous callback
  return new Promise(resolve => {
    resolve(finalize(depValues));
  });
}
681748
function loadConfig(opts) {
  if (opts != null && (typeof opts === "undefined" ? "undefined" : (0, _typeof3.default)(opts)) !== "object") {
    throw new Error("Babel options must be an object, null, or undefined");
  }

  return (0, _optionManager2.default)(opts || {});
}
551717
public function initLoader(Config $config)
    {
        $loader = new Loader();
        $loader->registerDirs(
            [
                $config->application->libraryDir,
                $config->application->pluginDir,
                $config->application->taskDir
            ]
        )->register();
    }
1144028
function _getRequire(config) {
  if (!config.syncRequire && !config.resolveModulePath) return requireLike(config.filename);

  const _requireResolver = {
    basedir:config.basedir||path.dirname(config.filename),
    parent:config.filename,
    scope:config.scope,
    useSandbox:config.useSandbox,
    squashErrors:!!((config.resolver ||{}).squashErrors || config.squashErrors)
  };

  const requireX = require('./index');
  const _mergeResolver = resolver=>Object.assign({}, _requireResolver, resolver);
  const _getResolver = (params, resolverId=0)=>{
    if (isString(params[resolverId]) || Array.isArray(params[resolverId])) return _requireResolver;
    return _mergeResolver(params.shift());
  };

  return Object.assign(function(...params) {
    return config.syncRequire(_getResolver(params), ...params);
  }, requireX, {
    resolve: (...params)=>config.resolveModulePathSync(_getResolver(params), ...params),
    resolveAsync: (...params)=>config.resolveModulePath(_getResolver(params), ...params),
    async: (...params)=>requireX(_getResolver(params), ...params),
    native: moduleId=>requireLike(config.filename)(moduleId),
    import: (dirPath, options, callback)=>requireX.import(dirPath, _mergeResolver(options), callback)
  });
}
547641
function createLoader(options, fn) {
  var loader = new utils.Loader(options);
  return function() {
    if (!this.isApp) loader.cache = this.views;
    loader.options.loaderFn = fn.bind(this);
    loader.load.apply(loader, arguments);
    return loader.cache;
  };
}
1165620
function getWebpackConfig(config, context) {
  var webpackConfig = {
    module: {
      rules: [
        {
          exclude: /node_modules/,
          loader: assist.resolve('settle-loader'),
          test: /\.(es6|jsx)$/,
          options: {
            stub: config.holder.stub,
            link: 'react-dom'
          }
        },
        {
          exclude: /node_modules/,
          loader: assist.resolve('babel-loader'),
          test: /\.(es6|js|jsx)$/
        }
      ]
    },
    output: {
      path: config.$path.target.client,
      filename: '[name].js'
    },
    resolve: {
      extensions: ['.js', '.jsx'],
      alias: config.alias || {}
    },
    externals: {}
  }

  var babelConfig = assist.getBabelConfig(context.env)
  var babelLoader = webpackConfig.module.rules
    .find(rule => rule.loader && /babel/.test(rule.loader))
  babelLoader.options = babelConfig

  if (config.extern) {
    config.extern = assist.arrayify(config.extern)
    if (config.extern.indexOf('react') >= 0) {
      webpackConfig.externals['react'] = 'React'
      webpackConfig.externals['react-dom'] = 'ReactDOM'
    }
  }

  if (!webpackConfig.externals['react']) {
    webpackConfig.module.rules.push({
      test: require.resolve('react'),
      use: [{ loader: 'expose-loader', options: 'React' }]
    },{
      test: require.resolve('react-dom'),
      use: [{ loader: 'expose-loader', options: 'ReactDOM' }]
    })
  }

  var processEnv = {
    'process.env': {
      NODE_ENV: JSON.stringify(context.env || 'production'),
      IS_BROWSER: true
    }
  }
  if (context.env === 'development') {
    // development env
    webpackConfig.plugins = [
      new webpack.DefinePlugin(processEnv)
    ]
  } else {
    // production env
    webpackConfig.plugins = [
      new webpack.DefinePlugin(processEnv),
      new webpack.optimize.CommonsChunkPlugin({ name: 'common' }),
      new webpack.optimize.UglifyJsPlugin({ sourceMap: false })
    ]
  }

  return webpackConfig
}
229704
function() {
			var depends	= this.depends,
				allowed	= this.allowed;

			return every(depends, function(depend) {
				return depend.loader.loaded[depend.id]
					|| depend.loader.failed[depend.id]
					|| allowed[depend.id];
			});
		}
205302
function mergeConfig(loaderConfig) {
  var defaultConfig = {
    // Web3
    provider: 'http://localhost:8545',

    // For deployment
    from: web3.eth.accounts[0],
    gasLimit: web3.eth.getBlock(web3.eth.defaultBlock).gasLimit,

    // Specify contract constructor parameters, if any.
    // constructorParams: {
    //   ContractOne: [ 'param1_value', 'param2_value' ]
    // }
    constructorParams: {},

    // To use deployed contracts instead of redeploying, include contract addresses in config
    // deployedContracts: {
    //   ContractOne: '0x...........',
    //   ContractTwo: '0x...........',
    // }
    deployedContracts: {}
  };

  var mergedConfig = loaderConfig;
  for (var key in defaultConfig) {
    if (!mergedConfig.hasOwnProperty(key)) {
      mergedConfig[key] = defaultConfig[key];
    }
  }
  return mergedConfig;
}
299698
function getLoader(data) {
	if(typeof Loader !== "undefined" && (data instanceof global.Loader)) {
		return data;
	} else if(typeof LoaderPolyfill !== "undefined" && (data instanceof global.LoaderPolyfill)) {
		return data;
	} else {
		return data.steal.System;
	}
}
1223616
function Loader(options) {
  if (!(this instanceof Loader)) {
    return new Loader(options);
  }
  this.options = options || {};
  this.cache = this.options.helpers || {};
}
236061
function loadConfig(config) {
  var options = normalizeOptions(config);

  if (config.options.plugins != null && !Array.isArray(config.options.plugins)) {
    throw new Error(".plugins should be an array, null, or undefined");
  }

  var plugins = (config.options.plugins || []).map(function (plugin, index) {
    var _normalizePair = normalizePair(plugin, _files.loadPlugin, config.dirname),
        filepath = _normalizePair.filepath,
        value = _normalizePair.value,
        options = _normalizePair.options;

    return {
      alias: filepath || config.loc + "$" + index,
      loc: filepath || config.loc,
      value: value,
      options: options,
      dirname: config.dirname
    };
  });

  if (config.options.presets != null && !Array.isArray(config.options.presets)) {
    throw new Error(".presets should be an array, null, or undefined");
  }

  var presets = (config.options.presets || []).map(function (preset, index) {
    var _normalizePair2 = normalizePair(preset, _files.loadPreset, config.dirname),
        filepath = _normalizePair2.filepath,
        value = _normalizePair2.value,
        options = _normalizePair2.options;

    return {
      alias: filepath || config.loc + "$" + index,
      loc: filepath || config.loc,
      value: value,
      options: options,
      dirname: config.dirname
    };
  });

  return { options: options, plugins: plugins, presets: presets };
}
1032428
function (config) {
            if (isUrlOnWhitelist(config.url)) {
              numLoadings++;
              $rootScope.$emit('loaderShow', config.method);
            }

            return config || $q.when(config);
          }
179238
function loadConfig(config, props) {
  // The calling module's path. Unfortunately, because modules are cached,
  // module.parent is the FIRST calling module parent, not necessarily the
  // current one.
  var callerPath = path.dirname(stackTrace.get(loadConfig)[1].getFileName());

  // If no config defined, resolve to nearest package.json to the calling lib. If not found, throw an error.
  if (config == null) {
    config = findup('package.json', {cwd: callerPath});
    if (config == null) {
      throw new Error('No package.json found.');
    }
  }
  // If filename was specified with no path parts, make the path absolute so
  // that resolve doesn't look in node_module directories for it.
  else if (typeof config === 'string' && !/[\\\/]/.test(config)) {
    config = path.join(callerPath, config);
  }

  // If package is a string, try to require it.
  if (typeof config === 'string') {
    config = require(resolve(config, {basedir: callerPath}));
  }

  // If config is not an object yet, something is amiss.
  if (typeof config !== 'object') {
    throw new Error('Invalid configuration specified.');
  }

  // For all specified props, populate result object.
  var result = {};
  props.forEach(function(prop) {
    result[prop] = config[prop] ? Object.keys(config[prop]) : [];
  });
  return result;
}
1218104
function _requireModule(rootPath, name) {
  let modulePath = _normalizeRequire(rootPath, name),
    moduleRes;
  try {
    moduleRes = require(modulePath);
  } catch (e) {
    if (e.code === 'MODULE_NOT_FOUND' && e.message.indexOf(name) !== -1) {
      try {
        moduleRes = require(name);
      } catch (e) {
        if (e.code === 'MODULE_NOT_FOUND' && e.message.indexOf(name) !== -1) {
          throw "NOT_FOUND";
        }
        throw e;
      }
    } else {
      throw e;
    }
  }
  return moduleRes;
}
85058
function _loadFile(filename){
  var module = require(filename);
  delete require.cache[require.resolve(filename)];
  return module;
}