If a chunk loader contains complex logic it will not be run. For example:
function loader(chunkId) {
return __webpack_require__.p + "" + ({ "1": "chunk1", "2": "chunk2" }[chunkId] || chunkId) + ".js";
}
Looks simple enough. However, This __webpack_require__.p is generated by:
var scriptUrl;
if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
var document = __webpack_require__.g.document;
if (!scriptUrl && document) {
if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
scriptUrl = document.currentScript.src;
if (!scriptUrl) {
var scripts = document.getElementsByTagName("script");
if(scripts.length) {
var i = scripts.length - 1;
while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
}
}
}
if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
__webpack_require__.p = scriptUrl;
Which is pretty complex, involving lots of other members.
Currently, the algorithm can only handle simple hardcoded values, such as __webpack_require__.p = "value" and cannot perform more complex logic like the example above.
If a chunk loader contains complex logic it will not be run. For example:
Looks simple enough. However, This
__webpack_require__.pis generated by:Which is pretty complex, involving lots of other members.
Currently, the algorithm can only handle simple hardcoded values, such as
__webpack_require__.p = "value"and cannot perform more complex logic like the example above.