|
|
|
@ -380,13 +380,12 @@ function webpackContext(req) {
|
|
|
|
|
${returnModuleObject}
|
|
|
|
|
}
|
|
|
|
|
function webpackContextResolve(req) {
|
|
|
|
|
var id = map[req];
|
|
|
|
|
if(!(id + 1)) { // check for number or string
|
|
|
|
|
if(!__webpack_require__.o(map, req)) {
|
|
|
|
|
var e = new Error("Cannot find module '" + req + "'");
|
|
|
|
|
e.code = 'MODULE_NOT_FOUND';
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
return id;
|
|
|
|
|
return map[req];
|
|
|
|
|
}
|
|
|
|
|
webpackContext.keys = function webpackContextKeys() {
|
|
|
|
|
return Object.keys(map);
|
|
|
|
@ -414,13 +413,12 @@ function webpackContext(req) {
|
|
|
|
|
${returnModuleObject}
|
|
|
|
|
}
|
|
|
|
|
function webpackContextResolve(req) {
|
|
|
|
|
var id = map[req];
|
|
|
|
|
if(!(id + 1)) { // check for number or string
|
|
|
|
|
if(!__webpack_require__.o(map, req)) {
|
|
|
|
|
var e = new Error("Cannot find module '" + req + "'");
|
|
|
|
|
e.code = 'MODULE_NOT_FOUND';
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
return id;
|
|
|
|
|
return map[req];
|
|
|
|
|
}
|
|
|
|
|
webpackContext.keys = function webpackContextKeys() {
|
|
|
|
|
return Object.keys(map);
|
|
|
|
@ -452,13 +450,12 @@ function webpackAsyncContextResolve(req) {
|
|
|
|
|
// Here Promise.resolve().then() is used instead of new Promise() to prevent
|
|
|
|
|
// uncaught exception popping up in devtools
|
|
|
|
|
return Promise.resolve().then(function() {
|
|
|
|
|
var id = map[req];
|
|
|
|
|
if(!(id + 1)) { // check for number or string
|
|
|
|
|
if(!__webpack_require__.o(map, req)) {
|
|
|
|
|
var e = new Error("Cannot find module '" + req + "'");
|
|
|
|
|
e.code = 'MODULE_NOT_FOUND';
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
return id;
|
|
|
|
|
return map[req];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
webpackAsyncContext.keys = function webpackAsyncContextKeys() {
|
|
|
|
@ -488,13 +485,12 @@ function webpackAsyncContextResolve(req) {
|
|
|
|
|
// Here Promise.resolve().then() is used instead of new Promise() to prevent
|
|
|
|
|
// uncaught exception popping up in devtools
|
|
|
|
|
return Promise.resolve().then(function() {
|
|
|
|
|
var id = map[req];
|
|
|
|
|
if(!(id + 1)) { // check for number or string
|
|
|
|
|
if(!__webpack_require__.o(map, req)) {
|
|
|
|
|
var e = new Error("Cannot find module '" + req + "'");
|
|
|
|
|
e.code = 'MODULE_NOT_FOUND';
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
return id;
|
|
|
|
|
return map[req];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
webpackAsyncContext.keys = function webpackAsyncContextKeys() {
|
|
|
|
@ -527,13 +523,12 @@ function webpackAsyncContext(req) {
|
|
|
|
|
}
|
|
|
|
|
function webpackAsyncContextResolve(req) {
|
|
|
|
|
return ${promise}.then(function() {
|
|
|
|
|
var id = map[req];
|
|
|
|
|
if(!(id + 1)) { // check for number or string
|
|
|
|
|
if(!__webpack_require__.o(map, req)) {
|
|
|
|
|
var e = new Error("Cannot find module '" + req + "'");
|
|
|
|
|
e.code = 'MODULE_NOT_FOUND';
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
return id;
|
|
|
|
|
return map[req];
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
webpackAsyncContext.keys = function webpackAsyncContextKeys() {
|
|
|
|
@ -546,59 +541,92 @@ module.exports = webpackAsyncContext;`;
|
|
|
|
|
|
|
|
|
|
getLazySource(blocks, id) {
|
|
|
|
|
let hasMultipleOrNoChunks = false;
|
|
|
|
|
let hasNoChunk = true;
|
|
|
|
|
const fakeMap = this.getFakeMap(blocks.map(b => b.dependencies[0]));
|
|
|
|
|
const hasFakeMap = typeof fakeMap === "object";
|
|
|
|
|
const map = blocks
|
|
|
|
|
.filter(block => block.dependencies[0].module)
|
|
|
|
|
.map(block => ({
|
|
|
|
|
dependency: block.dependencies[0],
|
|
|
|
|
block: block,
|
|
|
|
|
userRequest: block.dependencies[0].userRequest
|
|
|
|
|
}))
|
|
|
|
|
.map(block => {
|
|
|
|
|
const chunks = block.chunkGroup ? block.chunkGroup.chunks : [];
|
|
|
|
|
if (chunks.length > 0) {
|
|
|
|
|
hasNoChunk = false;
|
|
|
|
|
}
|
|
|
|
|
if (chunks.length !== 1) {
|
|
|
|
|
hasMultipleOrNoChunks = true;
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
dependency: block.dependencies[0],
|
|
|
|
|
block: block,
|
|
|
|
|
userRequest: block.dependencies[0].userRequest,
|
|
|
|
|
chunks
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
.sort((a, b) => {
|
|
|
|
|
if (a.userRequest === b.userRequest) return 0;
|
|
|
|
|
return a.userRequest < b.userRequest ? -1 : 1;
|
|
|
|
|
})
|
|
|
|
|
.reduce((map, item) => {
|
|
|
|
|
const chunks =
|
|
|
|
|
(item.block.chunkGroup && item.block.chunkGroup.chunks) || [];
|
|
|
|
|
if (chunks.length !== 1) {
|
|
|
|
|
hasMultipleOrNoChunks = true;
|
|
|
|
|
const chunks = item.chunks;
|
|
|
|
|
|
|
|
|
|
if (hasNoChunk && !hasFakeMap) {
|
|
|
|
|
map[item.userRequest] = item.dependency.module.id;
|
|
|
|
|
} else {
|
|
|
|
|
const arrayStart = [item.dependency.module.id];
|
|
|
|
|
if (typeof fakeMap === "object") {
|
|
|
|
|
arrayStart.push(fakeMap[item.dependency.module.id]);
|
|
|
|
|
}
|
|
|
|
|
map[item.userRequest] = arrayStart.concat(
|
|
|
|
|
chunks.map(chunk => chunk.id)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
const arrayStart = [item.dependency.module.id];
|
|
|
|
|
if (typeof fakeMap === "object") {
|
|
|
|
|
arrayStart.push(fakeMap[item.dependency.module.id]);
|
|
|
|
|
}
|
|
|
|
|
map[item.userRequest] = arrayStart.concat(
|
|
|
|
|
chunks.map(chunk => chunk.id)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return map;
|
|
|
|
|
}, Object.create(null));
|
|
|
|
|
|
|
|
|
|
const chunksStartPosition = typeof fakeMap === "object" ? 2 : 1;
|
|
|
|
|
const requestPrefix = hasMultipleOrNoChunks
|
|
|
|
|
const shortMode = hasNoChunk && !hasFakeMap;
|
|
|
|
|
const chunksStartPosition = hasFakeMap ? 2 : 1;
|
|
|
|
|
const requestPrefix = hasNoChunk
|
|
|
|
|
? "Promise.resolve()"
|
|
|
|
|
: hasMultipleOrNoChunks
|
|
|
|
|
? `Promise.all(ids.slice(${chunksStartPosition}).map(__webpack_require__.e))`
|
|
|
|
|
: `__webpack_require__.e(ids[${chunksStartPosition}])`;
|
|
|
|
|
const returnModuleObject = this.getReturnModuleObjectSource(
|
|
|
|
|
fakeMap,
|
|
|
|
|
"ids[1]"
|
|
|
|
|
shortMode ? "invalid" : "ids[1]"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return `var map = ${JSON.stringify(map, null, "\t")};
|
|
|
|
|
const webpackAsyncContext =
|
|
|
|
|
requestPrefix === "Promise.resolve()"
|
|
|
|
|
? `${shortMode ? "" : ""}
|
|
|
|
|
function webpackAsyncContext(req) {
|
|
|
|
|
var ids = map[req];
|
|
|
|
|
if(!ids) {
|
|
|
|
|
return Promise.resolve().then(function() {
|
|
|
|
|
if(!__webpack_require__.o(map, req)) {
|
|
|
|
|
var e = new Error("Cannot find module '" + req + "'");
|
|
|
|
|
e.code = 'MODULE_NOT_FOUND';
|
|
|
|
|
throw e;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
${shortMode ? "var id = map[req];" : "var ids = map[req], id = ids[0];"}
|
|
|
|
|
${returnModuleObject}
|
|
|
|
|
});
|
|
|
|
|
}`
|
|
|
|
|
: `function webpackAsyncContext(req) {
|
|
|
|
|
if(!__webpack_require__.o(map, req)) {
|
|
|
|
|
return Promise.resolve().then(function() {
|
|
|
|
|
var e = new Error("Cannot find module '" + req + "'");
|
|
|
|
|
e.code = 'MODULE_NOT_FOUND';
|
|
|
|
|
throw e;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ids = map[req], id = ids[0];
|
|
|
|
|
return ${requestPrefix}.then(function() {
|
|
|
|
|
var id = ids[0];
|
|
|
|
|
${returnModuleObject}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}`;
|
|
|
|
|
|
|
|
|
|
return `var map = ${JSON.stringify(map, null, "\t")};
|
|
|
|
|
${webpackAsyncContext}
|
|
|
|
|
webpackAsyncContext.keys = function webpackAsyncContextKeys() {
|
|
|
|
|
return Object.keys(map);
|
|
|
|
|
};
|
|
|
|
|