那么manifest如何做初始化工作呢?
(function(modules) {
parentJsonpFunction = window[] =
moduleId,chunkId,i = ,resolves =(;i < chunkIds.length; i++== (moduleId =(i=; i < executeModules.length; i++= __webpack_require__(__webpack_require__.s = </span><span style="color: #008000">//</span><span style="color: #008000"> The module cache</span>
<span style="color: #0000ff">var</span> installedModules =<span style="color: #000000"> {};
</span><span style="color: #008000">//</span><span style="color: #008000"> objects to store loaded and loading chunks</span>
<span style="color: #0000ff">var</span> installedChunks =<span style="color: #000000"> {
</span><span style="color: #800080">4</span>: <span style="color: #800080">0</span><span style="color: #000000">
};
</span><span style="color: #008000">//</span><span style="color: #008000"> The require function模块加载函数</span>
<span style="color: #000000"> function __webpack_require__(moduleId) {
</span><span style="color: #008000">//</span><span style="color: #008000"> Check if module is in cache</span>
<span style="color: #0000ff">if</span><span style="color: #000000">(installedModules[moduleId]) {
</span><span style="color: #0000ff">return</span><span style="color: #000000"> installedModules[moduleId].exports;
}
</span><span style="color: #008000">//</span><span style="color: #008000"> Create a new module (and put it into the cache)</span>
<span style="color: #0000ff">var</span> module = installedModules[moduleId] =<span style="color: #000000"> {
i: moduleId,exports: {}
};
</span><span style="color: #008000">//</span><span style="color: #008000"> Execute the module function</span>
<span style="color: #000000"> modules[moduleId].call(module.exports,__webpack_require__);
</span><span style="color: #008000">//</span><span style="color: #008000"> Flag the module as loaded</span>
module.l = <span style="color: #0000ff">true</span><span style="color: #000000">;
</span><span style="color: #008000">//</span><span style="color: #008000"> Return the exports of the module</span>
<span style="color: #0000ff">return</span><span style="color: #000000"> module.exports;
}
</span><span style="color: #008000">//</span><span style="color: #008000"> This file contains only the entry chunk.
</span><span style="color: #008000">//</span><span style="color: #008000"> The chunk loading function for additional chunks</span>
__webpack_require__.e =<span style="color: #000000"> function requireEnsure(chunkId) {
</span><span style="color: #0000ff">var</span> installedChunkData =<span style="color: #000000"> installedChunks[chunkId];
</span><span style="color: #0000ff">if</span>(installedChunkData === <span style="color: #800080">0</span><span style="color: #000000">) {
</span><span style="color: #0000ff">return</span> <span style="color: #0000ff">new</span><span style="color: #000000"> Promise(function(resolve) { resolve(); });
}
</span><span style="color: #008000">//</span><span style="color: #008000"> a Promise means "currently loading".</span>
<span style="color: #0000ff">if</span><span style="color: #000000">(installedChunkData) {
</span><span style="color: #0000ff">return</span> installedChunkData[<span style="color: #800080">2</span><span style="color: #000000">];
}
</span><span style="color: #008000">//</span><span style="color: #008000"> setup Promise in chunk cache</span>
<span style="color: #0000ff">var</span> promise = <span style="color: #0000ff">new</span><span style="color: #000000"> Promise(function(resolve,reject) {
installedChunkData </span>= installedChunks[chunkId] =<span style="color: #000000"> [resolve,reject];
});
installedChunkData[</span><span style="color: #800080">2</span>] =<span style="color: #000000"> promise;
</span><span style="color: #008000">//</span><span style="color: #008000"> start chunk loading</span>
<span style="color: #0000ff">var</span> head = document.getElementsByTagName(<span style="color: #800000">'</span><span style="color: #800000">head</span><span style="color: #800000">'</span>)[<span style="color: #800080">0</span><span style="color: #000000">];
</span><span style="color: #0000ff">var</span> script = document.createElement(<span style="color: #800000">'</span><span style="color: #800000">script</span><span style="color: #800000">'</span><span style="color: #000000">);
script.type </span>= <span style="color: #800000">"</span><span style="color: #800000">text/javascript</span><span style="color: #800000">"</span><span style="color: #000000">;
script.charset </span>= <span style="color: #800000">'</span><span style="color: #800000">utf-8</span><span style="color: #800000">'</span><span style="color: #000000">;
script.</span><span style="color: #0000ff">async</span> = <span style="color: #0000ff">true</span><span style="color: #000000">;
script.timeout </span>= <span style="color: #800080">120000</span><span style="color: #000000">;
</span><span style="color: #0000ff">if</span><span style="color: #000000"> (__webpack_require__.nc) {
script.setAttribute(</span><span style="color: #800000">"</span><span style="color: #800000">nonce</span><span style="color: #800000">"</span><span style="color: #000000">,__webpack_require__.nc);
}
script.src </span>= __webpack_require__.p + <span style="color: #800000">""</span> + chunkId + <span style="color: #800000">"</span><span style="color: #800000">.</span><span style="color: #800000">"</span> + {<span style="color: #800000">"</span><span style="color: #800000">0</span><span style="color: #800000">"</span>:<span style="color: #800000">"</span><span style="color: #800000">ae9c5f5f</span><span style="color: #800000">"</span>}[chunkId] + <span style="color: #800000">"</span><span style="color: #800000">.js</span><span style="color: #800000">"</span><span style="color: #000000">;
</span><span style="color: #0000ff">var</span> timeout = setTimeout(onScriptComplete,<span style="color: #800080">120000</span><span style="color: #000000">);
script.onerror </span>= script.onload =<span style="color: #000000"> onScriptComplete;
function onScriptComplete() {
</span><span style="color: #008000">//</span><span style="color: #008000"> avoid mem leaks in IE.</span>
script.onerror = script.onload = <span style="color: #0000ff">null</span><span style="color: #000000">;
clearTimeout(timeout);
</span><span style="color: #0000ff">var</span> chunk =<span style="color: #000000"> installedChunks[chunkId];
</span><span style="color: #0000ff">if</span>(chunk !== <span style="color: #800080">0</span><span style="color: #000000">) {
</span><span style="color: #0000ff">if</span><span style="color: #000000">(chunk) {
chunk[</span><span style="color: #800080">1</span>](<span style="color: #0000ff">new</span> Error(<span style="color: #800000">'</span><span style="color: #800000">Loading chunk </span><span style="color: #800000">'</span> + chunkId + <span style="color: #800000">'</span><span style="color: #800000"> failed.</span><span style="color: #800000">'</span><span style="color: #000000">));
}
installedChunks[chunkId] </span>=<span style="color: #000000"> undefined;
}
};
head.appendChild(script);
</span><span style="color: #0000ff">return</span><span style="color: #000000"> promise;
};
</span><span style="color: #008000">//</span><span style="color: #008000"> expose the modules object (__webpack_modules__)</span>
__webpack_require__.m =<span style="color: #000000"> modules;
</span><span style="color: #008000">//</span><span style="color: #008000"> expose the module cache</span>
__webpack_require__.c =<span style="color: #000000"> installedModules;
</span><span style="color: #008000">//</span><span style="color: #008000"> define getter function for harmony exports</span>
__webpack_require__.d =<span style="color: #000000"> function(exports,</span><span style="color: #0000ff">get</span><span style="color: #000000">: getter
});
}
};
</span><span style="color: #008000">//</span><span style="color: #008000"> getDefaultExport function for compatibility with non-harmony modules</span>
__webpack_require__.n =<span style="color: #000000"> function(module) {
</span><span style="color: #0000ff">var</span> getter = module && module.__esModule ?<span style="color: #000000">
function getDefault() { </span><span style="color: #0000ff">return</span> module[<span style="color: #800000">'</span><span style="color: #800000">default</span><span style="color: #800000">'</span><span style="color: #000000">]; } :
function getModuleExports() { </span><span style="color: #0000ff">return</span><span style="color: #000000"> module; };
__webpack_require__.d(getter,getter);
</span><span style="color: #0000ff">return</span><span style="color: #000000"> getter;
};
</span><span style="color: #008000">//</span><span style="color: #008000"> Object.prototype.hasOwnProperty.call</span>
__webpack_require__.o = function(<span style="color: #0000ff">object</span>,property); };
</span><span style="color: #008000">//</span><span style="color: #008000"> __webpack_public_path__</span>
__webpack_require__.p = <span style="color: #800000">""</span><span style="color: #000000">;
</span><span style="color: #008000">//</span><span style="color: #008000"> on error function for async loading</span>
__webpack_require__.oe = function(err) { console.error(err); <span style="color: #0000ff">throw</span><span style="color: #000000"> err; };
})([]);
与单文件内容一致,定义了一个自执行函数,因为它不包含任何模块,所以传入一个空数组。除了定义了__webpack_require__ ,还另外定义了两个函数用来进行加载模块。
(编辑:ASP站长网)
|