diff --git a/lib/dependencies/DepBlockHelpers.js b/lib/dependencies/DepBlockHelpers.js index 57739851075..ebf977fe94f 100644 --- a/lib/dependencies/DepBlockHelpers.js +++ b/lib/dependencies/DepBlockHelpers.js @@ -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(); })";