index.js
function setGlobalDefine(requiredModule)
{
  // pass globalDefine instance from parent to child module
  if (requiredModule.parent && requiredModule.parent._globalDefine)
  {
    // inherited instance
    requiredModule._globalDefine = requiredModule.parent._globalDefine;
  }

  // create global define specific to the module
  // but only if its whitelisted and not blacklisted
  if (requiredModule._globalDefine && requiredModule._globalDefine.isWhitelisted(requiredModule.id) && !requiredModule._globalDefine.isBlacklisted(requiredModule.id))
  {
    global.define = requiredModule._globalDefine.amdefineWorkaround(requiredModule);

    // run required paths through alias substituion
    if (requiredModule._globalDefine.aliasRequire)
    {
      requiredModule._originalRequire = requiredModule.require;
      requiredModule.require = function(modulePath)
      {
        return requiredModule._originalRequire.call(this, requiredModule._globalDefine.checkPath(modulePath));
      }
    }
  }
  else
  {
    // reset global define
    delete global.define;
  }
}
function setGlobalDefine(requiredModule)
{
  // pass globalDefine instance from parent to child module
  if (requiredModule.parent && requiredModule.parent._globalDefine)
  {
    // inherited instance
    requiredModule._globalDefine = requiredModule.parent._globalDefine;
  }

  // create global define specific to the module
  // but only if its whitelisted and not blacklisted
  if (requiredModule._globalDefine && requiredModule._globalDefine.isWhitelisted(requiredModule.id) && !requiredModule._globalDefine.isBlacklisted(requiredModule.id))
  {
    global.define = requiredModule._globalDefine.amdefineWorkaround(requiredModule);

    // run required paths through alias substituion
    if (requiredModule._globalDefine.aliasRequire)
    {
      requiredModule._originalRequire = requiredModule.require;
      requiredModule.require = function(modulePath)
      {
        return requiredModule._originalRequire.call(this, requiredModule._globalDefine.checkPath(modulePath));
      }
    }
  }
  else
  {
    // reset global define
    delete global.define;
  }
}
function setGlobalDefine ( requiredModule ) { // pass globalDefine instance from parent to child module if ( requiredModule . parent && requiredModule . parent . _globalDefine ) { // inherited instance requiredModule . _globalDefine = requiredModule . parent . _globalDefine ; } // create global define specific to the module // but only if its whitelisted and not blacklisted if ( requiredModule . _globalDefine && requiredModule . _globalDefine . isWhitelisted ( requiredModule . id ) && ! requiredModule . _globalDefine . isBlacklisted ( requiredModule . id ) ) { global . define = requiredModule . _globalDefine . amdefineWorkaround ( requiredModule ) ; // run required paths through alias substituion if ( requiredModule . _globalDefine . aliasRequire ) { requiredModule . _originalRequire = requiredModule . require ; requiredModule . require = function ( modulePath ) { return requiredModule . _originalRequire . call ( this , requiredModule . _globalDefine . checkPath ( modulePath ) ) ; } } } else { // reset global define delete global . define ; } }
sets _globalDefine and global.define if needed
sets _globalDefine and global . define if needed