lib/module.js
function create_require (env) {
  function require (id) {
    // `require('a@0.0.0')` is prohibited.
    prohibit_require_id_with_version(id);

    // When `require()` another module inside the factory,
    // the module of depdendencies must already been created
    var module = get_module(id, env, true);
    return get_exports(module);
  }

  // @param {string} id Module identifier.
  // Since 4.2.0, we only allow to asynchronously load a single module
  require.async = function(id, callback) {
    if (callback) {
      // `require.async('a@0.0.0')` is prohibited
      prohibit_require_id_with_version(id);
      var module = get_module(id, env);

      // If `require.async` a foreign module, it must be a main entry
      if (!module.main) {

        // Or it should be a module inside the current package
        if (module.n !== env.n) {
          // Otherwise, we will stop that.
          return;
        }
        module.a = true;
      }

      use_module(module, callback);
    }
  };

  // @param {string} path
  require.resolve = function (path) {
    return NEURON_CONF.resolve(parse_id(path, env).id);
  };

  return require;
}
function create_require (env) {
  function require (id) {
    // `require('a@0.0.0')` is prohibited.
    prohibit_require_id_with_version(id);

    // When `require()` another module inside the factory,
    // the module of depdendencies must already been created
    var module = get_module(id, env, true);
    return get_exports(module);
  }

  // @param {string} id Module identifier.
  // Since 4.2.0, we only allow to asynchronously load a single module
  require.async = function(id, callback) {
    if (callback) {
      // `require.async('a@0.0.0')` is prohibited
      prohibit_require_id_with_version(id);
      var module = get_module(id, env);

      // If `require.async` a foreign module, it must be a main entry
      if (!module.main) {

        // Or it should be a module inside the current package
        if (module.n !== env.n) {
          // Otherwise, we will stop that.
          return;
        }
        module.a = true;
      }

      use_module(module, callback);
    }
  };

  // @param {string} path
  require.resolve = function (path) {
    return NEURON_CONF.resolve(parse_id(path, env).id);
  };

  return require;
}
function create_require ( env ) { function require ( id ) { // `require('a@0.0.0')` is prohibited. prohibit_require_id_with_version ( id ) ; // When `require()` another module inside the factory, // the module of depdendencies must already been created var module = get_module ( id , env , true ) ; return get_exports ( module ) ; } // @param {string} id Module identifier. // Since 4.2.0, we only allow to asynchronously load a single module require . async = function ( id , callback ) { if ( callback ) { // `require.async('a@0.0.0')` is prohibited prohibit_require_id_with_version ( id ) ; var module = get_module ( id , env ) ; // If `require.async` a foreign module, it must be a main entry if ( ! module . main ) { // Or it should be a module inside the current package if ( module . n !== env . n ) { // Otherwise, we will stop that. return ; } module . a = true ; } use_module ( module , callback ) ; } } ; // @param {string} path require . resolve = function ( path ) { return NEURON_CONF . resolve ( parse_id ( path , env ) . id ) ; } ; return require ; }
use the sandbox to specify the environment for every id that required in the current module @param {Object} env The object of the current module. @return {function}
use the sandbox to specify the environment for every id that required in the current module