Skip to content

Commit

Permalink
- Move some expressions out from string template into separate variab…
Browse files Browse the repository at this point in the history
…les to improve readability
  • Loading branch information
Kyle Truong authored and Kyle Truong committed Jul 1, 2017
1 parent be6a710 commit 6549f15
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/dependencies/DepBlockHelpers.js
Expand Up @@ -18,11 +18,14 @@ DepBlockHelpers.getLoadDepBlockWrapper = (depBlock, outputOptions, requestShorte
DepBlockHelpers.getDepBlockPromise = (depBlock, outputOptions, requestShortener, name) => {
if(depBlock.chunks) {
const chunks = depBlock.chunks.filter(chunk => !chunk.hasRuntime() && chunk.id !== null);
const pathAndChunkCheck = outputOptions.pathinfo && depBlock.chunkName;
const shortenedChunkName = requestShortener.shorten(depBlock.chunkName);
const chunkReason = asComment(depBlock.chunkReason);
if(chunks.length === 1) {
const chunk = chunks[0];
return `__webpack_require__.e${asComment(name)}(${JSON.stringify(chunk.id)}${outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : ""}${asComment(depBlock.chunkReason)})`;
const chunkId = JSON.stringify(chunks[0].id);
return `__webpack_require__.e${asComment(name)}(${chunkId}${pathAndChunkCheck ? "/*! " + shortenedChunkName + " */" : ""}${chunkReason})`;
} else if(chunks.length > 0) {
return `Promise.all${asComment(name)}(${outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : ""}[${chunks.map(chunk => "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")").join(", ")}])`;
return `Promise.all${asComment(name)}(${pathAndChunkCheck ? "/*! " + shortenedChunkName + " */" : ""}[${chunks.map(chunk => "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")").join(", ")}])`;
}
}
return "new Promise(function(resolve) { resolve(); })";
Expand Down

0 comments on commit 6549f15

Please sign in to comment.