Skip to content

Commit

Permalink
- Move more expressions out to improve readability as discussed in PR…
Browse files Browse the repository at this point in the history
… review
  • Loading branch information
Kyle Truong authored and Kyle Truong committed Jul 1, 2017
1 parent 6549f15 commit 98951d1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/dependencies/DepBlockHelpers.js
Expand Up @@ -18,14 +18,16 @@ 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 pathChunkCheck = outputOptions.pathinfo && depBlock.chunkName;
const shortChunkName = requestShortener.shorten(depBlock.chunkName);
const chunkReason = asComment(depBlock.chunkReason);
const requireChunkId = chunk => "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")";
name = asComment(name);
if(chunks.length === 1) {
const chunkId = JSON.stringify(chunks[0].id);
return `__webpack_require__.e${asComment(name)}(${chunkId}${pathAndChunkCheck ? "/*! " + shortenedChunkName + " */" : ""}${chunkReason})`;
return `__webpack_require__.e${name}(${chunkId}${pathChunkCheck ? "/*! " + shortChunkName + " */" : ""}${chunkReason})`;
} else if(chunks.length > 0) {
return `Promise.all${asComment(name)}(${pathAndChunkCheck ? "/*! " + shortenedChunkName + " */" : ""}[${chunks.map(chunk => "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")").join(", ")}])`;
return `Promise.all${name}(${pathChunkCheck ? "/*! " + shortChunkName + " */" : ""}[${chunks.map(requireChunkId).join(", ")}])`;
}
}
return "new Promise(function(resolve) { resolve(); })";
Expand Down

0 comments on commit 98951d1

Please sign in to comment.