diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-05-03 15:35:00 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-05-03 15:35:00 +0200 |
commit | de98e0b232509d5f40c135d540a70e415272ff85 (patch) | |
tree | a79222a5b58484ab3b80d18efcaaa7ccc4769b33 /node_modules/webpack/lib/dependencies/DepBlockHelpers.js | |
parent | e0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff) |
node_modules
Diffstat (limited to 'node_modules/webpack/lib/dependencies/DepBlockHelpers.js')
-rw-r--r-- | node_modules/webpack/lib/dependencies/DepBlockHelpers.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/node_modules/webpack/lib/dependencies/DepBlockHelpers.js b/node_modules/webpack/lib/dependencies/DepBlockHelpers.js new file mode 100644 index 000000000..aef63fded --- /dev/null +++ b/node_modules/webpack/lib/dependencies/DepBlockHelpers.js @@ -0,0 +1,42 @@ +/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+var DepBlockHelpers = exports;
+
+DepBlockHelpers.getLoadDepBlockWrapper = function(depBlock, outputOptions, requestShortener, name) {
+ var promiseCode = DepBlockHelpers.getDepBlockPromise(depBlock, outputOptions, requestShortener, name);
+ return [
+ promiseCode + ".then(",
+ ").catch(",
+ ")"
+ ];
+};
+
+DepBlockHelpers.getDepBlockPromise = function(depBlock, outputOptions, requestShortener, name) {
+ if(depBlock.chunks) {
+ var chunks = depBlock.chunks.filter(function(chunk) {
+ return !chunk.hasRuntime() && chunk.id !== null;
+ });
+ 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) + ")";
+ } 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.resolve()";
+};
+
+function asComment(str) {
+ if(!str) return "";
+ return "/* " + str + " */";
+}
|