diff options
Diffstat (limited to 'node_modules/webpack/lib/dependencies/DepBlockHelpers.js')
-rw-r--r-- | node_modules/webpack/lib/dependencies/DepBlockHelpers.js | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/node_modules/webpack/lib/dependencies/DepBlockHelpers.js b/node_modules/webpack/lib/dependencies/DepBlockHelpers.js index d4a4014ec..c1e48a3a5 100644 --- a/node_modules/webpack/lib/dependencies/DepBlockHelpers.js +++ b/node_modules/webpack/lib/dependencies/DepBlockHelpers.js @@ -2,10 +2,12 @@ MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
-var DepBlockHelpers = exports;
+"use strict";
-DepBlockHelpers.getLoadDepBlockWrapper = function(depBlock, outputOptions, requestShortener, name) {
- var promiseCode = DepBlockHelpers.getDepBlockPromise(depBlock, outputOptions, requestShortener, name);
+const DepBlockHelpers = exports;
+
+DepBlockHelpers.getLoadDepBlockWrapper = (depBlock, outputOptions, requestShortener, name) => {
+ const promiseCode = DepBlockHelpers.getDepBlockPromise(depBlock, outputOptions, requestShortener, name);
return [
promiseCode + ".then(",
").catch(",
@@ -13,24 +15,19 @@ DepBlockHelpers.getLoadDepBlockWrapper = function(depBlock, outputOptions, reque ];
};
-DepBlockHelpers.getDepBlockPromise = function(depBlock, outputOptions, requestShortener, name) {
+DepBlockHelpers.getDepBlockPromise = (depBlock, outputOptions, requestShortener, name) => {
if(depBlock.chunks) {
- var chunks = depBlock.chunks.filter(function(chunk) {
- return !chunk.hasRuntime() && chunk.id !== null;
- });
+ const chunks = depBlock.chunks.filter(chunk => !chunk.hasRuntime() && chunk.id !== null);
+ 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) {
- var 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${name}(${chunkId}${pathChunkCheck ? "/*! " + shortChunkName + " */" : ""}${chunkReason})`;
} else if(chunks.length > 0) {
- return "Promise.all" + asComment(name) + "(" +
- (outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : "") +
- "[" +
- chunks.map(function(chunk) {
- return "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")";
- }).join(", ") +
- "])";
+ return `Promise.all${name}(${pathChunkCheck ? "/*! " + shortChunkName + " */" : ""}[${chunks.map(requireChunkId).join(", ")}])`;
}
}
return "new Promise(function(resolve) { resolve(); })";
@@ -38,5 +35,5 @@ DepBlockHelpers.getDepBlockPromise = function(depBlock, outputOptions, requestSh function asComment(str) {
if(!str) return "";
- return "/* " + str + " */";
+ return `/* ${str} */`;
}
|