`

入口之__webpack_require__

 
阅读更多

此处module,exports并不是commonJS、CMD、AMD规范的module,exports

而是webpack自定义的对象

 

module和chunk是不同的设定,

chunk可以理解为一个个的js文件,

module理解为chunk文件的组成部分,根据功能划分的代码块

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;
/******/
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}

 

每个module加载后,都通过这个方法进行执行

modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics