此处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__);
本文详细解释了Webpack中模块(module)的概念及其加载机制。module并非传统意义上的CommonJS、CMD或AMD规范,而是Webpack自定义的对象。文章阐述了module与chunk的区别,并通过具体的__webpack_require__函数说明了模块是如何被加载和执行的。
2249

被折叠的 条评论
为什么被折叠?



