diff --git a/lib/JsonpMainTemplatePlugin.js b/lib/JsonpMainTemplatePlugin.js index a8ac8968ef9..a1e2217914a 100644 --- a/lib/JsonpMainTemplatePlugin.js +++ b/lib/JsonpMainTemplatePlugin.js @@ -92,10 +92,8 @@ JsonpMainTemplatePlugin.prototype.apply = function(mainTemplate) { "return installedChunks[chunkId][2];" ]), "}", - "// start chunk loading", - "var head = document.getElementsByTagName('head')[0];", - this.applyPluginsWaterfall("jsonp-script", "", chunk, hash), "", + "// setup Promise in chunk cache", "var promise = new Promise(function(resolve, reject) {", this.indent([ "installedChunks[chunkId] = [resolve, reject];" @@ -103,7 +101,11 @@ JsonpMainTemplatePlugin.prototype.apply = function(mainTemplate) { "});", "installedChunks[chunkId][2] = promise;", "", + "// start chunk loading", + "var head = document.getElementsByTagName('head')[0];", + this.applyPluginsWaterfall("jsonp-script", "", chunk, hash), "head.appendChild(script);", + "", "return promise;" ]); }); diff --git a/test/statsCases/aggressive-splitting-on-demand/expected.txt b/test/statsCases/aggressive-splitting-on-demand/expected.txt index 5efeec84f75..b8c6df14fff 100644 --- a/test/statsCases/aggressive-splitting-on-demand/expected.txt +++ b/test/statsCases/aggressive-splitting-on-demand/expected.txt @@ -6,7 +6,7 @@ cd45585186d59208602b.js 1.96 kB 1 [emitted] 6b94c231e016c5aaccdb.js 1.94 kB 2 [emitted] fd0985cee894c4f3f1a6.js 1.94 kB 3 [emitted] d9fc46873c8ea924b895.js 979 bytes 4 [emitted] -beecea47f9a8ded3c298.js 7.41 kB 6 [emitted] main +beecea47f9a8ded3c298.js 7.46 kB 6 [emitted] main b08c507d4e1e05cbab45.js 985 bytes 9 [emitted] 5d50e858fe6e559aa47c.js 977 bytes 11 [emitted] Entrypoint main = beecea47f9a8ded3c298.js diff --git a/test/statsCases/chunks/expected.txt b/test/statsCases/chunks/expected.txt index 1e62ebe1ea4..701eec11d57 100644 --- a/test/statsCases/chunks/expected.txt +++ b/test/statsCases/chunks/expected.txt @@ -4,7 +4,7 @@ Time: Xms 0.bundle.js 238 bytes 0 [emitted] 1.bundle.js 108 bytes 1 [emitted] 2.bundle.js 204 bytes 2 [emitted] - bundle.js 6.05 kB 3 [emitted] main + bundle.js 6.1 kB 3 [emitted] main chunk {0} 0.bundle.js 54 bytes {3} [rendered] > [5] (webpack)/test/statsCases/chunks/index.js 3:0-16 [2] (webpack)/test/statsCases/chunks/c.js 54 bytes {0} [built] diff --git a/test/statsCases/commons-chunk-min-size-0/expected.txt b/test/statsCases/commons-chunk-min-size-0/expected.txt index 82bc8923530..f265ca90ae5 100644 --- a/test/statsCases/commons-chunk-min-size-0/expected.txt +++ b/test/statsCases/commons-chunk-min-size-0/expected.txt @@ -2,7 +2,7 @@ Hash: dc6038bec87a57d1a45e Time: Xms Asset Size Chunks Chunk Names entry-1.js 25 bytes 0 [emitted] entry-1 -vendor-1.js 6.7 kB 1 [emitted] vendor-1 +vendor-1.js 6.76 kB 1 [emitted] vendor-1 chunk {0} entry-1.js (entry-1) 0 bytes {1} [initial] [rendered] chunk {1} vendor-1.js (vendor-1) 329 bytes [entry] [rendered] [0] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/a.js 22 bytes {1} [built] diff --git a/test/statsCases/limit-chunk-count-plugin/expected.txt b/test/statsCases/limit-chunk-count-plugin/expected.txt index 476fccda650..f982522a6ba 100644 --- a/test/statsCases/limit-chunk-count-plugin/expected.txt +++ b/test/statsCases/limit-chunk-count-plugin/expected.txt @@ -16,7 +16,7 @@ Child Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 592 bytes 0 [emitted] - bundle.js 6.06 kB 1 [emitted] main + bundle.js 6.12 kB 1 [emitted] main chunk {0} 0.bundle.js 118 bytes {1} [rendered] [0] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/b.js 22 bytes {0} [built] @@ -31,7 +31,7 @@ Child Asset Size Chunks Chunk Names 0.bundle.js 445 bytes 0 [emitted] 1.bundle.js 204 bytes 1 [emitted] - bundle.js 6.05 kB 2 [emitted] main + bundle.js 6.11 kB 2 [emitted] main chunk {0} 0.bundle.js 74 bytes {2} [rendered] [0] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] [2] (webpack)/test/statsCases/limit-chunk-count-plugin/c.js 30 bytes {0} [built] @@ -48,7 +48,7 @@ Child 0.bundle.js 204 bytes 0 [emitted] 1.bundle.js 195 bytes 1 [emitted] 2.bundle.js 283 bytes 2 [emitted] - bundle.js 6.04 kB 3 [emitted] main + bundle.js 6.09 kB 3 [emitted] main chunk {0} 0.bundle.js 44 bytes {2} {3} [rendered] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/b.js 22 bytes {0} [built] [4] (webpack)/test/statsCases/limit-chunk-count-plugin/e.js 22 bytes {0} [built] diff --git a/test/statsCases/optimize-chunks/expected.txt b/test/statsCases/optimize-chunks/expected.txt index 40c4a20975f..0e3075f27c8 100644 --- a/test/statsCases/optimize-chunks/expected.txt +++ b/test/statsCases/optimize-chunks/expected.txt @@ -8,7 +8,7 @@ Time: Xms 4.js 140 bytes 4, 6 [emitted] chunk 5.js 306 bytes 5, 3 [emitted] cir2 from cir1 6.js 80 bytes 6 [emitted] ac in ab -main.js 6.72 kB 7 [emitted] main +main.js 6.77 kB 7 [emitted] main chunk {0} 0.js (cir1) 81 bytes {3} {5} {7} [rendered] > duplicate cir1 from cir2 [3] (webpack)/test/statsCases/optimize-chunks/circular2.js 1:0-79 > duplicate cir1 [7] (webpack)/test/statsCases/optimize-chunks/index.js 13:0-54 diff --git a/test/statsCases/preset-verbose/expected.txt b/test/statsCases/preset-verbose/expected.txt index 4a4151e0da7..4715dd1f7b4 100644 --- a/test/statsCases/preset-verbose/expected.txt +++ b/test/statsCases/preset-verbose/expected.txt @@ -4,7 +4,7 @@ Time: Xms 0.js 238 bytes 0 [emitted] 1.js 108 bytes 1 [emitted] 2.js 204 bytes 2 [emitted] -main.js 6.04 kB 3 [emitted] main +main.js 6.09 kB 3 [emitted] main Entrypoint main = main.js chunk {0} 0.js 54 bytes {3} [rendered] [2] (webpack)/test/statsCases/preset-verbose/c.js 54 bytes {0} [depth 1] [built]