180、React15.6.0、ReactDOM15.6.0和React-Redux.4.0.0.js源码结构

/*(function (exports,require,module,__dirname,__filename) {
    this = exports;
    module.exports = exports = {}
    文件
    exports = Person
    return module.exports
})*/
//向exports对象上增加属性,可以导致module.exports的变化,如果让exports指向新的地址,不会影响module.exports的变化,最终导出的是module.exports 不是exports

//外自执行函数执行->内自执行函数执行->递归函数执行->功能函数执行(里面仍然有可能执行递归函数)
/**
 * React v15.6.0
 */
(function (allFn) {
  if (typeof exports === "object" && typeof module !== "undefined") {
    module.exports = allFn()
  } else if (typeof define === "function" && define.amd) { 
    define([], allFn) 
  } else { 
    var tempGlobal; 
    if (typeof window !== "undefined") { 
      tempGlobal = window 
    } else if (typeof global !== "undefined") { 
      tempGlobal = global 
    } else if (typeof self !== "undefined") { 
      tempGlobal = self 
    } else { 
      tempGlobal = this 
    } 
    tempGlobal.React = allFn() 
    }
})(function () {
  var define, module, exports; 
  return (function outerFn(first, second, third) { 
    function recursion(number) { 
      if(!second[number]){
        if(!first[number]) {
          var error = new Error("Cannot find module '" + number + "'"); 
          throw error.code = "MODULE_NOT_FOUND", error 
        } 
        var module = second[number] = { 
          exports: {} 
        }; 
        first[number][0].call(module.exports, function (key) { 
          var value = first[number][1][key]; 
          return recursion(value ? value : key) 
        }, module, module.exports, outerFn, first, second, third) 
      } 
      return second[number].exports 
    } 
    for (var number = 0; number < third.length; number++) recursion(third[number]); 
    return recursion 
    //以上两行可以合并为下面一行
    //return recursion(third[0]); 
    //同时下面的"(48)" 应当删掉 
  })({2: [function (_dereq_, module, exports) {console.log(_dereq_)}, { "25": 25, "30": 30 }], }, {}, [16])(16)
});

/**
 * ReactDOM v15.6.0
 */
(function (allFn) {
  if (typeof exports === "object" && typeof module !== "undefined") {
    module.exports = allFn(require('react'));
  } else if (typeof define === "function" && define.amd) {
    define(['react'], allFn);
  } else {
    var tempGlobal;
    if (typeof window !== "undefined") {
      tempGlobal = window;
    } else if (typeof global !== "undefined") {
      tempGlobal = global;
    } else if (typeof self !== "undefined") {
      tempGlobal = self;
    } else {
      tempGlobal = this;
    }
    tempGlobal.ReactDOM = allFn(tempGlobal.React);
  }
})(function (React) {
  var define, module, exports; 
  return (function outerFn(first, second, third) {  
    function recursion(number) { 
      if(!second[number]){
        if(!first[number]) {
          var error = new Error("Cannot find module '" + number + "'"); 
          throw error.code = "MODULE_NOT_FOUND", error 
        } 
        var module = second[number] = { 
          exports: {} 
        }; 
        first[number][0].call(module.exports, function (key) { 
          var value = first[number][1][key]; 
          return recursion(value ? value : key) 
        }, module, module.exports, outerFn, first, second, third) 
      } 
      return second[number].exports 
    } 
    var i = typeof require == "function" && require; 
    for (var number = 0; number < third.length; number++) recursion(third[number]); 
    return recursion 
    //以上两行可以合并为下面一行
    //return recursion(third[0]);
    //同时下面的"(48)" 应当删掉 
  })({1: [function (_dereq_, module, exports) {console.log(_dereq_)}, {"25": 25, "30": 30}],}, {}, [48])(48)
});

/* react-redux.4.0.0.js */
(function webpackUniversalModuleDefinition(root, factory) {
    if (typeof exports === 'object' && typeof module === 'object')
        module.exports = factory(require("react"), require("redux"));
    else if (typeof define === 'function' && define.amd)
        define(["react", "redux"], factory);
    else if (typeof exports === 'object')
        exports["ReactRedux"] = factory(require("react"), require("redux"));
    else
        root["ReactRedux"] = factory(root["React"], root["Redux"]);
})(this, function (__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_10__) {
    return (function (modules) { 
        var installedModules = {};
        function __webpack_require__(moduleId) {
            if (installedModules[moduleId])
                return installedModules[moduleId].exports;
            var module = installedModules[moduleId] = {
                exports: {},
                id: moduleId,
                loaded: false
            };
            modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
            module.loaded = true;
            return module.exports;
        }
        __webpack_require__.m = modules;
        __webpack_require__.c = installedModules;
        __webpack_require__.p = "";
        return __webpack_require__(0);
    })([
            function (module, exports, __webpack_require__) {
                'use strict';
                exports.__esModule = true;
                function _interopRequire(obj) { return obj && obj.__esModule ? obj['default'] : obj; }
                var _componentsProvider = __webpack_require__(3);
                exports.Provider = _interopRequire(_componentsProvider);
                var _componentsConnect = __webpack_require__(4);
                exports.connect = _interopRequire(_componentsConnect);
            },            
        ])
});

 

你可能感兴趣的:(180、React15.6.0、ReactDOM15.6.0和React-Redux.4.0.0.js源码结构)