src/Module.js
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)
  });
}
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)
  });
}
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 ) } ) ; }
Create a require function to pass into the module.

@private
@param {Object} config     Module construction config.
@returns {Function}        The require function.
Create a require function to pass into the module .