Skip to content

Commit 6549f15

Browse files
Kyle TruongKyle Truong
authored andcommitted
- Move some expressions out from string template into separate variables to improve readability
1 parent be6a710 commit 6549f15

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎lib/dependencies/DepBlockHelpers.js‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ DepBlockHelpers.getLoadDepBlockWrapper = (depBlock, outputOptions, requestShorte
1818
DepBlockHelpers.getDepBlockPromise = (depBlock, outputOptions, requestShortener, name) => {
1919
if(depBlock.chunks) {
2020
const chunks = depBlock.chunks.filter(chunk => !chunk.hasRuntime() && chunk.id !== null);
21+
const pathAndChunkCheck = outputOptions.pathinfo && depBlock.chunkName;
22+
const shortenedChunkName = requestShortener.shorten(depBlock.chunkName);
23+
const chunkReason = asComment(depBlock.chunkReason);
2124
if(chunks.length === 1) {
22-
const chunk = chunks[0];
23-
return `__webpack_require__.e${asComment(name)}(${JSON.stringify(chunk.id)}${outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : ""}${asComment(depBlock.chunkReason)})`;
25+
const chunkId = JSON.stringify(chunks[0].id);
26+
return `__webpack_require__.e${asComment(name)}(${chunkId}${pathAndChunkCheck ? "/*! " + shortenedChunkName + " */" : ""}${chunkReason})`;
2427
} else if(chunks.length > 0) {
25-
return `Promise.all${asComment(name)}(${outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : ""}[${chunks.map(chunk => "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")").join(", ")}])`;
28+
return `Promise.all${asComment(name)}(${pathAndChunkCheck ? "/*! " + shortenedChunkName + " */" : ""}[${chunks.map(chunk => "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")").join(", ")}])`;
2629
}
2730
}
2831
return "new Promise(function(resolve) { resolve(); })";

0 commit comments

Comments
 (0)