From 9732e371c20a808fce845009dff8c0f946288325 Mon Sep 17 00:00:00 2001 From: Robo Burned Date: Mon, 9 Oct 2017 14:20:20 +0400 Subject: [PATCH 01/85] Display file size in kibibytes in statistics. Fix #5769 --- lib/SizeFormatHelpers.js | 6 ++--- test/SizeFormatHelpers.test.js | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 test/SizeFormatHelpers.test.js diff --git a/lib/SizeFormatHelpers.js b/lib/SizeFormatHelpers.js index 4591d08c8..aaa517e5e 100644 --- a/lib/SizeFormatHelpers.js +++ b/lib/SizeFormatHelpers.js @@ -11,8 +11,8 @@ SizeFormatHelpers.formatSize = size => { return "0 bytes"; } - const abbreviations = ["bytes", "kB", "MB", "GB"]; - const index = Math.floor(Math.log(size) / Math.log(1000)); + const abbreviations = ["bytes", "KiB", "MiB", "GiB"]; + const index = Math.floor(Math.log(size) / Math.log(1024)); - return `${+(size / Math.pow(1000, index)).toPrecision(3)} ${abbreviations[index]}`; + return `${+(size / Math.pow(1024, index)).toPrecision(3)} ${abbreviations[index]}`; }; diff --git a/test/SizeFormatHelpers.test.js b/test/SizeFormatHelpers.test.js new file mode 100644 index 000000000..988a02624 --- /dev/null +++ b/test/SizeFormatHelpers.test.js @@ -0,0 +1,41 @@ +/* globals describe, it, beforeEach */ +"use strict"; + +const should = require("should"); +const SizeFormatHelpers = require("../lib/SizeFormatHelpers"); + +describe("SizeFormatHelpers", () => { + describe("formatSize", () => { + it("should handle zero size", () => { + should(SizeFormatHelpers.formatSize(0)).be.eql("0 bytes"); + }); + + it("should handle bytes", () => { + should(SizeFormatHelpers.formatSize(1000)).be.eql("1000 bytes"); + }); + + it("should handle integer kibibytes", () => { + should(SizeFormatHelpers.formatSize(2048)).be.eql("2 KiB"); + }); + + it("should handle float kibibytes", () => { + should(SizeFormatHelpers.formatSize(2560)).be.eql("2.5 KiB"); + }); + + it("should handle integer mebibytes", () => { + should(SizeFormatHelpers.formatSize(10 * 1024 * 1024)).be.eql("10 MiB"); + }); + + it("should handle float mebibytes", () => { + should(SizeFormatHelpers.formatSize(12.5 * 1024 * 1024)).be.eql("12.5 MiB"); + }); + + it("should handle integer gibibytes", () => { + should(SizeFormatHelpers.formatSize(3 * 1024 * 1024 * 1024)).be.eql("3 GiB"); + }); + + it("should handle float gibibytes", () => { + should(SizeFormatHelpers.formatSize(1.2 * 1024 * 1024 * 1024)).be.eql("1.2 GiB"); + }); + }); +}); From 4cc3832926f23df37115e1083ad1227384597a8a Mon Sep 17 00:00:00 2001 From: Robo Burned Date: Mon, 9 Oct 2017 14:20:53 +0400 Subject: [PATCH 02/85] Update tests to match file size in kibibytes. --- .../aggressive-splitting-entry/expected.txt | 12 ++--- .../expected.txt | 18 +++---- test/statsCases/chunks/expected.txt | 2 +- test/statsCases/color-disabled/expected.txt | 4 +- .../color-enabled-custom/expected.txt | 4 +- test/statsCases/color-enabled/expected.txt | 4 +- .../commons-chunk-min-size-0/expected.txt | 2 +- .../expected.txt | 6 +-- .../commons-plugin-issue-4980/expected.txt | 8 +-- test/statsCases/define-plugin/expected.txt | 8 +-- .../exclude-with-loader/expected.txt | 4 +- test/statsCases/external/expected.txt | 4 +- test/statsCases/filter-warnings/expected.txt | 52 +++++++++---------- test/statsCases/import-weak/expected.txt | 2 +- .../limit-chunk-count-plugin/expected.txt | 10 ++-- .../max-modules-default/expected.txt | 4 +- test/statsCases/max-modules/expected.txt | 4 +- .../expected.txt | 4 +- .../expected.txt | 4 +- .../named-chunks-plugin-async/expected.txt | 2 +- .../named-chunks-plugin/expected.txt | 2 +- test/statsCases/optimize-chunks/expected.txt | 2 +- .../performance-disabled/expected.txt | 4 +- .../statsCases/performance-error/expected.txt | 12 ++--- .../expected.txt | 16 +++--- .../performance-no-hints/expected.txt | 4 +- .../expected.txt | 20 +++---- test/statsCases/preset-detailed/expected.txt | 2 +- .../expected.txt | 14 ++--- .../preset-normal-performance/expected.txt | 12 ++--- test/statsCases/preset-normal/expected.txt | 2 +- test/statsCases/preset-verbose/expected.txt | 2 +- .../resolve-plugin-context/expected.txt | 4 +- .../reverse-sort-modules/expected.txt | 4 +- .../separate-css-bundle/expected.txt | 20 +++---- test/statsCases/simple-more-info/expected.txt | 4 +- test/statsCases/simple/expected.txt | 4 +- test/statsCases/tree-shaking/expected.txt | 4 +- .../statsCases/warnings-uglifyjs/expected.txt | 4 +- 39 files changed, 147 insertions(+), 147 deletions(-) diff --git a/test/statsCases/aggressive-splitting-entry/expected.txt b/test/statsCases/aggressive-splitting-entry/expected.txt index fff900916..f7fb9f143 100644 --- a/test/statsCases/aggressive-splitting-entry/expected.txt +++ b/test/statsCases/aggressive-splitting-entry/expected.txt @@ -1,21 +1,21 @@ Hash: c4756fe25e35ccb187f7 Time: Xms Asset Size Chunks Chunk Names -48c8b1dae03a37363ec8.js 4.2 kB 1 [emitted] -002fc3bb6fc14459f8e8.js 2.23 kB 2 [emitted] -9356e9a0fb00a97b2e73.js 1.94 kB 3 [emitted] +48c8b1dae03a37363ec8.js 4.1 KiB 1 [emitted] +002fc3bb6fc14459f8e8.js 2.17 KiB 2 [emitted] +9356e9a0fb00a97b2e73.js 1.89 KiB 3 [emitted] 88d78642a86768757078.js 979 bytes 4 [emitted] Entrypoint main = 48c8b1dae03a37363ec8.js 9356e9a0fb00a97b2e73.js 88d78642a86768757078.js 002fc3bb6fc14459f8e8.js -chunk {1} 48c8b1dae03a37363ec8.js 1.8 kB [entry] [rendered] +chunk {1} 48c8b1dae03a37363ec8.js 1.76 KiB [entry] [rendered] > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [0] (webpack)/test/statsCases/aggressive-splitting-entry/b.js 899 bytes {1} [built] [1] (webpack)/test/statsCases/aggressive-splitting-entry/c.js 899 bytes {1} [built] -chunk {2} 002fc3bb6fc14459f8e8.js 1.91 kB [initial] [rendered] +chunk {2} 002fc3bb6fc14459f8e8.js 1.87 KiB [initial] [rendered] > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js 112 bytes {2} [built] [6] (webpack)/test/statsCases/aggressive-splitting-entry/f.js 899 bytes {2} [built] [7] (webpack)/test/statsCases/aggressive-splitting-entry/g.js 899 bytes {2} [built] -chunk {3} 9356e9a0fb00a97b2e73.js 1.8 kB [initial] [rendered] [recorded] +chunk {3} 9356e9a0fb00a97b2e73.js 1.76 KiB [initial] [rendered] [recorded] > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [2] (webpack)/test/statsCases/aggressive-splitting-entry/d.js 899 bytes {3} [built] [5] (webpack)/test/statsCases/aggressive-splitting-entry/a.js 899 bytes {3} [built] diff --git a/test/statsCases/aggressive-splitting-on-demand/expected.txt b/test/statsCases/aggressive-splitting-on-demand/expected.txt index c37ff156d..782732a17 100644 --- a/test/statsCases/aggressive-splitting-on-demand/expected.txt +++ b/test/statsCases/aggressive-splitting-on-demand/expected.txt @@ -1,33 +1,33 @@ Hash: 3605a628ea012f7d12ca Time: Xms Asset Size Chunks Chunk Names -fc930a2adf8206ea2dc5.js 1.94 kB 0 [emitted] -cd45585186d59208602b.js 1.96 kB 1 [emitted] -6b94c231e016c5aaccdb.js 1.94 kB 2 [emitted] -fd0985cee894c4f3f1a6.js 1.94 kB 3 [emitted] +fc930a2adf8206ea2dc5.js 1.89 KiB 0 [emitted] +cd45585186d59208602b.js 1.91 KiB 1 [emitted] +6b94c231e016c5aaccdb.js 1.89 KiB 2 [emitted] +fd0985cee894c4f3f1a6.js 1.89 KiB 3 [emitted] d9fc46873c8ea924b895.js 979 bytes 4 [emitted] -a773fee259e5a284dea9.js 7.47 kB 6 [emitted] main +a773fee259e5a284dea9.js 7.29 KiB 6 [emitted] main b08c507d4e1e05cbab45.js 985 bytes 9 [emitted] 5d50e858fe6e559aa47c.js 977 bytes 11 [emitted] Entrypoint main = a773fee259e5a284dea9.js -chunk {0} fc930a2adf8206ea2dc5.js 1.8 kB {6} +chunk {0} fc930a2adf8206ea2dc5.js 1.76 KiB {6} > aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 4:0-51 > aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 5:0-44 > aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72 [5] (webpack)/test/statsCases/aggressive-splitting-on-demand/f.js 899 bytes {0} [built] [6] (webpack)/test/statsCases/aggressive-splitting-on-demand/g.js 901 bytes {0} [built] -chunk {1} cd45585186d59208602b.js 1.8 kB {6} [recorded] +chunk {1} cd45585186d59208602b.js 1.76 KiB {6} [recorded] > aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 3:0-30 > aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 5:0-44 > aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72 [3] (webpack)/test/statsCases/aggressive-splitting-on-demand/d.js 899 bytes {1} [built] [4] (webpack)/test/statsCases/aggressive-splitting-on-demand/e.js 899 bytes {1} [built] -chunk {2} 6b94c231e016c5aaccdb.js 1.8 kB {6} +chunk {2} 6b94c231e016c5aaccdb.js 1.76 KiB {6} > aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 4:0-51 > aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72 [10] (webpack)/test/statsCases/aggressive-splitting-on-demand/j.js 901 bytes {2} [built] [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/k.js 899 bytes {2} [built] -chunk {3} fd0985cee894c4f3f1a6.js 1.8 kB {6} [recorded] +chunk {3} fd0985cee894c4f3f1a6.js 1.76 KiB {6} [recorded] > aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 4:0-51 > aggressive-splitted duplicate [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72 [7] (webpack)/test/statsCases/aggressive-splitting-on-demand/h.js 899 bytes {3} [built] diff --git a/test/statsCases/chunks/expected.txt b/test/statsCases/chunks/expected.txt index 4d539f6d9..c8be3cab4 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 102 bytes 1 [emitted] 2.bundle.js 182 bytes 2 [emitted] - bundle.js 6.1 kB 3 [emitted] main + bundle.js 5.96 KiB 3 [emitted] main chunk {0} 0.bundle.js 54 bytes {3} [rendered] > [0] (webpack)/test/statsCases/chunks/index.js 3:0-16 [3] (webpack)/test/statsCases/chunks/c.js 54 bytes {0} [built] diff --git a/test/statsCases/color-disabled/expected.txt b/test/statsCases/color-disabled/expected.txt index 9e18644ea..43c5c037e 100644 --- a/test/statsCases/color-disabled/expected.txt +++ b/test/statsCases/color-disabled/expected.txt @@ -1,5 +1,5 @@ Hash: 6c781fe6bf412ba6435b Time: Xms - Asset Size Chunks Chunk Names -main.js 2.47 kB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 2.42 KiB 0 [emitted] main [0] (webpack)/test/statsCases/color-disabled/index.js 0 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/color-enabled-custom/expected.txt b/test/statsCases/color-enabled-custom/expected.txt index f14fd735e..5d89e53a9 100644 --- a/test/statsCases/color-enabled-custom/expected.txt +++ b/test/statsCases/color-enabled-custom/expected.txt @@ -1,5 +1,5 @@ Hash: 6c781fe6bf412ba6435b Time: Xms - Asset Size Chunks Chunk Names -main.js 2.47 kB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 2.42 KiB 0 [emitted] main [0] (webpack)/test/statsCases/color-enabled-custom/index.js 0 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/color-enabled/expected.txt b/test/statsCases/color-enabled/expected.txt index a9ee8d254..ab2d02c0a 100644 --- a/test/statsCases/color-enabled/expected.txt +++ b/test/statsCases/color-enabled/expected.txt @@ -1,5 +1,5 @@ Hash: 6c781fe6bf412ba6435b Time: Xms - Asset Size Chunks Chunk Names -main.js 2.47 kB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 2.42 KiB 0 [emitted] main [0] (webpack)/test/statsCases/color-enabled/index.js 0 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/commons-chunk-min-size-0/expected.txt b/test/statsCases/commons-chunk-min-size-0/expected.txt index 0673e9ea2..146b0ea46 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.76 kB 1 [emitted] vendor-1 +vendor-1.js 6.61 KiB 1 [emitted] vendor-1 [0] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/a.js 22 bytes {1} [built] [1] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/b.js 22 bytes {1} [built] [2] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/c.js 22 bytes {1} [built] diff --git a/test/statsCases/commons-chunk-min-size-Infinity/expected.txt b/test/statsCases/commons-chunk-min-size-Infinity/expected.txt index 604973f76..5570e04c8 100644 --- a/test/statsCases/commons-chunk-min-size-Infinity/expected.txt +++ b/test/statsCases/commons-chunk-min-size-Infinity/expected.txt @@ -1,8 +1,8 @@ Hash: 9c0d5be5c7febb314e7a Time: Xms - Asset Size Chunks Chunk Names - entry-1.js 3.11 kB 0 [emitted] entry-1 -vendor-1.js 2.85 kB 1 [emitted] vendor-1 + Asset Size Chunks Chunk Names + entry-1.js 3.03 KiB 0 [emitted] entry-1 +vendor-1.js 2.79 KiB 1 [emitted] vendor-1 [0] (webpack)/test/statsCases/commons-chunk-min-size-Infinity/modules/a.js 22 bytes {0} {1} [built] [1] (webpack)/test/statsCases/commons-chunk-min-size-Infinity/modules/b.js 22 bytes {0} {1} [built] [2] (webpack)/test/statsCases/commons-chunk-min-size-Infinity/modules/c.js 22 bytes {0} {1} [built] diff --git a/test/statsCases/commons-plugin-issue-4980/expected.txt b/test/statsCases/commons-plugin-issue-4980/expected.txt index 36d2ebbe8..4a755d260 100644 --- a/test/statsCases/commons-plugin-issue-4980/expected.txt +++ b/test/statsCases/commons-plugin-issue-4980/expected.txt @@ -3,9 +3,9 @@ Child Hash: 7d3a56317b2e339b1d82 Time: Xms Asset Size Chunks Chunk Names - app.js 1.27 kB 0 [emitted] app + app.js 1.24 KiB 0 [emitted] app vendor.bd2b4219dfda1a951495.js 443 bytes 1 [emitted] vendor - runtime.js 5.78 kB 2 [emitted] runtime + runtime.js 5.64 KiB 2 [emitted] runtime [./constants.js] (webpack)/test/statsCases/commons-plugin-issue-4980/constants.js 87 bytes {1} [built] [./entry-1.js] (webpack)/test/statsCases/commons-plugin-issue-4980/entry-1.js 67 bytes {0} [built] [./submodule-a.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-a.js 59 bytes {0} [built] @@ -14,9 +14,9 @@ Child Hash: 2897fe6052020598632c Time: Xms Asset Size Chunks Chunk Names - app.js 1.32 kB 0 [emitted] app + app.js 1.29 KiB 0 [emitted] app vendor.bd2b4219dfda1a951495.js 443 bytes 1 [emitted] vendor - runtime.js 5.78 kB 2 [emitted] runtime + runtime.js 5.64 KiB 2 [emitted] runtime [./constants.js] (webpack)/test/statsCases/commons-plugin-issue-4980/constants.js 87 bytes {1} [built] [./entry-2.js] (webpack)/test/statsCases/commons-plugin-issue-4980/entry-2.js 67 bytes {0} [built] [./submodule-a.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-a.js 59 bytes {0} [built] diff --git a/test/statsCases/define-plugin/expected.txt b/test/statsCases/define-plugin/expected.txt index bc25d5d7a..498857a61 100644 --- a/test/statsCases/define-plugin/expected.txt +++ b/test/statsCases/define-plugin/expected.txt @@ -2,12 +2,12 @@ Hash: 052d0451a89cb963e4d3eb3ff8e5a88b9234d04f Child Hash: 052d0451a89cb963e4d3 Time: Xms - Asset Size Chunks Chunk Names - main.js 2.52 kB 0 [emitted] main + Asset Size Chunks Chunk Names + main.js 2.46 KiB 0 [emitted] main [0] (webpack)/test/statsCases/define-plugin/index.js 24 bytes {0} [built] Child Hash: eb3ff8e5a88b9234d04f Time: Xms - Asset Size Chunks Chunk Names - main.js 2.52 kB 0 [emitted] main + Asset Size Chunks Chunk Names + main.js 2.46 KiB 0 [emitted] main [0] (webpack)/test/statsCases/define-plugin/index.js 24 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/exclude-with-loader/expected.txt b/test/statsCases/exclude-with-loader/expected.txt index ac9ade187..2b0cde6ef 100644 --- a/test/statsCases/exclude-with-loader/expected.txt +++ b/test/statsCases/exclude-with-loader/expected.txt @@ -1,7 +1,7 @@ Hash: 14e131b4e5c91ed5ce4a Time: Xms - Asset Size Chunks Chunk Names -bundle.js 2.92 kB 0 [emitted] main + Asset Size Chunks Chunk Names +bundle.js 2.85 KiB 0 [emitted] main + 1 hidden asset [0] (webpack)/test/statsCases/exclude-with-loader/index.js 77 bytes {0} [built] [1] (webpack)/test/statsCases/exclude-with-loader/a.txt 43 bytes {0} [built] diff --git a/test/statsCases/external/expected.txt b/test/statsCases/external/expected.txt index 740170c2e..8fe332f26 100644 --- a/test/statsCases/external/expected.txt +++ b/test/statsCases/external/expected.txt @@ -1,6 +1,6 @@ Hash: e500321cbaac14df7284 Time: Xms - Asset Size Chunks Chunk Names -main.js 2.61 kB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 2.55 KiB 0 [emitted] main [0] (webpack)/test/statsCases/external/index.js 17 bytes {0} [built] [1] external "test" 42 bytes {0} [not cacheable] \ No newline at end of file diff --git a/test/statsCases/filter-warnings/expected.txt b/test/statsCases/filter-warnings/expected.txt index 37608dea4..2acede782 100644 --- a/test/statsCases/filter-warnings/expected.txt +++ b/test/statsCases/filter-warnings/expected.txt @@ -2,8 +2,8 @@ Hash: 3cc7bf529a74b021bee53cc7bf529a74b021bee53cc7bf529a74b021bee53cc7bf529a74b0 Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs Dropping side-effect-free statement [./index.js:6,0] @@ -20,38 +20,38 @@ Child Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs Dropping side-effect-free statement [./index.js:6,0] @@ -68,8 +68,8 @@ Child Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs Dropping side-effect-free statement [./index.js:6,0] @@ -86,8 +86,8 @@ Child Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs Dropping side-effect-free statement [./index.js:6,0] @@ -104,8 +104,8 @@ Child Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs Dropping side-effect-free statement [./index.js:6,0] @@ -122,8 +122,8 @@ Child Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs Dropping side-effect-free statement [./index.js:6,0] @@ -140,8 +140,8 @@ Child Child Hash: 3cc7bf529a74b021bee5 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs Dropping side-effect-free statement [./index.js:6,0] diff --git a/test/statsCases/import-weak/expected.txt b/test/statsCases/import-weak/expected.txt index 00282baa3..18c85a42b 100644 --- a/test/statsCases/import-weak/expected.txt +++ b/test/statsCases/import-weak/expected.txt @@ -2,7 +2,7 @@ Hash: d34cc0bd2faeb65c3282 Time: Xms Asset Size Chunks Chunk Names 0.js 99 bytes 0 [emitted] -entry.js 6.22 kB 1 [emitted] entry +entry.js 6.07 KiB 1 [emitted] entry [0] (webpack)/test/statsCases/import-weak/modules/b.js 22 bytes {0} [built] [1] (webpack)/test/statsCases/import-weak/entry.js 120 bytes {1} [built] [2] (webpack)/test/statsCases/import-weak/modules/a.js 37 bytes [built] \ No newline at end of file diff --git a/test/statsCases/limit-chunk-count-plugin/expected.txt b/test/statsCases/limit-chunk-count-plugin/expected.txt index e020942cc..80d013a50 100644 --- a/test/statsCases/limit-chunk-count-plugin/expected.txt +++ b/test/statsCases/limit-chunk-count-plugin/expected.txt @@ -2,8 +2,8 @@ Hash: e0c3e190f6cf11c37f15b34fa5f72acbbc9cbd9a404c277a8869b8a6a62e5c32ec6fc2ff40 Child Hash: e0c3e190f6cf11c37f15 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 3.4 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 3.32 KiB 0 [emitted] main chunk {0} bundle.js (main) 191 bytes [entry] [rendered] [0] (webpack)/test/statsCases/limit-chunk-count-plugin/index.js 73 bytes {0} [built] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] @@ -16,7 +16,7 @@ Child Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 601 bytes 0 [emitted] - bundle.js 6.12 kB 1 [emitted] main + bundle.js 5.98 KiB 1 [emitted] main chunk {0} 0.bundle.js 118 bytes {1} [rendered] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] [2] (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 454 bytes 0 [emitted] 1.bundle.js 182 bytes 1 [emitted] - bundle.js 6.11 kB 2 [emitted] main + bundle.js 5.97 KiB 2 [emitted] main chunk {0} 0.bundle.js 74 bytes {2} [rendered] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] [3] (webpack)/test/statsCases/limit-chunk-count-plugin/c.js 30 bytes {0} [built] @@ -48,7 +48,7 @@ Child 0.bundle.js 182 bytes 0 [emitted] 1.bundle.js 204 bytes 1 [emitted] 2.bundle.js 283 bytes 2 [emitted] - bundle.js 6.1 kB 3 [emitted] main + bundle.js 5.96 KiB 3 [emitted] main chunk {0} 0.bundle.js 44 bytes {2} {3} [rendered] [2] (webpack)/test/statsCases/limit-chunk-count-plugin/b.js 22 bytes {0} [built] [5] (webpack)/test/statsCases/limit-chunk-count-plugin/e.js 22 bytes {0} [built] diff --git a/test/statsCases/max-modules-default/expected.txt b/test/statsCases/max-modules-default/expected.txt index e4cee1b02..cb8301beb 100644 --- a/test/statsCases/max-modules-default/expected.txt +++ b/test/statsCases/max-modules-default/expected.txt @@ -1,7 +1,7 @@ Hash: b70eb677e8a8b3694c25 Time: Xms - Asset Size Chunks Chunk Names -main.js 5.79 kB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 5.65 KiB 0 [emitted] main [0] (webpack)/test/statsCases/max-modules-default/a.js?1 33 bytes {0} [built] [1] (webpack)/test/statsCases/max-modules-default/a.js?2 33 bytes {0} [built] [2] (webpack)/test/statsCases/max-modules-default/a.js?3 33 bytes {0} [built] diff --git a/test/statsCases/max-modules/expected.txt b/test/statsCases/max-modules/expected.txt index 9303956d2..4b9c4602c 100644 --- a/test/statsCases/max-modules/expected.txt +++ b/test/statsCases/max-modules/expected.txt @@ -1,7 +1,7 @@ Hash: b70eb677e8a8b3694c25 Time: Xms - Asset Size Chunks Chunk Names -main.js 5.79 kB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 5.65 KiB 0 [emitted] main [0] (webpack)/test/statsCases/max-modules/a.js?1 33 bytes {0} [built] [1] (webpack)/test/statsCases/max-modules/a.js?2 33 bytes {0} [built] [2] (webpack)/test/statsCases/max-modules/a.js?3 33 bytes {0} [built] diff --git a/test/statsCases/module-trace-disabled-in-error/expected.txt b/test/statsCases/module-trace-disabled-in-error/expected.txt index 0058796ae..eabea074b 100644 --- a/test/statsCases/module-trace-disabled-in-error/expected.txt +++ b/test/statsCases/module-trace-disabled-in-error/expected.txt @@ -1,6 +1,6 @@ Time: Xms - Asset Size Chunks Chunk Names -main.js 2.65 kB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 2.59 KiB 0 [emitted] main [0] (webpack)/test/statsCases/module-trace-disabled-in-error/index.js 25 bytes {0} [built] ERROR in (webpack)/test/statsCases/module-trace-disabled-in-error/index.js diff --git a/test/statsCases/module-trace-enabled-in-error/expected.txt b/test/statsCases/module-trace-enabled-in-error/expected.txt index de33078eb..02a8bf64b 100644 --- a/test/statsCases/module-trace-enabled-in-error/expected.txt +++ b/test/statsCases/module-trace-enabled-in-error/expected.txt @@ -1,6 +1,6 @@ Time: Xms - Asset Size Chunks Chunk Names -main.js 2.65 kB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 2.59 KiB 0 [emitted] main [0] (webpack)/test/statsCases/module-trace-enabled-in-error/index.js 25 bytes {0} [built] ERROR in (webpack)/test/statsCases/module-trace-enabled-in-error/index.js diff --git a/test/statsCases/named-chunks-plugin-async/expected.txt b/test/statsCases/named-chunks-plugin-async/expected.txt index 809ff0492..32cb5b2b2 100644 --- a/test/statsCases/named-chunks-plugin-async/expected.txt +++ b/test/statsCases/named-chunks-plugin-async/expected.txt @@ -3,7 +3,7 @@ Time: Xms Asset Size Chunks Chunk Names chunk-containing-__a_js.js 266 bytes chunk-containing-__a_js [emitted] chunk-containing-__b_js.js 123 bytes chunk-containing-__b_js [emitted] - entry.js 5.99 kB entry [emitted] entry + entry.js 5.85 KiB entry [emitted] entry [0] (webpack)/test/statsCases/named-chunks-plugin-async/modules/b.js 22 bytes {chunk-containing-__b_js} [built] [1] (webpack)/test/statsCases/named-chunks-plugin-async/entry.js 47 bytes {entry} [built] [2] (webpack)/test/statsCases/named-chunks-plugin-async/modules/a.js 37 bytes {chunk-containing-__a_js} [built] \ No newline at end of file diff --git a/test/statsCases/named-chunks-plugin/expected.txt b/test/statsCases/named-chunks-plugin/expected.txt index e19f2054f..f6ef83e95 100644 --- a/test/statsCases/named-chunks-plugin/expected.txt +++ b/test/statsCases/named-chunks-plugin/expected.txt @@ -2,7 +2,7 @@ Hash: ac63e5be974bcdfea3a3 Time: Xms Asset Size Chunks Chunk Names entry.js 345 bytes entry [emitted] entry -manifest.js 5.78 kB manifest [emitted] manifest +manifest.js 5.65 KiB manifest [emitted] manifest vendor.js 397 bytes vendor [emitted] vendor [0] multi ./modules/a ./modules/b 40 bytes {vendor} [built] [./entry.js] (webpack)/test/statsCases/named-chunks-plugin/entry.js 72 bytes {entry} [built] diff --git a/test/statsCases/optimize-chunks/expected.txt b/test/statsCases/optimize-chunks/expected.txt index 9a932b565..0b7ed0ecd 100644 --- a/test/statsCases/optimize-chunks/expected.txt +++ b/test/statsCases/optimize-chunks/expected.txt @@ -8,7 +8,7 @@ Time: Xms 4.js 162 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.78 kB 7 [emitted] main +main.js 6.62 KiB 7 [emitted] main chunk {0} 0.js (cir1) 81 bytes {3} {5} {7} [rendered] > duplicate cir1 from cir2 [6] (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/performance-disabled/expected.txt b/test/statsCases/performance-disabled/expected.txt index 8c700e931..0a5a044c2 100644 --- a/test/statsCases/performance-disabled/expected.txt +++ b/test/statsCases/performance-disabled/expected.txt @@ -3,10 +3,10 @@ Time: Xms 0.js 238 bytes 0 [emitted] 1.js 102 bytes 1 [emitted] 2.js 182 bytes 2 [emitted] -main.js 306 kB 3 [emitted] main +main.js 299 KiB 3 [emitted] main Entrypoint main = main.js [0] (webpack)/test/statsCases/performance-disabled/index.js 52 bytes {3} [built] - [1] (webpack)/test/statsCases/performance-disabled/a.js 300 kB {3} [built] + [1] (webpack)/test/statsCases/performance-disabled/a.js 293 KiB {3} [built] [2] (webpack)/test/statsCases/performance-disabled/b.js 22 bytes {1} [built] [3] (webpack)/test/statsCases/performance-disabled/c.js 54 bytes {0} [built] [4] (webpack)/test/statsCases/performance-disabled/d.js 22 bytes {2} [built] diff --git a/test/statsCases/performance-error/expected.txt b/test/statsCases/performance-error/expected.txt index 57c4f2d85..7fe70863d 100644 --- a/test/statsCases/performance-error/expected.txt +++ b/test/statsCases/performance-error/expected.txt @@ -3,22 +3,22 @@ Time: Xms 0.js 238 bytes 0 [emitted] 1.js 102 bytes 1 [emitted] 2.js 182 bytes 2 [emitted] -main.js 306 kB 3 [emitted] [big] main +main.js 299 KiB 3 [emitted] [big] main Entrypoint main [big] = main.js [0] (webpack)/test/statsCases/performance-error/index.js 52 bytes {3} [built] - [1] (webpack)/test/statsCases/performance-error/a.js 300 kB {3} [built] + [1] (webpack)/test/statsCases/performance-error/a.js 293 KiB {3} [built] [2] (webpack)/test/statsCases/performance-error/b.js 22 bytes {1} [built] [3] (webpack)/test/statsCases/performance-error/c.js 54 bytes {0} [built] [4] (webpack)/test/statsCases/performance-error/d.js 22 bytes {2} [built] [5] (webpack)/test/statsCases/performance-error/e.js 22 bytes {2} [built] -ERROR in asset size limit: The following asset(s) exceed the recommended size limit (250 kB). +ERROR in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB). This can impact web performance. Assets: - main.js (306 kB) + main.js (299 KiB) -ERROR in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (250 kB). This can impact web performance. +ERROR in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance. Entrypoints: - main (306 kB) + main (299 KiB) main.js \ No newline at end of file diff --git a/test/statsCases/performance-no-async-chunks-shown/expected.txt b/test/statsCases/performance-no-async-chunks-shown/expected.txt index 8ed34c516..ecfae72c3 100644 --- a/test/statsCases/performance-no-async-chunks-shown/expected.txt +++ b/test/statsCases/performance-no-async-chunks-shown/expected.txt @@ -1,24 +1,24 @@ Time: Xms - Asset Size Chunks Chunk Names - sec.js 2.82 kB 0 [emitted] sec -main.js 303 kB 1 [emitted] [big] main + Asset Size Chunks Chunk Names + sec.js 2.75 KiB 0 [emitted] sec +main.js 296 KiB 1 [emitted] [big] main Entrypoint main [big] = main.js Entrypoint sec = sec.js [0] (webpack)/test/statsCases/performance-no-async-chunks-shown/b.js 22 bytes {0} {1} [built] [1] (webpack)/test/statsCases/performance-no-async-chunks-shown/index.js 32 bytes {1} [built] - [2] (webpack)/test/statsCases/performance-no-async-chunks-shown/a.js 300 kB {1} [built] + [2] (webpack)/test/statsCases/performance-no-async-chunks-shown/a.js 293 KiB {1} [built] [3] (webpack)/test/statsCases/performance-no-async-chunks-shown/index2.js 48 bytes {0} [built] [4] (webpack)/test/statsCases/performance-no-async-chunks-shown/c.js 22 bytes {0} [built] [5] (webpack)/test/statsCases/performance-no-async-chunks-shown/d.js 22 bytes {0} [built] -WARNING in asset size limit: The following asset(s) exceed the recommended size limit (250 kB). +WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB). This can impact web performance. Assets: - main.js (303 kB) + main.js (296 KiB) -WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (250 kB). This can impact web performance. +WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance. Entrypoints: - main (303 kB) + main (296 KiB) main.js diff --git a/test/statsCases/performance-no-hints/expected.txt b/test/statsCases/performance-no-hints/expected.txt index e044be0ff..f1def83c7 100644 --- a/test/statsCases/performance-no-hints/expected.txt +++ b/test/statsCases/performance-no-hints/expected.txt @@ -3,10 +3,10 @@ Time: Xms 0.js 238 bytes 0 [emitted] 1.js 102 bytes 1 [emitted] 2.js 182 bytes 2 [emitted] -main.js 306 kB 3 [emitted] [big] main +main.js 299 KiB 3 [emitted] [big] main Entrypoint main [big] = main.js [0] (webpack)/test/statsCases/performance-no-hints/index.js 52 bytes {3} [built] - [1] (webpack)/test/statsCases/performance-no-hints/a.js 300 kB {3} [built] + [1] (webpack)/test/statsCases/performance-no-hints/a.js 293 KiB {3} [built] [2] (webpack)/test/statsCases/performance-no-hints/b.js 22 bytes {1} [built] [3] (webpack)/test/statsCases/performance-no-hints/c.js 54 bytes {0} [built] [4] (webpack)/test/statsCases/performance-no-hints/d.js 22 bytes {2} [built] diff --git a/test/statsCases/performance-oversize-limit-error/expected.txt b/test/statsCases/performance-oversize-limit-error/expected.txt index 200eedb07..2db55bccc 100644 --- a/test/statsCases/performance-oversize-limit-error/expected.txt +++ b/test/statsCases/performance-oversize-limit-error/expected.txt @@ -1,24 +1,24 @@ Time: Xms - Asset Size Chunks Chunk Names - sec.js 303 kB 0 [emitted] [big] sec -main.js 303 kB 1 [emitted] [big] main + Asset Size Chunks Chunk Names + sec.js 296 KiB 0 [emitted] [big] sec +main.js 296 KiB 1 [emitted] [big] main Entrypoint main [big] = main.js Entrypoint sec [big] = sec.js - [0] (webpack)/test/statsCases/performance-oversize-limit-error/a.js 300 kB {0} {1} [built] + [0] (webpack)/test/statsCases/performance-oversize-limit-error/a.js 293 KiB {0} {1} [built] [1] (webpack)/test/statsCases/performance-oversize-limit-error/index.js 16 bytes {1} [built] [2] (webpack)/test/statsCases/performance-oversize-limit-error/index2.js 16 bytes {0} [built] -ERROR in asset size limit: The following asset(s) exceed the recommended size limit (250 kB). +ERROR in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB). This can impact web performance. Assets: - sec.js (303 kB) - main.js (303 kB) + sec.js (296 KiB) + main.js (296 KiB) -ERROR in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (250 kB). This can impact web performance. +ERROR in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance. Entrypoints: - main (303 kB) + main (296 KiB) main.js - sec (303 kB) + sec (296 KiB) sec.js diff --git a/test/statsCases/preset-detailed/expected.txt b/test/statsCases/preset-detailed/expected.txt index d4b48f326..411f52cc2 100644 --- a/test/statsCases/preset-detailed/expected.txt +++ b/test/statsCases/preset-detailed/expected.txt @@ -4,7 +4,7 @@ Time: Xms 0.js 238 bytes 0 [emitted] 1.js 102 bytes 1 [emitted] 2.js 182 bytes 2 [emitted] -main.js 6.1 kB 3 [emitted] main +main.js 5.95 KiB 3 [emitted] main Entrypoint main = main.js chunk {0} 0.js 54 bytes {3} [rendered] > [0] (webpack)/test/statsCases/preset-detailed/index.js 3:0-16 diff --git a/test/statsCases/preset-normal-performance-ensure-filter-sourcemaps/expected.txt b/test/statsCases/preset-normal-performance-ensure-filter-sourcemaps/expected.txt index 33bec0f02..d5384e4a9 100644 --- a/test/statsCases/preset-normal-performance-ensure-filter-sourcemaps/expected.txt +++ b/test/statsCases/preset-normal-performance-ensure-filter-sourcemaps/expected.txt @@ -3,25 +3,25 @@ Time: Xms 0.js 268 bytes 0 [emitted] 1.js 132 bytes 1 [emitted] 2.js 212 bytes 2 [emitted] - main.js 306 kB 3 [emitted] [big] main + main.js 299 KiB 3 [emitted] [big] main 0.js.map 291 bytes 0 [emitted] 1.js.map 250 bytes 1 [emitted] 2.js.map 404 bytes 2 [emitted] -main.js.map 1.81 MB 3 [emitted] main +main.js.map 1.72 MiB 3 [emitted] main [0] (webpack)/test/statsCases/preset-normal-performance-ensure-filter-sourcemaps/index.js 52 bytes {3} [built] - [1] (webpack)/test/statsCases/preset-normal-performance-ensure-filter-sourcemaps/a.js 300 kB {3} [built] + [1] (webpack)/test/statsCases/preset-normal-performance-ensure-filter-sourcemaps/a.js 293 KiB {3} [built] [2] (webpack)/test/statsCases/preset-normal-performance-ensure-filter-sourcemaps/b.js 22 bytes {1} [built] [3] (webpack)/test/statsCases/preset-normal-performance-ensure-filter-sourcemaps/c.js 54 bytes {0} [built] [4] (webpack)/test/statsCases/preset-normal-performance-ensure-filter-sourcemaps/d.js 22 bytes {2} [built] [5] (webpack)/test/statsCases/preset-normal-performance-ensure-filter-sourcemaps/e.js 22 bytes {2} [built] -WARNING in asset size limit: The following asset(s) exceed the recommended size limit (250 kB). +WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB). This can impact web performance. Assets: - main.js (306 kB) + main.js (299 KiB) -WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (250 kB). This can impact web performance. +WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance. Entrypoints: - main (306 kB) + main (299 KiB) main.js \ No newline at end of file diff --git a/test/statsCases/preset-normal-performance/expected.txt b/test/statsCases/preset-normal-performance/expected.txt index b7d797ecb..6cb93d9ce 100644 --- a/test/statsCases/preset-normal-performance/expected.txt +++ b/test/statsCases/preset-normal-performance/expected.txt @@ -3,21 +3,21 @@ Time: Xms 0.js 238 bytes 0 [emitted] 1.js 102 bytes 1 [emitted] 2.js 182 bytes 2 [emitted] -main.js 306 kB 3 [emitted] [big] main +main.js 299 KiB 3 [emitted] [big] main [0] (webpack)/test/statsCases/preset-normal-performance/index.js 52 bytes {3} [built] - [1] (webpack)/test/statsCases/preset-normal-performance/a.js 300 kB {3} [built] + [1] (webpack)/test/statsCases/preset-normal-performance/a.js 293 KiB {3} [built] [2] (webpack)/test/statsCases/preset-normal-performance/b.js 22 bytes {1} [built] [3] (webpack)/test/statsCases/preset-normal-performance/c.js 54 bytes {0} [built] [4] (webpack)/test/statsCases/preset-normal-performance/d.js 22 bytes {2} [built] [5] (webpack)/test/statsCases/preset-normal-performance/e.js 22 bytes {2} [built] -WARNING in asset size limit: The following asset(s) exceed the recommended size limit (250 kB). +WARNING in asset size limit: The following asset(s) exceed the recommended size limit (244 KiB). This can impact web performance. Assets: - main.js (306 kB) + main.js (299 KiB) -WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (250 kB). This can impact web performance. +WARNING in entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (244 KiB). This can impact web performance. Entrypoints: - main (306 kB) + main (299 KiB) main.js \ No newline at end of file diff --git a/test/statsCases/preset-normal/expected.txt b/test/statsCases/preset-normal/expected.txt index 80a51e555..5b9baa895 100644 --- a/test/statsCases/preset-normal/expected.txt +++ b/test/statsCases/preset-normal/expected.txt @@ -4,7 +4,7 @@ Time: Xms 0.js 238 bytes 0 [emitted] 1.js 102 bytes 1 [emitted] 2.js 182 bytes 2 [emitted] -main.js 6.1 kB 3 [emitted] main +main.js 5.95 KiB 3 [emitted] main [0] (webpack)/test/statsCases/preset-normal/index.js 51 bytes {3} [built] [1] (webpack)/test/statsCases/preset-normal/a.js 22 bytes {3} [built] [2] (webpack)/test/statsCases/preset-normal/b.js 22 bytes {1} [built] diff --git a/test/statsCases/preset-verbose/expected.txt b/test/statsCases/preset-verbose/expected.txt index 686bf3a65..3951db5f8 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 102 bytes 1 [emitted] 2.js 182 bytes 2 [emitted] -main.js 6.1 kB 3 [emitted] main +main.js 5.95 KiB 3 [emitted] main Entrypoint main = main.js chunk {0} 0.js 54 bytes {3} [rendered] > [0] (webpack)/test/statsCases/preset-verbose/index.js 3:0-16 diff --git a/test/statsCases/resolve-plugin-context/expected.txt b/test/statsCases/resolve-plugin-context/expected.txt index 033a761bd..114743b00 100644 --- a/test/statsCases/resolve-plugin-context/expected.txt +++ b/test/statsCases/resolve-plugin-context/expected.txt @@ -1,7 +1,7 @@ Hash: 94e1d97f3e1cf37e753f Time: Xms - Asset Size Chunks Chunk Names -bundle.js 2.88 kB 0 [emitted] main + Asset Size Chunks Chunk Names +bundle.js 2.81 KiB 0 [emitted] main [0] (webpack)/test/statsCases/resolve-plugin-context/node_modules/xyz/index.js 0 bytes {0} [built] [1] (webpack)/test/statsCases/resolve-plugin-context/index.js 48 bytes {0} [built] [2] (webpack)/test/statsCases/resolve-plugin-context/node_modules/abc/index.js 16 bytes {0} [built] diff --git a/test/statsCases/reverse-sort-modules/expected.txt b/test/statsCases/reverse-sort-modules/expected.txt index 7ce77ddc3..79c20eb65 100644 --- a/test/statsCases/reverse-sort-modules/expected.txt +++ b/test/statsCases/reverse-sort-modules/expected.txt @@ -1,7 +1,7 @@ Hash: b70eb677e8a8b3694c25 Time: Xms - Asset Size Chunks Chunk Names -main.js 5.79 kB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 5.65 KiB 0 [emitted] main [29] (webpack)/test/statsCases/reverse-sort-modules/c.js?10 33 bytes {0} [built] [27] (webpack)/test/statsCases/reverse-sort-modules/c.js?9 33 bytes {0} [built] [25] (webpack)/test/statsCases/reverse-sort-modules/c.js?8 33 bytes {0} [built] diff --git a/test/statsCases/separate-css-bundle/expected.txt b/test/statsCases/separate-css-bundle/expected.txt index 752a6975d..5e742800b 100644 --- a/test/statsCases/separate-css-bundle/expected.txt +++ b/test/statsCases/separate-css-bundle/expected.txt @@ -3,29 +3,29 @@ Child Hash: a3f5cb0c4f2d75d79214 Time: Xms Asset Size Chunks Chunk Names - 5a21b890f95ec575ba49.js 2.62 kB 0 [emitted] main + 5a21b890f95ec575ba49.js 2.55 KiB 0 [emitted] main c815cf440254d4f3bba4e7041db00a28.css 26 bytes 0 [emitted] main [0] (webpack)/test/statsCases/separate-css-bundle/a/index.js 23 bytes {0} [built] [1] (webpack)/test/statsCases/separate-css-bundle/a/file.css 41 bytes {0} [built] [2] (webpack)/node_modules/css-loader!(webpack)/test/statsCases/separate-css-bundle/a/file.css 199 bytes [built] - [3] (webpack)/node_modules/css-loader/lib/css-base.js 2.26 kB [built] - [4] (webpack)/node_modules/style-loader/lib/addStyles.js 8.7 kB [built] - [5] (webpack)/node_modules/style-loader/lib/urls.js 3.01 kB [built] + [3] (webpack)/node_modules/css-loader/lib/css-base.js 2.21 KiB [built] + [4] (webpack)/node_modules/style-loader/lib/addStyles.js 8.5 KiB [built] + [5] (webpack)/node_modules/style-loader/lib/urls.js 2.94 KiB [built] Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js!test/statsCases/separate-css-bundle/a/file.css: [0] (webpack)/node_modules/css-loader!(webpack)/test/statsCases/separate-css-bundle/a/file.css 199 bytes {0} [built] - [1] (webpack)/node_modules/css-loader/lib/css-base.js 2.26 kB {0} [built] + [1] (webpack)/node_modules/css-loader/lib/css-base.js 2.21 KiB {0} [built] Child Hash: 074bc8c917dae9eb215a Time: Xms Asset Size Chunks Chunk Names - 5a21b890f95ec575ba49.js 2.62 kB 0 [emitted] main + 5a21b890f95ec575ba49.js 2.55 KiB 0 [emitted] main a3f385680aef7a9bb2a517699532cc34.css 28 bytes 0 [emitted] main [0] (webpack)/test/statsCases/separate-css-bundle/b/index.js 23 bytes {0} [built] [1] (webpack)/test/statsCases/separate-css-bundle/b/file.css 41 bytes {0} [built] [2] (webpack)/node_modules/css-loader!(webpack)/test/statsCases/separate-css-bundle/b/file.css 201 bytes [built] - [3] (webpack)/node_modules/css-loader/lib/css-base.js 2.26 kB [built] - [4] (webpack)/node_modules/style-loader/lib/addStyles.js 8.7 kB [built] - [5] (webpack)/node_modules/style-loader/lib/urls.js 3.01 kB [built] + [3] (webpack)/node_modules/css-loader/lib/css-base.js 2.21 KiB [built] + [4] (webpack)/node_modules/style-loader/lib/addStyles.js 8.5 KiB [built] + [5] (webpack)/node_modules/style-loader/lib/urls.js 2.94 KiB [built] Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js!test/statsCases/separate-css-bundle/b/file.css: [0] (webpack)/node_modules/css-loader!(webpack)/test/statsCases/separate-css-bundle/b/file.css 201 bytes {0} [built] - [1] (webpack)/node_modules/css-loader/lib/css-base.js 2.26 kB {0} [built] \ No newline at end of file + [1] (webpack)/node_modules/css-loader/lib/css-base.js 2.21 KiB {0} [built] \ No newline at end of file diff --git a/test/statsCases/simple-more-info/expected.txt b/test/statsCases/simple-more-info/expected.txt index ecf254996..a6841ea9d 100644 --- a/test/statsCases/simple-more-info/expected.txt +++ b/test/statsCases/simple-more-info/expected.txt @@ -1,6 +1,6 @@ Hash: 0bd4f09244f0e8c60354 Time: Xms - Asset Size Chunks Chunk Names -bundle.js 2.47 kB 0 [emitted] main + Asset Size Chunks Chunk Names +bundle.js 2.42 KiB 0 [emitted] main [0] (webpack)/test/statsCases/simple-more-info/index.js 0 bytes {0} [built] factory:Xms building:Xms = Xms \ No newline at end of file diff --git a/test/statsCases/simple/expected.txt b/test/statsCases/simple/expected.txt index 4974e2530..8b3bfd655 100644 --- a/test/statsCases/simple/expected.txt +++ b/test/statsCases/simple/expected.txt @@ -1,5 +1,5 @@ Hash: 0bd4f09244f0e8c60354 Time: Xms - Asset Size Chunks Chunk Names -bundle.js 2.47 kB 0 [emitted] main + Asset Size Chunks Chunk Names +bundle.js 2.42 KiB 0 [emitted] main [0] (webpack)/test/statsCases/simple/index.js 0 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/tree-shaking/expected.txt b/test/statsCases/tree-shaking/expected.txt index d60eb28d0..a06b3bc7a 100644 --- a/test/statsCases/tree-shaking/expected.txt +++ b/test/statsCases/tree-shaking/expected.txt @@ -1,7 +1,7 @@ Hash: d655480cef20a0a12dff Time: Xms - Asset Size Chunks Chunk Names -bundle.js 7.33 kB 0 [emitted] main + Asset Size Chunks Chunk Names +bundle.js 7.16 KiB 0 [emitted] main [0] (webpack)/test/statsCases/tree-shaking/a.js 13 bytes {0} [built] [exports: a] [only some exports used: a] diff --git a/test/statsCases/warnings-uglifyjs/expected.txt b/test/statsCases/warnings-uglifyjs/expected.txt index 1e79500ce..bcb7fdc70 100644 --- a/test/statsCases/warnings-uglifyjs/expected.txt +++ b/test/statsCases/warnings-uglifyjs/expected.txt @@ -1,7 +1,7 @@ Hash: 2c9851f0ea4c9778e64a Time: Xms - Asset Size Chunks Chunk Names -bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names +bundle.js 2.05 KiB 0 [emitted] main [0] (webpack)/test/statsCases/warnings-uglifyjs/index.js 299 bytes {0} [built] [1] (webpack)/test/statsCases/warnings-uglifyjs/a.js 249 bytes {0} [built] [2] (webpack)/buildin/module.js 495 bytes {0} [built] From f925032d5ad0985784f3c82bacf0bd185ad0995a Mon Sep 17 00:00:00 2001 From: Stephan Badragan Date: Tue, 17 Oct 2017 15:48:04 -0700 Subject: [PATCH 03/85] adding `output.devtoolNamespace` option When loading multiple libraries built with webpack, you can run into collisions of the sourcemap file paths. For examle, both have "webpack:///src/index.js". This change addresses the problem by introducing a new output option `output.devtoolNamespace` which defaults to `output.library` when not specified. The defaults moduleFilenameTemplates in all the sourcemap plugins have been modified to start with: "webpack://[namespace]/...", where [namespace] will be replaced by the `output.devtoolNamespace`. Notice that there are only two slashes following "webpack:" now. This is to make it behave just as before when not building with a namespace. When building with a namespace you only get the two slashes, but from what I've seen the chrome dev tools only care about the first 2 slashes anyways. Discussed with sokra here: https://github.com/webpack/webpack/issues/5767 --- lib/EvalDevToolModuleTemplatePlugin.js | 2 +- lib/EvalSourceMapDevToolModuleTemplatePlugin.js | 2 +- lib/ModuleFilenameHelpers.js | 13 +++++++++++-- lib/SourceMapDevToolPlugin.js | 4 ++-- lib/WebpackOptionsApply.js | 7 +++++++ schemas/webpackOptionsSchema.json | 4 ++++ .../namespace-source-path.library/index.js | 8 ++++++++ .../namespace-source-path.library/test.js | 3 +++ .../namespace-source-path.library/webpack.config.js | 10 ++++++++++ .../source-map/namespace-source-path/index.js | 8 ++++++++ .../source-map/namespace-source-path/test.js | 3 +++ .../namespace-source-path/webpack.config.js | 10 ++++++++++ 12 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 test/configCases/source-map/namespace-source-path.library/index.js create mode 100644 test/configCases/source-map/namespace-source-path.library/test.js create mode 100644 test/configCases/source-map/namespace-source-path.library/webpack.config.js create mode 100644 test/configCases/source-map/namespace-source-path/index.js create mode 100644 test/configCases/source-map/namespace-source-path/test.js create mode 100644 test/configCases/source-map/namespace-source-path/webpack.config.js diff --git a/lib/EvalDevToolModuleTemplatePlugin.js b/lib/EvalDevToolModuleTemplatePlugin.js index d6c0bb9b5..fc32c2d43 100644 --- a/lib/EvalDevToolModuleTemplatePlugin.js +++ b/lib/EvalDevToolModuleTemplatePlugin.js @@ -10,7 +10,7 @@ const ModuleFilenameHelpers = require("./ModuleFilenameHelpers"); class EvalDevToolModuleTemplatePlugin { constructor(sourceUrlComment, moduleFilenameTemplate) { this.sourceUrlComment = sourceUrlComment || "\n//# sourceURL=[url]"; - this.moduleFilenameTemplate = moduleFilenameTemplate || "webpack:///[resourcePath]?[loaders]"; + this.moduleFilenameTemplate = moduleFilenameTemplate || "webpack://[namespace]/[resourcePath]?[loaders]"; } apply(moduleTemplate) { diff --git a/lib/EvalSourceMapDevToolModuleTemplatePlugin.js b/lib/EvalSourceMapDevToolModuleTemplatePlugin.js index 31ecfe058..c0faf74d2 100644 --- a/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +++ b/lib/EvalSourceMapDevToolModuleTemplatePlugin.js @@ -11,7 +11,7 @@ class EvalSourceMapDevToolModuleTemplatePlugin { constructor(compilation, options) { this.compilation = compilation; this.sourceMapComment = options.append || "//# sourceURL=[module]\n//# sourceMappingURL=[url]"; - this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack:///[resource-path]?[hash]"; + this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack://[namespace]/[resource-path]?[hash]"; this.options = options; } diff --git a/lib/ModuleFilenameHelpers.js b/lib/ModuleFilenameHelpers.js index 59010dee5..9dc266488 100644 --- a/lib/ModuleFilenameHelpers.js +++ b/lib/ModuleFilenameHelpers.js @@ -26,6 +26,8 @@ ModuleFilenameHelpers.ID = "[id]"; ModuleFilenameHelpers.REGEXP_ID = /\[id\]/gi; ModuleFilenameHelpers.HASH = "[hash]"; ModuleFilenameHelpers.REGEXP_HASH = /\[hash\]/gi; +ModuleFilenameHelpers.NAMESPACE = "[namespace]"; +ModuleFilenameHelpers.REGEXP_NAMESPACE = /\[namespace\]/gi; function getAfter(str, token) { const idx = str.indexOf(token); @@ -73,6 +75,7 @@ ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFil const allLoaders = getBefore(identifier, "!"); const query = getAfter(resource, "?"); const resourcePath = resource.substr(0, resource.length - query.length); + const namespace = this._moduleNamespace || ""; if(typeof moduleFilenameTemplate === "function") { return moduleFilenameTemplate({ identifier: identifier, @@ -83,7 +86,8 @@ ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFil allLoaders: allLoaders, query: query, moduleId: moduleId, - hash: hash + hash: hash, + namespace: namespace }); } return moduleFilenameTemplate @@ -96,7 +100,8 @@ ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFil .replace(ModuleFilenameHelpers.REGEXP_LOADERS, loaders) .replace(ModuleFilenameHelpers.REGEXP_QUERY, query) .replace(ModuleFilenameHelpers.REGEXP_ID, moduleId) - .replace(ModuleFilenameHelpers.REGEXP_HASH, hash); + .replace(ModuleFilenameHelpers.REGEXP_HASH, hash) + .replace(ModuleFilenameHelpers.REGEXP_NAMESPACE, namespace); }; ModuleFilenameHelpers.createFooter = function createFooter(module, requestShortener) { @@ -160,3 +165,7 @@ ModuleFilenameHelpers.matchObject = function matchObject(obj, str) { if(ModuleFilenameHelpers.matchPart(str, obj.exclude)) return false; return true; }; + +ModuleFilenameHelpers.setModuleNamespace = function setModuleNamespace(moduleNamespace) { + this._moduleNamespace = moduleNamespace; +}; diff --git a/lib/SourceMapDevToolPlugin.js b/lib/SourceMapDevToolPlugin.js index 6055c2608..887bc130a 100644 --- a/lib/SourceMapDevToolPlugin.js +++ b/lib/SourceMapDevToolPlugin.js @@ -62,8 +62,8 @@ class SourceMapDevToolPlugin { if(!options) options = {}; this.sourceMapFilename = options.filename; this.sourceMappingURLComment = options.append === false ? false : options.append || "\n//# sourceMappingURL=[url]"; - this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack:///[resourcePath]"; - this.fallbackModuleFilenameTemplate = options.fallbackModuleFilenameTemplate || "webpack:///[resourcePath]?[hash]"; + this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack://[namespace]/[resourcePath]"; + this.fallbackModuleFilenameTemplate = options.fallbackModuleFilenameTemplate || "webpack://[namespace]/[resourcePath]?[hash]"; this.options = options; } diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js index 37f3d31e5..97ba58609 100644 --- a/lib/WebpackOptionsApply.js +++ b/lib/WebpackOptionsApply.js @@ -46,6 +46,7 @@ const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin"); const SizeLimitsPlugin = require("./performance/SizeLimitsPlugin"); const ResolverFactory = require("enhanced-resolve").ResolverFactory; +const ModuleFilenameHelpers = require("./ModuleFilenameHelpers"); class WebpackOptionsApply extends OptionsApply { constructor() { @@ -193,6 +194,12 @@ class WebpackOptionsApply extends OptionsApply { ExternalsPlugin = require("./ExternalsPlugin"); compiler.apply(new ExternalsPlugin(options.output.libraryTarget, options.externals)); } + + if(!options.output.devtoolNamespace) { + options.output.devtoolNamespace = options.output.library; + } + ModuleFilenameHelpers.setModuleNamespace(options.output.devtoolNamespace); + let noSources; let legacy; let modern; diff --git a/schemas/webpackOptionsSchema.json b/schemas/webpackOptionsSchema.json index a7f8ddefa..d594c364e 100644 --- a/schemas/webpackOptionsSchema.json +++ b/schemas/webpackOptionsSchema.json @@ -326,6 +326,10 @@ } ] }, + "devtoolNamespace": { + "description": "Module namespace to use when interpolating filename template string for the sources array in a generated SourceMap. Defaults to `output.library` if not set. It's useful for avoiding runtime collisions in sourcemaps from multiple webpack projects built as libraries.", + "type": "string" + }, "filename": { "description": "Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files.", "type": "string", diff --git a/test/configCases/source-map/namespace-source-path.library/index.js b/test/configCases/source-map/namespace-source-path.library/index.js new file mode 100644 index 000000000..5dfce4d59 --- /dev/null +++ b/test/configCases/source-map/namespace-source-path.library/index.js @@ -0,0 +1,8 @@ +it("should include webpack://mylibrary/./test.js in SourceMap", function() { + var fs = require("fs"); + var source = fs.readFileSync(__filename + ".map", "utf-8"); + var map = JSON.parse(source); + map.sources.should.containEql("webpack://mylibrary/./test.js"); +}); + +require.include("./test.js"); diff --git a/test/configCases/source-map/namespace-source-path.library/test.js b/test/configCases/source-map/namespace-source-path.library/test.js new file mode 100644 index 000000000..d336df4c8 --- /dev/null +++ b/test/configCases/source-map/namespace-source-path.library/test.js @@ -0,0 +1,3 @@ +var foo = {}; + +module.exports = foo; \ No newline at end of file diff --git a/test/configCases/source-map/namespace-source-path.library/webpack.config.js b/test/configCases/source-map/namespace-source-path.library/webpack.config.js new file mode 100644 index 000000000..c94b94d66 --- /dev/null +++ b/test/configCases/source-map/namespace-source-path.library/webpack.config.js @@ -0,0 +1,10 @@ +module.exports = { + output: { + library: "mylibrary" + }, + node: { + __dirname: false, + __filename: false + }, + devtool: "cheap-source-map" +}; diff --git a/test/configCases/source-map/namespace-source-path/index.js b/test/configCases/source-map/namespace-source-path/index.js new file mode 100644 index 000000000..da7dbac42 --- /dev/null +++ b/test/configCases/source-map/namespace-source-path/index.js @@ -0,0 +1,8 @@ +it("should include webpack://mynamespace/./test.js in SourceMap", function() { + var fs = require("fs"); + var source = fs.readFileSync(__filename + ".map", "utf-8"); + var map = JSON.parse(source); + map.sources.should.containEql("webpack://mynamespace/./test.js"); +}); + +require.include("./test.js"); diff --git a/test/configCases/source-map/namespace-source-path/test.js b/test/configCases/source-map/namespace-source-path/test.js new file mode 100644 index 000000000..d336df4c8 --- /dev/null +++ b/test/configCases/source-map/namespace-source-path/test.js @@ -0,0 +1,3 @@ +var foo = {}; + +module.exports = foo; \ No newline at end of file diff --git a/test/configCases/source-map/namespace-source-path/webpack.config.js b/test/configCases/source-map/namespace-source-path/webpack.config.js new file mode 100644 index 000000000..146dabbca --- /dev/null +++ b/test/configCases/source-map/namespace-source-path/webpack.config.js @@ -0,0 +1,10 @@ +module.exports = { + output: { + devtoolNamespace: "mynamespace" + }, + node: { + __dirname: false, + __filename: false + }, + devtool: "cheap-source-map" +}; From 72b28aa1c3db56857ba94ffba0d7679a6dc5e44c Mon Sep 17 00:00:00 2001 From: Stephan Badragan Date: Wed, 18 Oct 2017 15:24:59 -0700 Subject: [PATCH 04/85] passing devtoolNamespace through instead of setting it statically --- lib/EvalDevToolModulePlugin.js | 2 +- lib/EvalDevToolModuleTemplatePlugin.js | 8 +++++-- ...valSourceMapDevToolModuleTemplatePlugin.js | 6 ++++- lib/ModuleFilenameHelpers.js | 23 +++++++++++++------ lib/SourceMapDevToolPlugin.js | 8 +++++-- lib/WebpackOptionsApply.js | 2 -- 6 files changed, 34 insertions(+), 15 deletions(-) diff --git a/lib/EvalDevToolModulePlugin.js b/lib/EvalDevToolModulePlugin.js index 252b9d3f3..69ff73915 100644 --- a/lib/EvalDevToolModulePlugin.js +++ b/lib/EvalDevToolModulePlugin.js @@ -14,7 +14,7 @@ class EvalDevToolModulePlugin { apply(compiler) { compiler.plugin("compilation", (compilation) => { - compilation.moduleTemplate.apply(new EvalDevToolModuleTemplatePlugin(this.sourceUrlComment, this.moduleFilenameTemplate)); + compilation.moduleTemplate.apply(new EvalDevToolModuleTemplatePlugin(this.sourceUrlComment, this.moduleFilenameTemplate, compiler.options.output.devtoolNamespace)); }); } } diff --git a/lib/EvalDevToolModuleTemplatePlugin.js b/lib/EvalDevToolModuleTemplatePlugin.js index fc32c2d43..2b8d98552 100644 --- a/lib/EvalDevToolModuleTemplatePlugin.js +++ b/lib/EvalDevToolModuleTemplatePlugin.js @@ -8,15 +8,19 @@ const RawSource = require("webpack-sources").RawSource; const ModuleFilenameHelpers = require("./ModuleFilenameHelpers"); class EvalDevToolModuleTemplatePlugin { - constructor(sourceUrlComment, moduleFilenameTemplate) { + constructor(sourceUrlComment, moduleFilenameTemplate, namespace) { this.sourceUrlComment = sourceUrlComment || "\n//# sourceURL=[url]"; this.moduleFilenameTemplate = moduleFilenameTemplate || "webpack://[namespace]/[resourcePath]?[loaders]"; + this.namespace = namespace; } apply(moduleTemplate) { moduleTemplate.plugin("module", (source, module) => { const content = source.source(); - const str = ModuleFilenameHelpers.createFilename(module, this.moduleFilenameTemplate, moduleTemplate.requestShortener); + const str = ModuleFilenameHelpers.createFilename(module, { + moduleFilenameTemplate: this.moduleFilenameTemplate, + namespace: this.namespace + }, moduleTemplate.requestShortener); const footer = ["\n", ModuleFilenameHelpers.createFooter(module, moduleTemplate.requestShortener), this.sourceUrlComment.replace(/\[url\]/g, encodeURI(str).replace(/%2F/g, "/").replace(/%20/g, "_").replace(/%5E/g, "^").replace(/%5C/g, "\\").replace(/^\//, "")) diff --git a/lib/EvalSourceMapDevToolModuleTemplatePlugin.js b/lib/EvalSourceMapDevToolModuleTemplatePlugin.js index c0faf74d2..1c1c065ba 100644 --- a/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +++ b/lib/EvalSourceMapDevToolModuleTemplatePlugin.js @@ -12,6 +12,7 @@ class EvalSourceMapDevToolModuleTemplatePlugin { this.compilation = compilation; this.sourceMapComment = options.append || "//# sourceURL=[module]\n//# sourceMappingURL=[url]"; this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack://[namespace]/[resource-path]?[hash]"; + this.namespace = compilation.options.output.devtoolNamespace; this.options = options; } @@ -45,7 +46,10 @@ class EvalSourceMapDevToolModuleTemplatePlugin { return module || source; }); let moduleFilenames = modules.map(function(module) { - return ModuleFilenameHelpers.createFilename(module, self.moduleFilenameTemplate, this.requestShortener); + return ModuleFilenameHelpers.createFilename(module, { + moduleFilenameTemplate: self.moduleFilenameTemplate, + namespace: self.namespace + }, this.requestShortener); }, this); moduleFilenames = ModuleFilenameHelpers.replaceDuplicates(moduleFilenames, function(filename, i, n) { for(let j = 0; j < n; j++) diff --git a/lib/ModuleFilenameHelpers.js b/lib/ModuleFilenameHelpers.js index 9dc266488..9d778b6e9 100644 --- a/lib/ModuleFilenameHelpers.js +++ b/lib/ModuleFilenameHelpers.js @@ -50,7 +50,17 @@ function asRegExp(test) { return test; } -ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFilenameTemplate, requestShortener) { +ModuleFilenameHelpers.createFilename = function createFilename(module, options, requestShortener) { + let opts; + if(typeof options === "object") { + opts = options; + } else { + opts = { + moduleFilenameTemplate: arguments[1], + namespace: "" + }; + } + let absoluteResourcePath; let hash; let identifier; @@ -75,9 +85,8 @@ ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFil const allLoaders = getBefore(identifier, "!"); const query = getAfter(resource, "?"); const resourcePath = resource.substr(0, resource.length - query.length); - const namespace = this._moduleNamespace || ""; - if(typeof moduleFilenameTemplate === "function") { - return moduleFilenameTemplate({ + if(typeof opts.moduleFilenameTemplate === "function") { + return opts.moduleFilenameTemplate({ identifier: identifier, shortIdentifier: shortIdentifier, resource: resource, @@ -87,10 +96,10 @@ ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFil query: query, moduleId: moduleId, hash: hash, - namespace: namespace + namespace: opts.namespace }); } - return moduleFilenameTemplate + return opts.moduleFilenameTemplate .replace(ModuleFilenameHelpers.REGEXP_ALL_LOADERS_RESOURCE, identifier) .replace(ModuleFilenameHelpers.REGEXP_LOADERS_RESOURCE, shortIdentifier) .replace(ModuleFilenameHelpers.REGEXP_RESOURCE, resource) @@ -101,7 +110,7 @@ ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFil .replace(ModuleFilenameHelpers.REGEXP_QUERY, query) .replace(ModuleFilenameHelpers.REGEXP_ID, moduleId) .replace(ModuleFilenameHelpers.REGEXP_HASH, hash) - .replace(ModuleFilenameHelpers.REGEXP_NAMESPACE, namespace); + .replace(ModuleFilenameHelpers.REGEXP_NAMESPACE, opts.namespace); }; ModuleFilenameHelpers.createFooter = function createFooter(module, requestShortener) { diff --git a/lib/SourceMapDevToolPlugin.js b/lib/SourceMapDevToolPlugin.js index 887bc130a..b0bcc0b62 100644 --- a/lib/SourceMapDevToolPlugin.js +++ b/lib/SourceMapDevToolPlugin.js @@ -72,6 +72,7 @@ class SourceMapDevToolPlugin { const sourceMappingURLComment = this.sourceMappingURLComment; const moduleFilenameTemplate = this.moduleFilenameTemplate; const fallbackModuleFilenameTemplate = this.fallbackModuleFilenameTemplate; + const namespace = compiler.options.output.devtoolNamespace; const requestShortener = new RequestShortener(compiler.context); const options = this.options; options.test = options.test || /\.(js|css)($|\?)/i; @@ -99,7 +100,7 @@ class SourceMapDevToolPlugin { for(let idx = 0; idx < modules.length; idx++) { const module = modules[idx]; if(!moduleToSourceNameMapping.get(module)) { - moduleToSourceNameMapping.set(module, ModuleFilenameHelpers.createFilename(module, moduleFilenameTemplate, requestShortener)); + moduleToSourceNameMapping.set(module, ModuleFilenameHelpers.createFilename(module, { moduleFilenameTemplate, namespace }, requestShortener)); } } @@ -132,7 +133,10 @@ class SourceMapDevToolPlugin { } // try the fallback name first - sourceName = ModuleFilenameHelpers.createFilename(module, fallbackModuleFilenameTemplate, requestShortener); + sourceName = ModuleFilenameHelpers.createFilename(module, { + moduleFilenameTemplate: fallbackModuleFilenameTemplate, + namespace: namespace + }, requestShortener); hasName = usedNamesSet.has(sourceName); if(!hasName) { moduleToSourceNameMapping.set(module, sourceName); diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js index 97ba58609..13c031b74 100644 --- a/lib/WebpackOptionsApply.js +++ b/lib/WebpackOptionsApply.js @@ -46,7 +46,6 @@ const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin"); const SizeLimitsPlugin = require("./performance/SizeLimitsPlugin"); const ResolverFactory = require("enhanced-resolve").ResolverFactory; -const ModuleFilenameHelpers = require("./ModuleFilenameHelpers"); class WebpackOptionsApply extends OptionsApply { constructor() { @@ -198,7 +197,6 @@ class WebpackOptionsApply extends OptionsApply { if(!options.output.devtoolNamespace) { options.output.devtoolNamespace = options.output.library; } - ModuleFilenameHelpers.setModuleNamespace(options.output.devtoolNamespace); let noSources; let legacy; From c9e3591c5e125bef89dde9475d7548cd8ba8d194 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 19 Oct 2017 19:47:49 +0200 Subject: [PATCH 05/85] Rename SizeFormatHelpers.test.js to SizeFormatHelpers.unittest.js --- test/{SizeFormatHelpers.test.js => SizeFormatHelpers.unittest.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/{SizeFormatHelpers.test.js => SizeFormatHelpers.unittest.js} (100%) diff --git a/test/SizeFormatHelpers.test.js b/test/SizeFormatHelpers.unittest.js similarity index 100% rename from test/SizeFormatHelpers.test.js rename to test/SizeFormatHelpers.unittest.js From 68acd41bffba30382e9916b8291e413b26a9d3f1 Mon Sep 17 00:00:00 2001 From: Stephan Badragan Date: Thu, 19 Oct 2017 13:23:28 -0700 Subject: [PATCH 06/85] passing namespace argument to contructors of dev tool plugins --- lib/EvalDevToolModulePlugin.js | 13 +++++++++---- lib/EvalDevToolModuleTemplatePlugin.js | 8 ++++---- lib/EvalSourceMapDevToolModuleTemplatePlugin.js | 2 +- lib/ModuleFilenameHelpers.js | 17 ++++------------- lib/SourceMapDevToolPlugin.js | 8 ++++++-- lib/WebpackOptionsApply.js | 11 ++++++----- lib/WebpackOptionsDefaulter.js | 3 +++ 7 files changed, 33 insertions(+), 29 deletions(-) diff --git a/lib/EvalDevToolModulePlugin.js b/lib/EvalDevToolModulePlugin.js index 69ff73915..c4860bc8e 100644 --- a/lib/EvalDevToolModulePlugin.js +++ b/lib/EvalDevToolModulePlugin.js @@ -7,14 +7,19 @@ const EvalDevToolModuleTemplatePlugin = require("./EvalDevToolModuleTemplatePlugin"); class EvalDevToolModulePlugin { - constructor(sourceUrlComment, moduleFilenameTemplate) { - this.sourceUrlComment = sourceUrlComment; - this.moduleFilenameTemplate = moduleFilenameTemplate; + constructor(options) { + this.sourceUrlComment = options.sourceUrlComment; + this.moduleFilenameTemplate = options.moduleFilenameTemplate; + this.namespace = options.namespace; } apply(compiler) { compiler.plugin("compilation", (compilation) => { - compilation.moduleTemplate.apply(new EvalDevToolModuleTemplatePlugin(this.sourceUrlComment, this.moduleFilenameTemplate, compiler.options.output.devtoolNamespace)); + compilation.moduleTemplate.apply(new EvalDevToolModuleTemplatePlugin({ + sourceUrlComment: this.sourceUrlComment, + moduleFilenameTemplate: this.moduleFilenameTemplate, + namespace: this.namespace + })); }); } } diff --git a/lib/EvalDevToolModuleTemplatePlugin.js b/lib/EvalDevToolModuleTemplatePlugin.js index 2b8d98552..a45a4a15b 100644 --- a/lib/EvalDevToolModuleTemplatePlugin.js +++ b/lib/EvalDevToolModuleTemplatePlugin.js @@ -8,10 +8,10 @@ const RawSource = require("webpack-sources").RawSource; const ModuleFilenameHelpers = require("./ModuleFilenameHelpers"); class EvalDevToolModuleTemplatePlugin { - constructor(sourceUrlComment, moduleFilenameTemplate, namespace) { - this.sourceUrlComment = sourceUrlComment || "\n//# sourceURL=[url]"; - this.moduleFilenameTemplate = moduleFilenameTemplate || "webpack://[namespace]/[resourcePath]?[loaders]"; - this.namespace = namespace; + constructor(options) { + this.sourceUrlComment = options.sourceUrlComment || "\n//# sourceURL=[url]"; + this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack://[namespace]/[resourcePath]?[loaders]"; + this.namespace = options.namespace || ""; } apply(moduleTemplate) { diff --git a/lib/EvalSourceMapDevToolModuleTemplatePlugin.js b/lib/EvalSourceMapDevToolModuleTemplatePlugin.js index 1c1c065ba..d99e65148 100644 --- a/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +++ b/lib/EvalSourceMapDevToolModuleTemplatePlugin.js @@ -12,7 +12,7 @@ class EvalSourceMapDevToolModuleTemplatePlugin { this.compilation = compilation; this.sourceMapComment = options.append || "//# sourceURL=[module]\n//# sourceMappingURL=[url]"; this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack://[namespace]/[resource-path]?[hash]"; - this.namespace = compilation.options.output.devtoolNamespace; + this.namespace = options.namespace || ""; this.options = options; } diff --git a/lib/ModuleFilenameHelpers.js b/lib/ModuleFilenameHelpers.js index 9d778b6e9..de9c79e55 100644 --- a/lib/ModuleFilenameHelpers.js +++ b/lib/ModuleFilenameHelpers.js @@ -51,15 +51,10 @@ function asRegExp(test) { } ModuleFilenameHelpers.createFilename = function createFilename(module, options, requestShortener) { - let opts; - if(typeof options === "object") { - opts = options; - } else { - opts = { - moduleFilenameTemplate: arguments[1], - namespace: "" - }; - } + const opts = Object.assign({ + namespace: "", + moduleFilenameTemplate: "" + }, typeof options === "object" ? options : { moduleFilenameTemplate: options }); let absoluteResourcePath; let hash; @@ -174,7 +169,3 @@ ModuleFilenameHelpers.matchObject = function matchObject(obj, str) { if(ModuleFilenameHelpers.matchPart(str, obj.exclude)) return false; return true; }; - -ModuleFilenameHelpers.setModuleNamespace = function setModuleNamespace(moduleNamespace) { - this._moduleNamespace = moduleNamespace; -}; diff --git a/lib/SourceMapDevToolPlugin.js b/lib/SourceMapDevToolPlugin.js index b0bcc0b62..82db7ac57 100644 --- a/lib/SourceMapDevToolPlugin.js +++ b/lib/SourceMapDevToolPlugin.js @@ -64,6 +64,7 @@ class SourceMapDevToolPlugin { this.sourceMappingURLComment = options.append === false ? false : options.append || "\n//# sourceMappingURL=[url]"; this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack://[namespace]/[resourcePath]"; this.fallbackModuleFilenameTemplate = options.fallbackModuleFilenameTemplate || "webpack://[namespace]/[resourcePath]?[hash]"; + this.namespace = options.namespace || ""; this.options = options; } @@ -71,8 +72,8 @@ class SourceMapDevToolPlugin { const sourceMapFilename = this.sourceMapFilename; const sourceMappingURLComment = this.sourceMappingURLComment; const moduleFilenameTemplate = this.moduleFilenameTemplate; + const namespace = this.namespace; const fallbackModuleFilenameTemplate = this.fallbackModuleFilenameTemplate; - const namespace = compiler.options.output.devtoolNamespace; const requestShortener = new RequestShortener(compiler.context); const options = this.options; options.test = options.test || /\.(js|css)($|\?)/i; @@ -100,7 +101,10 @@ class SourceMapDevToolPlugin { for(let idx = 0; idx < modules.length; idx++) { const module = modules[idx]; if(!moduleToSourceNameMapping.get(module)) { - moduleToSourceNameMapping.set(module, ModuleFilenameHelpers.createFilename(module, { moduleFilenameTemplate, namespace }, requestShortener)); + moduleToSourceNameMapping.set(module, ModuleFilenameHelpers.createFilename(module, { + moduleFilenameTemplate: moduleFilenameTemplate, + namespace: namespace + }, requestShortener)); } } diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js index 13c031b74..8baf8c747 100644 --- a/lib/WebpackOptionsApply.js +++ b/lib/WebpackOptionsApply.js @@ -194,10 +194,6 @@ class WebpackOptionsApply extends OptionsApply { compiler.apply(new ExternalsPlugin(options.output.libraryTarget, options.externals)); } - if(!options.output.devtoolNamespace) { - options.output.devtoolNamespace = options.output.library; - } - let noSources; let legacy; let modern; @@ -225,6 +221,7 @@ class WebpackOptionsApply extends OptionsApply { columns: cheap ? false : true, lineToLine: options.output.devtoolLineToLine, noSources: noSources, + namespace: options.output.devtoolNamespace })); } else if(options.devtool && options.devtool.indexOf("eval") >= 0) { legacy = options.devtool.indexOf("@") >= 0; @@ -233,7 +230,11 @@ class WebpackOptionsApply extends OptionsApply { legacy ? "\n//@ sourceURL=[url]" : modern ? "\n//# sourceURL=[url]" : null; - compiler.apply(new EvalDevToolModulePlugin(comment, options.output.devtoolModuleFilenameTemplate)); + compiler.apply(new EvalDevToolModulePlugin({ + sourceUrlComment: comment, + moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate, + namespace: options.output.devtoolNamespace + })); } compiler.apply(new EntryOptionPlugin()); diff --git a/lib/WebpackOptionsDefaulter.js b/lib/WebpackOptionsDefaulter.js index ff0cc8072..acd58285d 100644 --- a/lib/WebpackOptionsDefaulter.js +++ b/lib/WebpackOptionsDefaulter.js @@ -55,6 +55,9 @@ class WebpackOptionsDefaulter extends OptionsDefaulter { this.set("output.jsonpFunction", "make", (options) => { return Template.toIdentifier("webpackJsonp" + options.output.library); }); + this.set("output.devtoolNamespace", "make", (options) => { + return options.output.library || ""; + }); this.set("output.libraryTarget", "var"); this.set("output.path", process.cwd()); this.set("output.sourceMapFilename", "[file].map[query]"); From f0b81cbd340bcf695ea57bebf00319858f11b696 Mon Sep 17 00:00:00 2001 From: Stephan Badragan Date: Fri, 20 Oct 2017 20:50:28 +0100 Subject: [PATCH 07/85] fixing code style issue --- lib/ModuleFilenameHelpers.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ModuleFilenameHelpers.js b/lib/ModuleFilenameHelpers.js index de9c79e55..60c83f198 100644 --- a/lib/ModuleFilenameHelpers.js +++ b/lib/ModuleFilenameHelpers.js @@ -54,7 +54,9 @@ ModuleFilenameHelpers.createFilename = function createFilename(module, options, const opts = Object.assign({ namespace: "", moduleFilenameTemplate: "" - }, typeof options === "object" ? options : { moduleFilenameTemplate: options }); + }, typeof options === "object" ? options : { + moduleFilenameTemplate: options + }); let absoluteResourcePath; let hash; From 95bbcc66e807adc5b3cffb5a864829bdf85bfbd9 Mon Sep 17 00:00:00 2001 From: Shreyas Agarkar Date: Mon, 23 Oct 2017 11:28:34 +0530 Subject: [PATCH 08/85] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index ce7962c3c..859607564 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,9 @@ + + + From 1a856937d16db5d1ba30804b79a27488b9a9e55a Mon Sep 17 00:00:00 2001 From: Abhilash Singh Date: Sun, 29 Oct 2017 04:49:42 +0530 Subject: [PATCH 09/85] Source maps: webpack serves null content from sourcesContent #5542 --- lib/EvalSourceMapDevToolModuleTemplatePlugin.js | 2 +- lib/SourceMapDevToolPlugin.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/EvalSourceMapDevToolModuleTemplatePlugin.js b/lib/EvalSourceMapDevToolModuleTemplatePlugin.js index 31ecfe058..6031a8fe0 100644 --- a/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +++ b/lib/EvalSourceMapDevToolModuleTemplatePlugin.js @@ -55,7 +55,7 @@ class EvalSourceMapDevToolModuleTemplatePlugin { sourceMap.sources = moduleFilenames; if(sourceMap.sourcesContent) { sourceMap.sourcesContent = sourceMap.sourcesContent.map(function(content, i) { - return `${content}\n\n\n${ModuleFilenameHelpers.createFooter(modules[i], this.requestShortener)}`; + return typeof content === "string" ? `${content}\n\n\n${ModuleFilenameHelpers.createFooter(modules[i], this.requestShortener)}` : null; }, this); } sourceMap.sourceRoot = options.sourceRoot || ""; diff --git a/lib/SourceMapDevToolPlugin.js b/lib/SourceMapDevToolPlugin.js index 6055c2608..9fea7cc8c 100644 --- a/lib/SourceMapDevToolPlugin.js +++ b/lib/SourceMapDevToolPlugin.js @@ -158,7 +158,7 @@ class SourceMapDevToolPlugin { const moduleFilenames = modules.map(m => moduleToSourceNameMapping.get(m)); sourceMap.sources = moduleFilenames; if(sourceMap.sourcesContent && !options.noSources) { - sourceMap.sourcesContent = sourceMap.sourcesContent.map((content, i) => `${content}\n\n\n${ModuleFilenameHelpers.createFooter(modules[i], requestShortener)}`); + sourceMap.sourcesContent = sourceMap.sourcesContent.map((content, i) => typeof content === "string" ? `${content}\n\n\n${ModuleFilenameHelpers.createFooter(modules[i], requestShortener)}` : null); } else { sourceMap.sourcesContent = undefined; } From 51c572c4f517219cd401463d1aa2cea4a3129fdc Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 6 Nov 2017 16:41:26 +0100 Subject: [PATCH 10/85] refactor more properties to Sets --- lib/Chunk.js | 60 ++++++++++++++++++++++++--- lib/Compilation.js | 44 ++++++++------------ lib/Compiler.js | 33 ++++++--------- lib/ContextModule.js | 2 +- lib/DllReferencePlugin.js | 2 +- lib/Entrypoint.js | 19 +++++---- lib/JsonpChunkTemplatePlugin.js | 2 +- lib/JsonpMainTemplatePlugin.js | 2 +- lib/NormalModule.js | 43 +++++++++---------- lib/WarnCaseSensitiveModulesPlugin.js | 18 ++++---- lib/optimize/CommonsChunkPlugin.js | 2 +- lib/optimize/ConcatenatedModule.js | 16 ++++--- 12 files changed, 139 insertions(+), 104 deletions(-) diff --git a/lib/Chunk.js b/lib/Chunk.js index 859bdcea8..7329a4781 100644 --- a/lib/Chunk.js +++ b/lib/Chunk.js @@ -50,7 +50,7 @@ class Chunk { this.debugId = debugId++; this.name = name; this._modules = new SortableSet(undefined, sortByIdentifier); - this.entrypoints = []; + this._entrypoints = new SortableSet(); this._chunks = new SortableSet(undefined, sortById); this._parents = new SortableSet(undefined, sortById); this._blocks = new SortableSet(); @@ -155,13 +155,45 @@ class Chunk { return this._blocks; } + /** + * @return {Array} - an array containing the entrypoints + */ + getEntrypoints() { + return this._entrypoints.getFromCache(getArray); + } + + setEntrypoints(newEntrypoints) { + this._entrypoints.clear(); + for(const p of newEntrypoints) + this._entrypoints.add(p); + } + + mapEntrypoints(fn) { + return Array.from(this._entrypoints, fn); + } + + getNumberOfEntrypoints() { + return this._entrypoints.size; + } + + hasEntrypoint(entrypoint) { + return this._entrypoints.has(entrypoint); + } + + get entrypointsIterable() { + return this._entrypoints; + } + hasRuntime() { - if(this.entrypoints.length === 0) return false; - return this.entrypoints[0].getRuntimeChunk() === this; + for(const entrypoint of this._entrypoints) { + // We only need to check the first one + return entrypoint.getRuntimeChunk() === this; + } + return false; } isInitial() { - return this.entrypoints.length > 0; + return this._entrypoints.size > 0; } hasEntryModule() { @@ -213,6 +245,14 @@ class Chunk { return false; } + addEntrypoint(entrypoint) { + if(!this._entrypoints.has(entrypoint)) { + this._entrypoints.add(entrypoint); + return true; + } + return false; + } + removeModule(module) { if(this._modules.delete(module)) { module.removeChunk(this); @@ -432,7 +472,7 @@ class Chunk { parentChunk.addChunk(newChunk); newChunk._parents.add(parentChunk); } - for(const entrypoint of this.entrypoints) { + for(const entrypoint of this._entrypoints) { entrypoint.insertChunk(newChunk, this); } } @@ -592,4 +632,14 @@ Object.defineProperty(Chunk.prototype, "blocks", { }, "Chunk.blocks: Use Chunk.addBlock/removeBlock/setBlocks to modify blocks.") }); +Object.defineProperty(Chunk.prototype, "entrypoints", { + configurable: false, + get: util.deprecate(function() { + return this._entrypoints.getFromCache(getFrozenArray); + }, "Chunk.entrypoints: Use Chunk.getEntrypoints() instead"), + set: util.deprecate(function(value) { + this.setBlocks(value); + }, "Chunk.entrypoints: Use Chunk.addEntrypoint/setEntrypoints to modify entrypoints.") +}); + module.exports = Chunk; diff --git a/lib/Compilation.js b/lib/Compilation.js index 40da2e909..b542385e3 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -25,6 +25,7 @@ const CachedSource = require("webpack-sources").CachedSource; const Stats = require("./Stats"); const Semaphore = require("./util/Semaphore"); const Queue = require("./util/Queue"); +const SortableSet = require("./util/SortableSet"); function byId(a, b) { if(a.id < b.id) return -1; @@ -47,6 +48,12 @@ function iterationOfArrayCallback(arr, fn) { } } +function addAllToSet(set, otherSet) { + for(const item of otherSet) { + set.add(item); + } +} + class Compilation extends Tapable { constructor(compiler) { super(); @@ -1254,25 +1261,17 @@ class Compilation extends Tapable { } summarizeDependencies() { - function filterDups(array) { - const newArray = []; - for(let i = 0; i < array.length; i++) { - if(i === 0 || array[i - 1] !== array[i]) - newArray.push(array[i]); - } - return newArray; - } - this.fileDependencies = (this.compilationDependencies || []).slice(); - this.contextDependencies = []; - this.missingDependencies = []; + this.fileDependencies = new SortableSet(this.compilationDependencies); + this.contextDependencies = new SortableSet(); + this.missingDependencies = new SortableSet(); const children = this.children; for(let indexChildren = 0; indexChildren < children.length; indexChildren++) { const child = children[indexChildren]; - this.fileDependencies = this.fileDependencies.concat(child.fileDependencies); - this.contextDependencies = this.contextDependencies.concat(child.contextDependencies); - this.missingDependencies = this.missingDependencies.concat(child.missingDependencies); + addAllToSet(this.fileDependencies, child.fileDependencies); + addAllToSet(this.contextDependencies, child.contextDependencies); + addAllToSet(this.missingDependencies, child.missingDependencies); } const modules = this.modules; @@ -1280,29 +1279,20 @@ class Compilation extends Tapable { const module = modules[indexModule]; if(module.fileDependencies) { - const fileDependencies = module.fileDependencies; - for(let indexFileDep = 0; indexFileDep < fileDependencies.length; indexFileDep++) { - this.fileDependencies.push(fileDependencies[indexFileDep]); - } + addAllToSet(this.fileDependencies, module.fileDependencies); } if(module.contextDependencies) { - const contextDependencies = module.contextDependencies; - for(let indexContextDep = 0; indexContextDep < contextDependencies.length; indexContextDep++) { - this.contextDependencies.push(contextDependencies[indexContextDep]); - } + addAllToSet(this.contextDependencies, module.contextDependencies); } } this.errors.forEach(error => { - if(Array.isArray(error.missing)) { - error.missing.forEach(item => this.missingDependencies.push(item)); + if(typeof error.missing === "object" && error.missing && error.missing[Symbol.iterator]) { + addAllToSet(this.missingDependencies, error.missing); } }); this.fileDependencies.sort(); - this.fileDependencies = filterDups(this.fileDependencies); this.contextDependencies.sort(); - this.contextDependencies = filterDups(this.contextDependencies); this.missingDependencies.sort(); - this.missingDependencies = filterDups(this.missingDependencies); } createHash() { diff --git a/lib/Compiler.js b/lib/Compiler.js index 82b147992..cfbc92770 100644 --- a/lib/Compiler.js +++ b/lib/Compiler.js @@ -5,6 +5,7 @@ "use strict"; const path = require("path"); +const util = require("util"); const Tapable = require("tapable"); const Compilation = require("./Compilation"); @@ -104,7 +105,7 @@ class Watching { this.compiler.applyPlugins("done", stats); this.handler(null, stats); if(!this.closed) { - this.watch(compilation.fileDependencies, compilation.contextDependencies, compilation.missingDependencies); + this.watch(Array.from(compilation.fileDependencies), Array.from(compilation.contextDependencies), Array.from(compilation.missingDependencies)); } this.callbacks.forEach(cb => cb()); this.callbacks.length = 0; @@ -186,35 +187,25 @@ class Compiler extends Tapable { loader: null, context: null }; - let deprecationReported = false; this.parser = { - plugin: (hook, fn) => { - if(!deprecationReported) { - console.warn("webpack: Using compiler.parser is deprecated.\n" + - "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.plugin(/* ... */); });\n}); instead. " + - "It was called " + new Error().stack.split("\n")[2].trim() + "."); - deprecationReported = true; - } + plugin: util.deprecate((hook, fn) => { this.plugin("compilation", (compilation, data) => { data.normalModuleFactory.plugin("parser", parser => { parser.plugin(hook, fn); }); }); - }, - apply: () => { - const args = arguments; - if(!deprecationReported) { - console.warn("webpack: Using compiler.parser is deprecated.\n" + - "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.apply(/* ... */); });\n}); instead. " + - "It was called " + new Error().stack.split("\n")[2].trim() + "."); - deprecationReported = true; - } + }, "webpack: Using compiler.parser is deprecated.\n" + + "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.plugin(/* ... */); });\n}); instead. " + ), + apply: util.deprecate((...args) => { this.plugin("compilation", (compilation, data) => { data.normalModuleFactory.plugin("parser", parser => { - parser.apply.apply(parser, args); + parser.apply(...args); }); }); - } + }, "webpack: Using compiler.parser is deprecated.\n" + + "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.apply(/* ... */); });\n}); instead. " + ) }; this.options = {}; @@ -486,7 +477,7 @@ class Compiler extends Tapable { const params = { normalModuleFactory: this.createNormalModuleFactory(), contextModuleFactory: this.createContextModuleFactory(), - compilationDependencies: [] + compilationDependencies: new Set() }; return params; } diff --git a/lib/ContextModule.js b/lib/ContextModule.js index 342bd9291..bb03218fc 100644 --- a/lib/ContextModule.js +++ b/lib/ContextModule.js @@ -23,7 +23,7 @@ class ContextModule extends Module { this.options = options; this.cacheable = true; this.context = options.resource; - this.contextDependencies = [this.context]; + this.contextDependencies = new Set([this.context]); this.built = false; if(typeof options.mode !== "string") throw new Error("options.mode is a required option"); diff --git a/lib/DllReferencePlugin.js b/lib/DllReferencePlugin.js index bc314250c..10c8c2d80 100644 --- a/lib/DllReferencePlugin.js +++ b/lib/DllReferencePlugin.js @@ -25,7 +25,7 @@ class DllReferencePlugin { compiler.plugin("before-compile", (params, callback) => { const manifest = this.options.manifest; if(typeof manifest === "string") { - params.compilationDependencies.push(manifest); + params.compilationDependencies.add(manifest); compiler.inputFileSystem.readFile(manifest, function(err, result) { if(err) return callback(err); params["dll reference " + manifest] = JSON.parse(result.toString("utf-8")); diff --git a/lib/Entrypoint.js b/lib/Entrypoint.js index 8037fe5c5..bfe97aaea 100644 --- a/lib/Entrypoint.js +++ b/lib/Entrypoint.js @@ -11,8 +11,13 @@ class Entrypoint { } unshiftChunk(chunk) { - this.chunks.unshift(chunk); - chunk.entrypoints.push(this); + const oldIdx = this.chunks.indexOf(chunk); + if(oldIdx > 0) { + this.chunks.splice(oldIdx, 1); + this.chunks.unshift(chunk); + } else if(oldIdx < 0 && chunk.addEntrypoint(this)) { + this.chunks.unshift(chunk); + } } insertChunk(chunk, before) { @@ -26,22 +31,20 @@ class Entrypoint { this.chunks.splice(idx, 0, chunk); } else if(oldIdx < 0) { this.chunks.splice(idx, 0, chunk); - chunk.entrypoints.push(this); + chunk.addEntrypoint(this); } } getFiles() { - const files = []; + const files = new Set(); for(let chunkIdx = 0; chunkIdx < this.chunks.length; chunkIdx++) { for(let fileIdx = 0; fileIdx < this.chunks[chunkIdx].files.length; fileIdx++) { - if(files.indexOf(this.chunks[chunkIdx].files[fileIdx]) === -1) { - files.push(this.chunks[chunkIdx].files[fileIdx]); - } + files.add(this.chunks[chunkIdx].files[fileIdx]); } } - return files; + return Array.from(files); } getRuntimeChunk() { diff --git a/lib/JsonpChunkTemplatePlugin.js b/lib/JsonpChunkTemplatePlugin.js index 639003369..dd75e6728 100644 --- a/lib/JsonpChunkTemplatePlugin.js +++ b/lib/JsonpChunkTemplatePlugin.js @@ -15,7 +15,7 @@ class JsonpChunkTemplatePlugin { source.add(modules); const entries = [chunk.entryModule] .filter(Boolean) - .map(m => [m.id].concat(chunk.entrypoints[0].chunks.map(c => c.id))); + .map(m => [m.id].concat(chunk.getEntrypoints()[0].chunks.map(c => c.id))); if(entries.length > 0) { source.add(`,${JSON.stringify(entries)}`); } diff --git a/lib/JsonpMainTemplatePlugin.js b/lib/JsonpMainTemplatePlugin.js index f08cbee0f..6ac34a389 100644 --- a/lib/JsonpMainTemplatePlugin.js +++ b/lib/JsonpMainTemplatePlugin.js @@ -10,7 +10,7 @@ class JsonpMainTemplatePlugin { apply(mainTemplate) { function needChunkLoadingCode(chunk) { - var otherChunksInEntry = chunk.entrypoints.some(function(entrypoint) { + var otherChunksInEntry = chunk.getEntrypoints().some(function(entrypoint) { return entrypoint.chunks.length > 1; }); var onDemandChunks = chunk.getNumberOfChunks() > 0; diff --git a/lib/NormalModule.js b/lib/NormalModule.js index 95c80b7c5..840db5ed9 100644 --- a/lib/NormalModule.js +++ b/lib/NormalModule.js @@ -68,8 +68,8 @@ class NormalModule extends Module { this.resource = resource; this.context = getContext(resource); this.loaders = loaders; - this.fileDependencies = []; - this.contextDependencies = []; + this.fileDependencies = new Set(); + this.contextDependencies = new Set(); this.warnings = []; this.errors = []; this.error = null; @@ -184,8 +184,8 @@ class NormalModule extends Module { }, (err, result) => { if(result) { this.cacheable = result.cacheable; - this.fileDependencies = result.fileDependencies; - this.contextDependencies = result.contextDependencies; + this.fileDependencies = new Set(result.fileDependencies); + this.contextDependencies = new Set(result.contextDependencies); } if(err) { @@ -495,8 +495,7 @@ class NormalModule extends Module { getHighestTimestamp(keys, timestampsByKey) { let highestTimestamp = 0; - for(let i = 0; i < keys.length; i++) { - const key = keys[i]; + for(const key of keys) { const timestamp = timestampsByKey[key]; // if there is no timestamp yet, early return with Infinity if(!timestamp) return Infinity; @@ -506,26 +505,22 @@ class NormalModule extends Module { } needRebuild(fileTimestamps, contextTimestamps) { - const highestFileDepTimestamp = this.getHighestTimestamp( - this.fileDependencies, fileTimestamps); - // if the hightest is Infinity, we need a rebuild - // exit early here. - if(highestFileDepTimestamp === Infinity) { - return true; + + // Check timestamps of all dependencies + // Missing timestamp -> need rebuild + // Timestamp bigger than buildTimestamp -> need rebuild + for(const file of this.fileDependencies) { + const timestamp = fileTimestamps[file]; + if(!timestamp) return true; + if(timestamp >= this.buildTimestamp) return true; } - - const highestContextDepTimestamp = this.getHighestTimestamp( - this.contextDependencies, contextTimestamps); - - // Again if the hightest is Infinity, we need a rebuild - // exit early here. - if(highestContextDepTimestamp === Infinity) { - return true; + for(const file of this.contextDependencies) { + const timestamp = contextTimestamps[file]; + if(!timestamp) return true; + if(timestamp >= this.buildTimestamp) return true; } - - // else take the highest of file and context timestamps and compare - // to last build timestamp - return Math.max(highestContextDepTimestamp, highestFileDepTimestamp) >= this.buildTimestamp; + // elsewise -> no rebuild needed + return false; } size() { diff --git a/lib/WarnCaseSensitiveModulesPlugin.js b/lib/WarnCaseSensitiveModulesPlugin.js index 0146be773..7abc325d1 100644 --- a/lib/WarnCaseSensitiveModulesPlugin.js +++ b/lib/WarnCaseSensitiveModulesPlugin.js @@ -10,19 +10,21 @@ class WarnCaseSensitiveModulesPlugin { apply(compiler) { compiler.plugin("compilation", compilation => { compilation.plugin("seal", () => { - const moduleWithoutCase = Object.create(null); + const moduleWithoutCase = new Map(); compilation.modules.forEach(module => { const identifier = module.identifier().toLowerCase(); - if(moduleWithoutCase[identifier]) { - moduleWithoutCase[identifier].push(module); + const array = moduleWithoutCase.get(identifier); + if(array) { + array.push(module); } else { - moduleWithoutCase[identifier] = [module]; + moduleWithoutCase.set(identifier, [module]); } }); - Object.keys(moduleWithoutCase).forEach(key => { - if(moduleWithoutCase[key].length > 1) - compilation.warnings.push(new CaseSensitiveModulesWarning(moduleWithoutCase[key])); - }); + for(const pair of moduleWithoutCase) { + const array = pair[1]; + if(array.length > 1) + compilation.warnings.push(new CaseSensitiveModulesWarning(array)); + } }); }); } diff --git a/lib/optimize/CommonsChunkPlugin.js b/lib/optimize/CommonsChunkPlugin.js index 6432b3967..c6b192bea 100644 --- a/lib/optimize/CommonsChunkPlugin.js +++ b/lib/optimize/CommonsChunkPlugin.js @@ -369,7 +369,7 @@ Take a look at the "name"/"names" or async/children option.`); // add chunk to commonChunk commonChunk.addChunk(chunk); - for(const entrypoint of chunk.entrypoints.slice()) { + for(const entrypoint of chunk.getEntrypoints()) { entrypoint.insertChunk(commonChunk, chunk); } } diff --git a/lib/optimize/ConcatenatedModule.js b/lib/optimize/ConcatenatedModule.js index 94d7d878f..f0515a1fd 100644 --- a/lib/optimize/ConcatenatedModule.js +++ b/lib/optimize/ConcatenatedModule.js @@ -180,11 +180,11 @@ class ConcatenatedModule extends Module { this.dependencies = []; this.dependenciesWarnings = []; this.dependenciesErrors = []; - this.fileDependencies = []; - this.contextDependencies = []; + this.fileDependencies = new Set(); + this.contextDependencies = new Set(); this.warnings = []; this.errors = []; - this.assets = {}; + this.assets = undefined; this._orderedConcatenationList = this._createOrderedConcatenationList(rootModule, modulesSet); for(const info of this._orderedConcatenationList) { if(info.type === "concatenated") { @@ -198,15 +198,19 @@ class ConcatenatedModule extends Module { // populate dep errors m.dependenciesErrors.forEach(depError => this.dependenciesErrors.push(depError)); // populate file dependencies - if(m.fileDependencies) m.fileDependencies.forEach(file => this.fileDependencies.push(file)); + if(m.fileDependencies) m.fileDependencies.forEach(file => this.fileDependencies.add(file)); // populate context dependencies - if(m.contextDependencies) m.contextDependencies.forEach(context => this.contextDependencies.push(context)); + if(m.contextDependencies) m.contextDependencies.forEach(context => this.contextDependencies.add(context)); // populate warnings m.warnings.forEach(warning => this.warnings.push(warning)); // populate errors m.errors.forEach(error => this.errors.push(error)); - Object.assign(this.assets, m.assets); + if(m.assets) { + if(this.assets === undefined) + this.assets = Object.create(null); + Object.assign(this.assets, m.assets); + } } } } From a88fdc74bfc9e712ff5a939f65d115b64d1ed471 Mon Sep 17 00:00:00 2001 From: Michael Ciniawsky Date: Thu, 2 Nov 2017 23:28:34 +0100 Subject: [PATCH 11/85] refactor(bin/webpack): use `err.name` for error handling --- bin/webpack.js | 17 ++++++++++------- test/Validation.test.js | 23 +++++++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/bin/webpack.js b/bin/webpack.js index ab6f6e68d..469900c73 100644 --- a/bin/webpack.js +++ b/bin/webpack.js @@ -333,16 +333,19 @@ yargs.parse(process.argv.slice(2), (err, argv, output) => { var compiler; try { compiler = webpack(options); - } catch(e) { - var WebpackOptionsValidationError = require("../lib/WebpackOptionsValidationError"); - if(e instanceof WebpackOptionsValidationError) { + } catch(err) { + if(err.name === "WebpackOptionsValidationError") { if(argv.color) - console.error("\u001b[1m\u001b[31m" + e.message + "\u001b[39m\u001b[22m"); + console.error( + `\u001b[1m\u001b[31m${err.message}\u001b[39m\u001b[22m` + ); else - console.error(e.message); - process.exit(1); // eslint-disable-line no-process-exit + console.error(err.message); + // eslint-disable-next-line no-process-exit + process.exit(1); } - throw e; + + throw err; } if(argv.progress) { diff --git a/test/Validation.test.js b/test/Validation.test.js index 23b9bbd59..3429c4996 100644 --- a/test/Validation.test.js +++ b/test/Validation.test.js @@ -2,8 +2,8 @@ "use strict"; require("should"); + const webpack = require("../lib/webpack"); -const WebpackOptionsValidationError = require("../lib/WebpackOptionsValidationError"); describe("Validation", () => { const testCases = [{ @@ -207,30 +207,33 @@ describe("Validation", () => { foobar: true } }, - test(e) { - e.message.should.startWith("Invalid configuration object."); - e.message.split("\n").slice(1)[0].should.be.eql( + test(err) { + err.message.should.startWith("Invalid configuration object."); + err.message.split("\n").slice(1)[0].should.be.eql( " - configuration.stats should be one of these:" ); } }]; + testCases.forEach((testCase) => { it("should fail validation for " + testCase.name, () => { try { webpack(testCase.config); - } catch(e) { - if(!(e instanceof WebpackOptionsValidationError)) - throw e; + } catch(err) { + if(err.name !== 'WebpackOptionsValidationError') throw err; if(testCase.test) { - testCase.test(e); + testCase.test(err); + return; } - e.message.should.startWith("Invalid configuration object."); - e.message.split("\n").slice(1).should.be.eql(testCase.message); + err.message.should.startWith("Invalid configuration object."); + err.message.split("\n").slice(1).should.be.eql(testCase.message); + return; } + throw new Error("Validation didn't fail"); }); }); From 2a22cbd43d462333c16616e609eddfb69a171b6a Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 8 Nov 2017 05:58:48 +0100 Subject: [PATCH 12/85] code style fixes --- lib/Compiler.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/Compiler.js b/lib/Compiler.js index cfbc92770..82a79ac70 100644 --- a/lib/Compiler.js +++ b/lib/Compiler.js @@ -188,22 +188,26 @@ class Compiler extends Tapable { context: null }; this.parser = { - plugin: util.deprecate((hook, fn) => { - this.plugin("compilation", (compilation, data) => { - data.normalModuleFactory.plugin("parser", parser => { - parser.plugin(hook, fn); + plugin: util.deprecate( + (hook, fn) => { + this.plugin("compilation", (compilation, data) => { + data.normalModuleFactory.plugin("parser", parser => { + parser.plugin(hook, fn); + }); }); - }); - }, "webpack: Using compiler.parser is deprecated.\n" + + }, + "webpack: Using compiler.parser is deprecated.\n" + "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.plugin(/* ... */); });\n}); instead. " ), - apply: util.deprecate((...args) => { - this.plugin("compilation", (compilation, data) => { - data.normalModuleFactory.plugin("parser", parser => { - parser.apply(...args); + apply: util.deprecate( + (...args) => { + this.plugin("compilation", (compilation, data) => { + data.normalModuleFactory.plugin("parser", parser => { + parser.apply(...args); + }); }); - }); - }, "webpack: Using compiler.parser is deprecated.\n" + + }, + "webpack: Using compiler.parser is deprecated.\n" + "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.apply(/* ... */); });\n}); instead. " ) }; From 68db551cff1c1ced29c9b2201ccfceba0207d651 Mon Sep 17 00:00:00 2001 From: Michael Ciniawsky Date: Wed, 8 Nov 2017 06:48:01 +0100 Subject: [PATCH 13/85] test(binCases/errors): throw `WebpackOptionsValidationError` for invalid configs --- test/binCases/errors/validation/test.js | 5 +++++ test/binCases/errors/validation/webpack.config.js | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 test/binCases/errors/validation/test.js create mode 100644 test/binCases/errors/validation/webpack.config.js diff --git a/test/binCases/errors/validation/test.js b/test/binCases/errors/validation/test.js new file mode 100644 index 000000000..4159d904a --- /dev/null +++ b/test/binCases/errors/validation/test.js @@ -0,0 +1,5 @@ +"use strict"; + +module.exports = function(code, stdout, stderr) { + stderr[0].should.containEql("Invalid configuration object"); +}; diff --git a/test/binCases/errors/validation/webpack.config.js b/test/binCases/errors/validation/webpack.config.js new file mode 100644 index 000000000..916eb98e7 --- /dev/null +++ b/test/binCases/errors/validation/webpack.config.js @@ -0,0 +1,3 @@ +module.exports = { + postcss: () => {} +}; From 88ecff4fb9f21c1bc62d123c1ca0299373e67ccd Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 8 Nov 2017 11:29:58 +0100 Subject: [PATCH 14/85] getHighestTimestamp is no longer used --- lib/NormalModule.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/lib/NormalModule.js b/lib/NormalModule.js index 9ca2219ea..e8276939d 100644 --- a/lib/NormalModule.js +++ b/lib/NormalModule.js @@ -496,17 +496,6 @@ class NormalModule extends Module { return this._source; } - getHighestTimestamp(keys, timestampsByKey) { - let highestTimestamp = 0; - for(const key of keys) { - const timestamp = timestampsByKey[key]; - // if there is no timestamp yet, early return with Infinity - if(!timestamp) return Infinity; - highestTimestamp = Math.max(highestTimestamp, timestamp); - } - return highestTimestamp; - } - needRebuild(fileTimestamps, contextTimestamps) { // always try to rebuild in case of an error if(this.error) return true; From f7c2f8e470d44686a2758c2debe59b86b3396c12 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 8 Nov 2017 11:32:05 +0100 Subject: [PATCH 15/85] Update code style to arrow functions --- lib/CachePlugin.js | 2 +- lib/Chunk.js | 5 +- lib/Compilation.js | 298 ++++++++---------- lib/Compiler.js | 31 +- lib/ConstPlugin.js | 24 +- lib/ContextModule.js | 2 +- lib/ContextModuleFactory.js | 32 +- lib/ContextReplacementPlugin.js | 2 +- lib/DefinePlugin.js | 50 +-- lib/DependenciesBlock.js | 12 +- lib/DllPlugin.js | 4 +- lib/DllReferencePlugin.js | 2 +- lib/DynamicEntryPlugin.js | 2 +- lib/EntryOptionPlugin.js | 4 +- lib/EnvironmentPlugin.js | 14 +- ...valSourceMapDevToolModuleTemplatePlugin.js | 22 +- lib/ExportPropertyMainTemplatePlugin.js | 4 +- lib/ExtendedAPIPlugin.js | 12 +- lib/ExternalModuleFactoryPlugin.js | 23 +- lib/FlagDependencyExportsPlugin.js | 67 ++-- lib/FlagDependencyUsagePlugin.js | 63 ++-- lib/FunctionModuleTemplatePlugin.js | 12 +- lib/HotModuleReplacementPlugin.js | 106 ++++--- lib/JsonpChunkTemplatePlugin.js | 10 +- lib/JsonpHotUpdateChunkTemplatePlugin.js | 10 +- lib/JsonpMainTemplatePlugin.js | 128 ++++---- lib/LibraryTemplatePlugin.js | 8 +- lib/ModuleFilenameHelpers.js | 30 +- lib/MultiModule.js | 3 +- lib/NewWatchingPlugin.js | 2 +- lib/NodeStuffPlugin.js | 40 +-- lib/NormalModule.js | 10 +- lib/NormalModuleFactory.js | 8 +- lib/OptionsDefaulter.js | 12 +- lib/Parser.js | 66 ++-- lib/ParserHelpers.js | 16 +- lib/ProgressPlugin.js | 144 +++++---- lib/ProvidePlugin.js | 6 +- lib/RecordIdsPlugin.js | 13 +- lib/RequireJsStuffPlugin.js | 4 +- lib/RuleSet.js | 77 ++--- lib/SourceMapDevToolPlugin.js | 10 +- lib/Stats.js | 8 +- lib/Template.js | 38 +-- lib/TemplatedPathPlugin.js | 16 +- lib/compareLocations.js | 2 +- .../AMDDefineDependencyParserPlugin.js | 4 +- lib/dependencies/AMDPlugin.js | 4 +- .../CommonJsRequireDependencyParserPlugin.js | 2 +- lib/dependencies/ContextDependency.js | 4 +- lib/dependencies/ContextDependencyHelpers.js | 6 +- lib/dependencies/DepBlockHelpers.js | 9 +- .../HarmonyDetectionParserPlugin.js | 25 +- ...armonyExportImportedSpecifierDependency.js | 4 +- lib/dependencies/LoaderPlugin.js | 8 +- lib/dependencies/SystemPlugin.js | 10 +- lib/dependencies/getFunctionExpression.js | 2 +- lib/node/NodeChunkTemplatePlugin.js | 4 +- lib/node/NodeHotUpdateChunkTemplatePlugin.js | 6 +- lib/node/NodeMainTemplatePlugin.js | 82 ++--- lib/node/NodeSourcePlugin.js | 26 +- lib/optimize/AggressiveMergingPlugin.js | 5 +- lib/optimize/AggressiveSplittingPlugin.js | 18 +- lib/optimize/ConcatenatedModule.js | 66 ++-- lib/optimize/ModuleConcatenationPlugin.js | 12 +- lib/optimize/OccurrenceOrderPlugin.js | 4 +- lib/optimize/RemoveParentModulesPlugin.js | 8 +- lib/performance/SizeLimitsPlugin.js | 4 +- lib/prepareOptions.js | 32 +- lib/removeAndDo.js | 3 +- lib/validateSchema.js | 17 +- lib/webpack.js | 9 +- lib/webworker/WebWorkerChunkTemplatePlugin.js | 10 +- .../WebWorkerHotUpdateChunkTemplatePlugin.js | 10 +- lib/webworker/WebWorkerMainTemplatePlugin.js | 70 ++-- 75 files changed, 953 insertions(+), 965 deletions(-) diff --git a/lib/CachePlugin.js b/lib/CachePlugin.js index 0620311ad..3b30f09aa 100644 --- a/lib/CachePlugin.js +++ b/lib/CachePlugin.js @@ -65,7 +65,7 @@ class CachePlugin { callback(); }); }); - compiler.plugin("after-compile", function(compilation, callback) { + compiler.plugin("after-compile", (compilation, callback) => { compilation.compiler._lastCompilationFileDependencies = compilation.fileDependencies; compilation.compiler._lastCompilationContextDependencies = compilation.contextDependencies; callback(); diff --git a/lib/Chunk.js b/lib/Chunk.js index f2d38d3de..0d5990a11 100644 --- a/lib/Chunk.js +++ b/lib/Chunk.js @@ -501,7 +501,7 @@ class Chunk { const chunksProcessed = []; const chunkHashMap = {}; const chunkNameMap = {}; - (function addChunk(chunk) { + const addChunk = chunk => { if(chunksProcessed.indexOf(chunk) >= 0) return; chunksProcessed.push(chunk); if(!chunk.hasRuntime() || includeEntries) { @@ -510,7 +510,8 @@ class Chunk { chunkNameMap[chunk.id] = chunk.name; } chunk._chunks.forEach(addChunk); - }(this)); + }; + addChunk(this); return { hash: chunkHashMap, name: chunkNameMap diff --git a/lib/Compilation.js b/lib/Compilation.js index bd30bcaea..87d9832fb 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -26,26 +26,26 @@ const Stats = require("./Stats"); const Semaphore = require("./util/Semaphore"); const Queue = require("./util/Queue"); -function byId(a, b) { +const byId = (a, b) => { if(a.id < b.id) return -1; if(a.id > b.id) return 1; return 0; -} +}; -function iterationBlockVariable(variables, fn) { +const iterationBlockVariable = (variables, fn) => { for(let indexVariable = 0; indexVariable < variables.length; indexVariable++) { let varDep = variables[indexVariable].dependencies; for(let indexVDep = 0; indexVDep < varDep.length; indexVDep++) { fn(varDep[indexVDep]); } } -} +}; -function iterationOfArrayCallback(arr, fn) { +const iterationOfArrayCallback = (arr, fn) => { for(let index = 0; index < arr.length; index++) { fn(arr[index]); } -} +}; class Compilation extends Tapable { constructor(compiler) { @@ -197,16 +197,16 @@ class Compilation extends Tapable { processModuleDependencies(module, callback) { const dependencies = []; - function addDependency(dep) { + const addDependency = dep => { for(let i = 0; i < dependencies.length; i++) { if(dep.isEqualResource(dependencies[i][0])) { return dependencies[i].push(dep); } } dependencies.push([dep]); - } + }; - function addDependenciesBlock(block) { + const addDependenciesBlock = block => { if(block.dependencies) { iterationOfArrayCallback(block.dependencies, addDependency); } @@ -216,7 +216,8 @@ class Compilation extends Tapable { if(block.variables) { iterationBlockVariable(block.variables, addDependency); } - } + }; + addDependenciesBlock(module); this.addModuleDependencies(module, dependencies, this.bail, null, true, callback); } @@ -233,10 +234,10 @@ class Compilation extends Tapable { } factories[i] = [factory, dependencies[i]]; } - asyncLib.forEach(factories, function iteratorFactory(item, callback) { + asyncLib.forEach(factories, (item, callback) => { const dependencies = item[1]; - const errorAndCallback = function errorAndCallback(err) { + const errorAndCallback = err => { err.origin = module; _this.errors.push(err); if(bail) { @@ -245,7 +246,7 @@ class Compilation extends Tapable { callback(); } }; - const warningAndCallback = function warningAndCallback(err) { + const warningAndCallback = err => { err.origin = module; _this.warnings.push(err); callback(); @@ -263,30 +264,30 @@ class Compilation extends Tapable { }, context: module.context, dependencies: dependencies - }, function factoryCallback(err, dependentModule) { + }, (err, dependentModule) => { if(_this === null) return semaphore.release(); let afterFactory; - function isOptional() { + const isOptional = () => { return dependencies.every(d => d.optional); - } + }; - function errorOrWarningAndCallback(err) { + const errorOrWarningAndCallback = err => { if(isOptional()) { return warningAndCallback(err); } else { return errorAndCallback(err); } - } + }; - function iterationDependencies(depend) { + const iterationDependencies = depend => { for(let index = 0; index < depend.length; index++) { const dep = depend[index]; dep.module = dependentModule; dependentModule.addReason(module, dep); } - } + }; if(err) { semaphore.release(); @@ -376,7 +377,7 @@ class Compilation extends Tapable { }); }); - }, function finalCallbackAddModuleDependencies(err) { + }, err => { // In V8, the Error objects keep a reference to the functions on the stack. These warnings & // errors are created inside closures that keep a reference to the Compilation, so errors are // leaking the Compilation object. Setting _this to null workarounds the following issue in V8. @@ -457,6 +458,17 @@ class Compilation extends Tapable { return; } + const moduleReady = () => { + this.semaphore.release(); + this.processModuleDependencies(module, err => { + if(err) { + return callback(err); + } + + return callback(null, module); + }); + }; + if(result instanceof Module) { if(this.profile) { result.profile = module.profile; @@ -469,7 +481,7 @@ class Compilation extends Tapable { dependency.module = module; module.addReason(null, dependency); - moduleReady.call(this); + moduleReady(); return; } @@ -478,7 +490,7 @@ class Compilation extends Tapable { dependency.module = module; module.addReason(null, dependency); - this.buildModule(module, false, null, null, (err) => { + this.buildModule(module, false, null, null, err => { if(err) { this.semaphore.release(); return errorAndCallback(err); @@ -489,19 +501,8 @@ class Compilation extends Tapable { module.profile.building = afterBuilding - afterFactory; } - moduleReady.call(this); + moduleReady(); }); - - function moduleReady() { - this.semaphore.release(); - this.processModuleDependencies(module, err => { - if(err) { - return callback(err); - } - - return callback(null, module); - }); - } }); }); } @@ -591,118 +592,117 @@ class Compilation extends Tapable { } seal(callback) { - const self = this; - self.applyPlugins0("seal"); + this.applyPlugins0("seal"); - while(self.applyPluginsBailResult1("optimize-dependencies-basic", self.modules) || - self.applyPluginsBailResult1("optimize-dependencies", self.modules) || - self.applyPluginsBailResult1("optimize-dependencies-advanced", self.modules)) { /* empty */ } - self.applyPlugins1("after-optimize-dependencies", self.modules); + while(this.applyPluginsBailResult1("optimize-dependencies-basic", this.modules) || + this.applyPluginsBailResult1("optimize-dependencies", this.modules) || + this.applyPluginsBailResult1("optimize-dependencies-advanced", this.modules)) { /* empty */ } + this.applyPlugins1("after-optimize-dependencies", this.modules); - self.nextFreeModuleIndex = 0; - self.nextFreeModuleIndex2 = 0; - self.preparedChunks.forEach(preparedChunk => { + this.nextFreeModuleIndex = 0; + this.nextFreeModuleIndex2 = 0; + this.preparedChunks.forEach(preparedChunk => { const module = preparedChunk.module; - const chunk = self.addChunk(preparedChunk.name, module); - const entrypoint = self.entrypoints[chunk.name] = new Entrypoint(chunk.name); + const chunk = this.addChunk(preparedChunk.name, module); + const entrypoint = this.entrypoints[chunk.name] = new Entrypoint(chunk.name); entrypoint.unshiftChunk(chunk); chunk.addModule(module); module.addChunk(chunk); chunk.entryModule = module; - self.assignIndex(module); - self.assignDepth(module); + this.assignIndex(module); + this.assignDepth(module); }); - self.processDependenciesBlocksForChunks(self.chunks.slice()); - self.sortModules(self.modules); - self.applyPlugins0("optimize"); + this.processDependenciesBlocksForChunks(this.chunks.slice()); + this.sortModules(this.modules); + this.applyPlugins0("optimize"); - while(self.applyPluginsBailResult1("optimize-modules-basic", self.modules) || - self.applyPluginsBailResult1("optimize-modules", self.modules) || - self.applyPluginsBailResult1("optimize-modules-advanced", self.modules)) { /* empty */ } - self.applyPlugins1("after-optimize-modules", self.modules); + while(this.applyPluginsBailResult1("optimize-modules-basic", this.modules) || + this.applyPluginsBailResult1("optimize-modules", this.modules) || + this.applyPluginsBailResult1("optimize-modules-advanced", this.modules)) { /* empty */ } + this.applyPlugins1("after-optimize-modules", this.modules); - while(self.applyPluginsBailResult1("optimize-chunks-basic", self.chunks) || - self.applyPluginsBailResult1("optimize-chunks", self.chunks) || - self.applyPluginsBailResult1("optimize-chunks-advanced", self.chunks)) { /* empty */ } - self.applyPlugins1("after-optimize-chunks", self.chunks); + while(this.applyPluginsBailResult1("optimize-chunks-basic", this.chunks) || + this.applyPluginsBailResult1("optimize-chunks", this.chunks) || + this.applyPluginsBailResult1("optimize-chunks-advanced", this.chunks)) { /* empty */ } + this.applyPlugins1("after-optimize-chunks", this.chunks); - self.applyPluginsAsyncSeries("optimize-tree", self.chunks, self.modules, function sealPart2(err) { + this.applyPluginsAsyncSeries("optimize-tree", this.chunks, this.modules, err => { if(err) { return callback(err); } - self.applyPlugins2("after-optimize-tree", self.chunks, self.modules); + this.applyPlugins2("after-optimize-tree", this.chunks, this.modules); - while(self.applyPluginsBailResult("optimize-chunk-modules-basic", self.chunks, self.modules) || - self.applyPluginsBailResult("optimize-chunk-modules", self.chunks, self.modules) || - self.applyPluginsBailResult("optimize-chunk-modules-advanced", self.chunks, self.modules)) { /* empty */ } - self.applyPlugins2("after-optimize-chunk-modules", self.chunks, self.modules); + while(this.applyPluginsBailResult("optimize-chunk-modules-basic", this.chunks, this.modules) || + this.applyPluginsBailResult("optimize-chunk-modules", this.chunks, this.modules) || + this.applyPluginsBailResult("optimize-chunk-modules-advanced", this.chunks, this.modules)) { /* empty */ } + this.applyPlugins2("after-optimize-chunk-modules", this.chunks, this.modules); - const shouldRecord = self.applyPluginsBailResult("should-record") !== false; + const shouldRecord = this.applyPluginsBailResult("should-record") !== false; - self.applyPlugins2("revive-modules", self.modules, self.records); - self.applyPlugins1("optimize-module-order", self.modules); - self.applyPlugins1("advanced-optimize-module-order", self.modules); - self.applyPlugins1("before-module-ids", self.modules); - self.applyPlugins1("module-ids", self.modules); - self.applyModuleIds(); - self.applyPlugins1("optimize-module-ids", self.modules); - self.applyPlugins1("after-optimize-module-ids", self.modules); + this.applyPlugins2("revive-modules", this.modules, this.records); + this.applyPlugins1("optimize-module-order", this.modules); + this.applyPlugins1("advanced-optimize-module-order", this.modules); + this.applyPlugins1("before-module-ids", this.modules); + this.applyPlugins1("module-ids", this.modules); + this.applyModuleIds(); + this.applyPlugins1("optimize-module-ids", this.modules); + this.applyPlugins1("after-optimize-module-ids", this.modules); - self.sortItemsWithModuleIds(); + this.sortItemsWithModuleIds(); - self.applyPlugins2("revive-chunks", self.chunks, self.records); - self.applyPlugins1("optimize-chunk-order", self.chunks); - self.applyPlugins1("before-chunk-ids", self.chunks); - self.applyChunkIds(); - self.applyPlugins1("optimize-chunk-ids", self.chunks); - self.applyPlugins1("after-optimize-chunk-ids", self.chunks); + this.applyPlugins2("revive-chunks", this.chunks, this.records); + this.applyPlugins1("optimize-chunk-order", this.chunks); + this.applyPlugins1("before-chunk-ids", this.chunks); + this.applyChunkIds(); + this.applyPlugins1("optimize-chunk-ids", this.chunks); + this.applyPlugins1("after-optimize-chunk-ids", this.chunks); - self.sortItemsWithChunkIds(); + this.sortItemsWithChunkIds(); if(shouldRecord) - self.applyPlugins2("record-modules", self.modules, self.records); + this.applyPlugins2("record-modules", this.modules, this.records); if(shouldRecord) - self.applyPlugins2("record-chunks", self.chunks, self.records); + this.applyPlugins2("record-chunks", this.chunks, this.records); - self.applyPlugins0("before-hash"); - self.createHash(); - self.applyPlugins0("after-hash"); + this.applyPlugins0("before-hash"); + this.createHash(); + this.applyPlugins0("after-hash"); if(shouldRecord) - self.applyPlugins1("record-hash", self.records); + this.applyPlugins1("record-hash", this.records); - self.applyPlugins0("before-module-assets"); - self.createModuleAssets(); - if(self.applyPluginsBailResult("should-generate-chunk-assets") !== false) { - self.applyPlugins0("before-chunk-assets"); - self.createChunkAssets(); + this.applyPlugins0("before-module-assets"); + this.createModuleAssets(); + if(this.applyPluginsBailResult("should-generate-chunk-assets") !== false) { + this.applyPlugins0("before-chunk-assets"); + this.createChunkAssets(); } - self.applyPlugins1("additional-chunk-assets", self.chunks); - self.summarizeDependencies(); + this.applyPlugins1("additional-chunk-assets", this.chunks); + this.summarizeDependencies(); if(shouldRecord) - self.applyPlugins2("record", self, self.records); + this.applyPlugins2("record", this, this.records); - self.applyPluginsAsync("additional-assets", err => { + this.applyPluginsAsync("additional-assets", err => { if(err) { return callback(err); } - self.applyPluginsAsync("optimize-chunk-assets", self.chunks, err => { + this.applyPluginsAsync("optimize-chunk-assets", this.chunks, err => { if(err) { return callback(err); } - self.applyPlugins1("after-optimize-chunk-assets", self.chunks); - self.applyPluginsAsync("optimize-assets", self.assets, err => { + this.applyPlugins1("after-optimize-chunk-assets", this.chunks); + this.applyPluginsAsync("optimize-assets", this.assets, err => { if(err) { return callback(err); } - self.applyPlugins1("after-optimize-assets", self.assets); - if(self.applyPluginsBailResult("need-additional-seal")) { - self.unseal(); - return self.seal(callback); + this.applyPlugins1("after-optimize-assets", this.assets); + if(this.applyPluginsBailResult("need-additional-seal")) { + this.unseal(); + return this.seal(callback); } - return self.applyPluginsAsync("after-seal", callback); + return this.applyPluginsAsync("after-seal", callback); }); }); }); @@ -770,15 +770,7 @@ class Compilation extends Tapable { assignIndex(module) { const _this = this; - const queue = [() => { - assignIndexToModule(module); - }]; - - const iteratorAllDependencies = d => { - queue.push(() => assignIndexToDependency(d)); - }; - - function assignIndexToModule(module) { + const assignIndexToModule = module => { // enter module if(typeof module.index !== "number") { module.index = _this.nextFreeModuleIndex++; @@ -789,24 +781,20 @@ class Compilation extends Tapable { // enter it as block assignIndexToDependencyBlock(module); } - } + }; - function assignIndexToDependency(dependency) { + const assignIndexToDependency = dependency => { if(dependency.module) { queue.push(() => assignIndexToModule(dependency.module)); } - } + }; - function assignIndexToDependencyBlock(block) { + const assignIndexToDependencyBlock = block => { let allDependencies = []; - function iteratorDependency(d) { - allDependencies.push(d); - } + const iteratorDependency = d => allDependencies.push(d); - function iteratorBlock(b) { - queue.push(() => assignIndexToDependencyBlock(b)); - } + const iteratorBlock = b => queue.push(() => assignIndexToDependencyBlock(b)); if(block.variables) { iterationBlockVariable(block.variables, iteratorDependency); @@ -827,7 +815,15 @@ class Compilation extends Tapable { while(indexAll--) { iteratorAllDependencies(allDependencies[indexAll]); } - } + }; + + const queue = [() => { + assignIndexToModule(module); + }]; + + const iteratorAllDependencies = d => { + queue.push(() => assignIndexToDependency(d)); + }; while(queue.length) { queue.pop()(); @@ -835,29 +831,25 @@ class Compilation extends Tapable { } assignDepth(module) { - function assignDepthToModule(module, depth) { + const assignDepthToModule = (module, depth) => { // enter module if(typeof module.depth === "number" && module.depth <= depth) return; module.depth = depth; // enter it as block assignDepthToDependencyBlock(module, depth + 1); - } + }; - function assignDepthToDependency(dependency, depth) { + const assignDepthToDependency = (dependency, depth) => { if(dependency.module) { queue.push(() => assignDepthToModule(dependency.module, depth)); } - } + }; - function assignDepthToDependencyBlock(block, depth) { - function iteratorDependency(d) { - assignDepthToDependency(d, depth); - } + const assignDepthToDependencyBlock = (block, depth) => { + const iteratorDependency = d => assignDepthToDependency(d, depth); - function iteratorBlock(b) { - assignDepthToDependencyBlock(b, depth); - } + const iteratorBlock = b => assignDepthToDependencyBlock(b, depth); if(block.variables) { iterationBlockVariable(block.variables, iteratorDependency); @@ -870,11 +862,12 @@ class Compilation extends Tapable { if(block.blocks) { iterationOfArrayCallback(block.blocks, iteratorBlock); } - } + }; const queue = [() => { assignDepthToModule(module, 0); }]; + while(queue.length) { queue.pop()(); } @@ -1220,26 +1213,21 @@ class Compilation extends Tapable { const unusedIds = []; let nextFreeChunkId = 0; - function getNextFreeChunkId(usedChunkIds) { - const keyChunks = Object.keys(usedChunkIds); - let result = -1; + if(this.usedChunkIds) { + + const keyChunks = Object.keys(this.usedChunkIds); for(let index = 0; index < keyChunks.length; index++) { const usedIdKey = keyChunks[index]; - const usedIdValue = usedChunkIds[usedIdKey]; + const usedIdValue = this.usedChunkIds[usedIdKey]; if(typeof usedIdValue !== "number") { continue; } - result = Math.max(result, usedIdValue); + nextFreeChunkId = Math.max(nextFreeChunkId - 1, usedIdValue) + 1; } - return result; - } - - if(this.usedChunkIds) { - nextFreeChunkId = getNextFreeChunkId(this.usedChunkIds) + 1; let index = nextFreeChunkId; while(index--) { if(this.usedChunkIds[index] !== index) { @@ -1303,14 +1291,14 @@ class Compilation extends Tapable { } summarizeDependencies() { - function filterDups(array) { + const filterDups = array => { const newArray = []; for(let i = 0; i < array.length; i++) { if(i === 0 || array[i - 1] !== array[i]) newArray.push(array[i]); } return newArray; - } + }; this.fileDependencies = (this.compilationDependencies || []).slice(); this.contextDependencies = []; this.missingDependencies = []; @@ -1365,15 +1353,9 @@ class Compilation extends Tapable { this.mainTemplate.updateHash(hash); this.chunkTemplate.updateHash(hash); this.moduleTemplate.updateHash(hash); - this.children.forEach(function(child) { - hash.update(child.hash); - }); - this.warnings.forEach(function(warning) { - hash.update(`${warning.message}`); - }); - this.errors.forEach(function(error) { - hash.update(`${error.message}`); - }); + this.children.forEach(child => hash.update(child.hash)); + this.warnings.forEach(warning => hash.update(`${warning.message}`)); + this.errors.forEach(error => hash.update(`${error.message}`)); // clone needed as sort below is inplace mutation const chunks = this.chunks.slice(); /** diff --git a/lib/Compiler.js b/lib/Compiler.js index 82b147992..48c964995 100644 --- a/lib/Compiler.js +++ b/lib/Compiler.js @@ -143,7 +143,7 @@ class Watching { } close(callback) { - if(callback === undefined) callback = function() {}; + if(callback === undefined) callback = () => {}; this.closed = true; if(this.watcher) { @@ -351,7 +351,11 @@ class Compiler extends Tapable { }, err => { if(err) return callback(err); - afterEmit.call(this); + this.applyPluginsAsyncSeries1("after-emit", compilation, err => { + if(err) return callback(err); + + return callback(); + }); }); }; @@ -360,15 +364,6 @@ class Compiler extends Tapable { outputPath = compilation.getPath(this.outputPath); this.outputFileSystem.mkdirp(outputPath, emitFiles); }); - - function afterEmit() { - this.applyPluginsAsyncSeries1("after-emit", compilation, err => { - if(err) return callback(err); - - return callback(); - }); - } - } emitRecords(callback) { @@ -378,15 +373,17 @@ class Compiler extends Tapable { let recordsOutputPathDirectory = null; if(idx1 > idx2) recordsOutputPathDirectory = this.recordsOutputPath.substr(0, idx1); if(idx1 < idx2) recordsOutputPathDirectory = this.recordsOutputPath.substr(0, idx2); - if(!recordsOutputPathDirectory) return writeFile.call(this); + + const writeFile = () => { + this.outputFileSystem.writeFile(this.recordsOutputPath, JSON.stringify(this.records, undefined, 2), callback); + }; + + if(!recordsOutputPathDirectory) + return writeFile(); this.outputFileSystem.mkdirp(recordsOutputPathDirectory, err => { if(err) return callback(err); - writeFile.call(this); + writeFile(); }); - - function writeFile() { - this.outputFileSystem.writeFile(this.recordsOutputPath, JSON.stringify(this.records, undefined, 2), callback); - } } readRecords(callback) { diff --git a/lib/ConstPlugin.js b/lib/ConstPlugin.js index 33cd30a31..294be09a7 100644 --- a/lib/ConstPlugin.js +++ b/lib/ConstPlugin.js @@ -19,37 +19,37 @@ class ConstPlugin { compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); params.normalModuleFactory.plugin("parser", parser => { - parser.plugin("statement if", function(statement) { - const param = this.evaluateExpression(statement.test); + parser.plugin("statement if", statement => { + const param = parser.evaluateExpression(statement.test); const bool = param.asBool(); if(typeof bool === "boolean") { if(statement.test.type !== "Literal") { const dep = new ConstDependency(`${bool}`, param.range); dep.loc = statement.loc; - this.state.current.addDependency(dep); + parser.state.current.addDependency(dep); } return bool; } }); - parser.plugin("expression ?:", function(expression) { - const param = this.evaluateExpression(expression.test); + parser.plugin("expression ?:", expression => { + const param = parser.evaluateExpression(expression.test); const bool = param.asBool(); if(typeof bool === "boolean") { if(expression.test.type !== "Literal") { const dep = new ConstDependency(` ${bool}`, param.range); dep.loc = expression.loc; - this.state.current.addDependency(dep); + parser.state.current.addDependency(dep); } return bool; } }); - parser.plugin("evaluate Identifier __resourceQuery", function(expr) { - if(!this.state.module) return; - return ParserHelpers.evaluateToString(getQuery(this.state.module.resource))(expr); + parser.plugin("evaluate Identifier __resourceQuery", expr => { + if(!parser.state.module) return; + return ParserHelpers.evaluateToString(getQuery(parser.state.module.resource))(expr); }); - parser.plugin("expression __resourceQuery", function() { - if(!this.state.module) return; - this.state.current.addVariable("__resourceQuery", JSON.stringify(getQuery(this.state.module.resource))); + parser.plugin("expression __resourceQuery", () => { + if(!parser.state.module) return; + parser.state.current.addVariable("__resourceQuery", JSON.stringify(getQuery(parser.state.module.resource))); return true; }); }); diff --git a/lib/ContextModule.js b/lib/ContextModule.js index 6ea5c6a73..240b88e09 100644 --- a/lib/ContextModule.js +++ b/lib/ContextModule.js @@ -194,7 +194,7 @@ class ContextModule extends Module { return 0; } return a.userRequest < b.userRequest ? -1 : 1; - }).reduce(function(map, dep) { + }).reduce((map, dep) => { map[dep.userRequest] = dep.module.id; return map; }, Object.create(null)); diff --git a/lib/ContextModuleFactory.js b/lib/ContextModuleFactory.js index d4dd8ad31..774444c51 100644 --- a/lib/ContextModuleFactory.js +++ b/lib/ContextModuleFactory.js @@ -53,15 +53,15 @@ module.exports = class ContextModuleFactory extends Tapable { const resolvers = this.resolvers; asyncLib.parallel([ - function(callback) { - resolvers.context.resolve({}, context, resource, function(err, result) { + callback => { + resolvers.context.resolve({}, context, resource, (err, result) => { if(err) return callback(err); callback(null, result); }); }, - function(callback) { - asyncLib.map(loaders, function(loader, callback) { - resolvers.loader.resolve({}, context, loader, function(err, result) { + callback => { + asyncLib.map(loaders, (loader, callback) => { + resolvers.loader.resolve({}, context, loader, (err, result) => { if(err) return callback(err); callback(null, result); }); @@ -74,7 +74,7 @@ module.exports = class ContextModuleFactory extends Tapable { addon: loadersPrefix + result[1].join("!") + (result[1].length > 0 ? "!" : ""), resource: result[0], resolveDependencies: this.resolveDependencies.bind(this), - }, beforeResolveResult), function(err, result) { + }, beforeResolveResult), (err, result) => { if(err) return callback(err); // Ignored @@ -95,14 +95,12 @@ module.exports = class ContextModuleFactory extends Tapable { let exclude = options.exclude; if(!regExp || !resource) return callback(null, []); - (function addDirectory(directory, callback) { + const addDirectory = (directory, callback) => { fs.readdir(directory, (err, files) => { if(err) return callback(err); files = cmf.applyPluginsWaterfall("context-module-files", files); if(!files || files.length === 0) return callback(null, []); - asyncLib.map(files.filter(function(p) { - return p.indexOf(".") !== 0; - }), (seqment, callback) => { + asyncLib.map(files.filter(p => p.indexOf(".") !== 0), (seqment, callback) => { const subResource = path.join(directory, seqment); @@ -132,9 +130,7 @@ module.exports = class ContextModuleFactory extends Tapable { this.applyPluginsAsyncWaterfall("alternatives", [obj], (err, alternatives) => { if(err) return callback(err); - alternatives = alternatives.filter(function(obj) { - return regExp.test(obj.request); - }).map(function(obj) { + alternatives = alternatives.filter(obj => regExp.test(obj.request)).map(obj => { const dep = new ContextElementDependency(obj.request); dep.optional = true; return dep; @@ -151,13 +147,11 @@ module.exports = class ContextModuleFactory extends Tapable { if(!result) return callback(null, []); - callback(null, result.filter(function(i) { - return !!i; - }).reduce(function(a, i) { - return a.concat(i); - }, [])); + callback(null, result.filter(Boolean).reduce((a, i) => a.concat(i), [])); }); }); - }.call(this, resource, callback)); + }; + + addDirectory(resource, callback); } }; diff --git a/lib/ContextReplacementPlugin.js b/lib/ContextReplacementPlugin.js index 92f0bf249..5a1acee7d 100644 --- a/lib/ContextReplacementPlugin.js +++ b/lib/ContextReplacementPlugin.js @@ -97,7 +97,7 @@ class ContextReplacementPlugin { } const createResolveDependenciesFromContextMap = (createContextMap) => { - return function resolveDependenciesFromContextMap(fs, options, callback) { + return (fs, options, callback) => { createContextMap(fs, (err, map) => { if(err) return callback(err); const dependencies = Object.keys(map).map((key) => { diff --git a/lib/DefinePlugin.js b/lib/DefinePlugin.js index 6b4362d76..9f03f6c4d 100644 --- a/lib/DefinePlugin.js +++ b/lib/DefinePlugin.js @@ -9,6 +9,22 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression"); const ParserHelpers = require("./ParserHelpers"); const NullFactory = require("./NullFactory"); +const stringifyObj = obj => { + return "Object({" + Object.keys(obj).map((key) => { + const code = obj[key]; + return JSON.stringify(key) + ":" + toCode(code); + }).join(",") + "})"; +}; + +const toCode = code => { + if(code === null) return "null"; + else if(code === undefined) return "undefined"; + else if(code instanceof RegExp && code.toString) return code.toString(); + else if(typeof code === "function" && code.toString) return "(" + code.toString() + ")"; + else if(typeof code === "object") return stringifyObj(code); + else return code + ""; +}; + class DefinePlugin { constructor(definitions) { this.definitions = definitions; @@ -21,7 +37,7 @@ class DefinePlugin { compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); params.normalModuleFactory.plugin("parser", (parser) => { - (function walkDefinitions(definitions, prefix) { + const walkDefinitions = (definitions, prefix) => { Object.keys(definitions).forEach((key) => { const code = definitions[key]; if(code && typeof code === "object" && !(code instanceof RegExp)) { @@ -32,33 +48,17 @@ class DefinePlugin { applyDefineKey(prefix, key); applyDefine(prefix + key, code); }); - }(definitions, "")); + }; - function stringifyObj(obj) { - return "Object({" + Object.keys(obj).map((key) => { - const code = obj[key]; - return JSON.stringify(key) + ":" + toCode(code); - }).join(",") + "})"; - } - - function toCode(code) { - if(code === null) return "null"; - else if(code === undefined) return "undefined"; - else if(code instanceof RegExp && code.toString) return code.toString(); - else if(typeof code === "function" && code.toString) return "(" + code.toString() + ")"; - else if(typeof code === "object") return stringifyObj(code); - else return code + ""; - } - - function applyDefineKey(prefix, key) { + const applyDefineKey = (prefix, key) => { const splittedKey = key.split("."); splittedKey.slice(1).forEach((_, i) => { const fullKey = prefix + splittedKey.slice(0, i + 1).join("."); parser.plugin("can-rename " + fullKey, ParserHelpers.approve); }); - } + }; - function applyDefine(key, code) { + const applyDefine = (key, code) => { const isTypeof = /^typeof\s+/.test(key); if(isTypeof) key = key.replace(/^typeof\s+/, ""); let recurse = false; @@ -106,16 +106,18 @@ class DefinePlugin { if(!res.isString()) return; return ParserHelpers.toConstantDependency(JSON.stringify(res.string)).bind(parser)(expr); }); - } + }; - function applyObjectDefine(key, obj) { + const applyObjectDefine = (key, obj) => { const code = stringifyObj(obj); parser.plugin("can-rename " + key, ParserHelpers.approve); parser.plugin("evaluate Identifier " + key, (expr) => new BasicEvaluatedExpression().setTruthy().setRange(expr.range)); parser.plugin("evaluate typeof " + key, ParserHelpers.evaluateToString("object")); parser.plugin("expression " + key, ParserHelpers.toConstantDependency(code)); parser.plugin("typeof " + key, ParserHelpers.toConstantDependency(JSON.stringify("object"))); - } + }; + + walkDefinitions(definitions, ""); }); }); } diff --git a/lib/DependenciesBlock.js b/lib/DependenciesBlock.js index 741c499b7..dc8f8d437 100644 --- a/lib/DependenciesBlock.js +++ b/lib/DependenciesBlock.js @@ -6,13 +6,9 @@ const DependenciesBlockVariable = require("./DependenciesBlockVariable"); -function disconnect(i) { - i.disconnect(); -} +const disconnect = i => i.disconnect(); -function unseal(i) { - i.unseal(); -} +const unseal = i => i.unseal(); class DependenciesBlock { constructor() { @@ -46,9 +42,7 @@ class DependenciesBlock { } updateHash(hash) { - function updateHash(i) { - i.updateHash(hash); - } + const updateHash = i => i.updateHash(hash); this.dependencies.forEach(updateHash); this.blocks.forEach(updateHash); diff --git a/lib/DllPlugin.js b/lib/DllPlugin.js index 33fabb18c..97a6ad31e 100644 --- a/lib/DllPlugin.js +++ b/lib/DllPlugin.js @@ -15,12 +15,12 @@ class DllPlugin { apply(compiler) { compiler.plugin("entry-option", (context, entry) => { - function itemToPlugin(item, name) { + const itemToPlugin = (item, name) => { if(Array.isArray(item)) return new DllEntryPlugin(context, item, name); else throw new Error("DllPlugin: supply an Array as entry"); - } + }; if(typeof entry === "object" && !Array.isArray(entry)) { Object.keys(entry).forEach(name => { compiler.apply(itemToPlugin(entry[name], name)); diff --git a/lib/DllReferencePlugin.js b/lib/DllReferencePlugin.js index bc314250c..7cc065183 100644 --- a/lib/DllReferencePlugin.js +++ b/lib/DllReferencePlugin.js @@ -26,7 +26,7 @@ class DllReferencePlugin { const manifest = this.options.manifest; if(typeof manifest === "string") { params.compilationDependencies.push(manifest); - compiler.inputFileSystem.readFile(manifest, function(err, result) { + compiler.inputFileSystem.readFile(manifest, (err, result) => { if(err) return callback(err); params["dll reference " + manifest] = JSON.parse(result.toString("utf-8")); return callback(); diff --git a/lib/DynamicEntryPlugin.js b/lib/DynamicEntryPlugin.js index 655dd957f..3dde45b01 100644 --- a/lib/DynamicEntryPlugin.js +++ b/lib/DynamicEntryPlugin.js @@ -51,7 +51,7 @@ class DynamicEntryPlugin { module.exports = DynamicEntryPlugin; -DynamicEntryPlugin.createDependency = function(entry, name) { +DynamicEntryPlugin.createDependency = (entry, name) => { if(Array.isArray(entry)) return MultiEntryPlugin.createDependency(entry, name); else diff --git a/lib/EntryOptionPlugin.js b/lib/EntryOptionPlugin.js index 67e690172..af22f9a80 100644 --- a/lib/EntryOptionPlugin.js +++ b/lib/EntryOptionPlugin.js @@ -8,12 +8,12 @@ const SingleEntryPlugin = require("./SingleEntryPlugin"); const MultiEntryPlugin = require("./MultiEntryPlugin"); const DynamicEntryPlugin = require("./DynamicEntryPlugin"); -function itemToPlugin(context, item, name) { +const itemToPlugin = (context, item, name) => { if(Array.isArray(item)) { return new MultiEntryPlugin(context, item, name); } return new SingleEntryPlugin(context, item, name); -} +}; module.exports = class EntryOptionPlugin { apply(compiler) { diff --git a/lib/EnvironmentPlugin.js b/lib/EnvironmentPlugin.js index ad8d57336..86ef501c2 100644 --- a/lib/EnvironmentPlugin.js +++ b/lib/EnvironmentPlugin.js @@ -8,15 +8,15 @@ const DefinePlugin = require("./DefinePlugin"); class EnvironmentPlugin { - constructor(keys) { - if(Array.isArray(keys)) { - this.keys = keys; + constructor(...keys) { + if(keys.length === 1 && Array.isArray(keys[0])) { + this.keys = keys[0]; this.defaultValues = {}; - } else if(keys && typeof keys === "object") { - this.keys = Object.keys(keys); - this.defaultValues = keys; + } else if(keys.length === 1 && keys[0] && typeof keys[0] === "object") { + this.keys = Object.keys(keys[0]); + this.defaultValues = keys[0]; } else { - this.keys = Array.prototype.slice.call(arguments); + this.keys = keys; this.defaultValues = {}; } } diff --git a/lib/EvalSourceMapDevToolModuleTemplatePlugin.js b/lib/EvalSourceMapDevToolModuleTemplatePlugin.js index 31ecfe058..6ce4cc4f3 100644 --- a/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +++ b/lib/EvalSourceMapDevToolModuleTemplatePlugin.js @@ -18,7 +18,7 @@ class EvalSourceMapDevToolModuleTemplatePlugin { apply(moduleTemplate) { const self = this; const options = this.options; - moduleTemplate.plugin("module", function(source, module) { + moduleTemplate.plugin("module", (source, module) => { if(source.__EvalSourceMapDevToolData) return source.__EvalSourceMapDevToolData; let sourceMap; @@ -36,27 +36,27 @@ class EvalSourceMapDevToolModuleTemplatePlugin { } // Clone (flat) the sourcemap to ensure that the mutations below do not persist. - sourceMap = Object.keys(sourceMap).reduce(function(obj, key) { + sourceMap = Object.keys(sourceMap).reduce((obj, key) => { obj[key] = sourceMap[key]; return obj; }, {}); - const modules = sourceMap.sources.map(function(source) { + const modules = sourceMap.sources.map(source => { const module = self.compilation.findModule(source); return module || source; }); - let moduleFilenames = modules.map(function(module) { - return ModuleFilenameHelpers.createFilename(module, self.moduleFilenameTemplate, this.requestShortener); - }, this); - moduleFilenames = ModuleFilenameHelpers.replaceDuplicates(moduleFilenames, function(filename, i, n) { + let moduleFilenames = modules.map(module => { + return ModuleFilenameHelpers.createFilename(module, self.moduleFilenameTemplate, moduleTemplate.requestShortener); + }); + moduleFilenames = ModuleFilenameHelpers.replaceDuplicates(moduleFilenames, (filename, i, n) => { for(let j = 0; j < n; j++) filename += "*"; return filename; }); sourceMap.sources = moduleFilenames; if(sourceMap.sourcesContent) { - sourceMap.sourcesContent = sourceMap.sourcesContent.map(function(content, i) { - return `${content}\n\n\n${ModuleFilenameHelpers.createFooter(modules[i], this.requestShortener)}`; - }, this); + sourceMap.sourcesContent = sourceMap.sourcesContent.map((content, i) => { + return `${content}\n\n\n${ModuleFilenameHelpers.createFooter(modules[i], moduleTemplate.requestShortener)}`; + }); } sourceMap.sourceRoot = options.sourceRoot || ""; sourceMap.file = `${module.id}.js`; @@ -66,7 +66,7 @@ class EvalSourceMapDevToolModuleTemplatePlugin { source.__EvalSourceMapDevToolData = new RawSource(`eval(${JSON.stringify(content + footer)});`); return source.__EvalSourceMapDevToolData; }); - moduleTemplate.plugin("hash", function(hash) { + moduleTemplate.plugin("hash", hash => { hash.update("eval-source-map"); hash.update("2"); }); diff --git a/lib/ExportPropertyMainTemplatePlugin.js b/lib/ExportPropertyMainTemplatePlugin.js index bd0f43dff..c569e3a3b 100644 --- a/lib/ExportPropertyMainTemplatePlugin.js +++ b/lib/ExportPropertyMainTemplatePlugin.js @@ -6,9 +6,9 @@ const ConcatSource = require("webpack-sources").ConcatSource; -function accessorToObjectAccess(accessor) { +const accessorToObjectAccess = accessor => { return accessor.map(a => `[${JSON.stringify(a)}]`).join(""); -} +}; class ExportPropertyMainTemplatePlugin { constructor(property) { diff --git a/lib/ExtendedAPIPlugin.js b/lib/ExtendedAPIPlugin.js index dc78f95d3..b3df2ba6f 100644 --- a/lib/ExtendedAPIPlugin.js +++ b/lib/ExtendedAPIPlugin.js @@ -22,17 +22,19 @@ class ExtendedAPIPlugin { compiler.plugin("compilation", (compilation, params) => { compilation.dependencyFactories.set(ConstDependency, new NullFactory()); compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); - compilation.mainTemplate.plugin("require-extensions", function(source, chunk, hash) { + + const mainTemplate = compilation.mainTemplate; + mainTemplate.plugin("require-extensions", (source, chunk, hash) => { const buf = [source]; buf.push(""); buf.push("// __webpack_hash__"); - buf.push(`${this.requireFn}.h = ${JSON.stringify(hash)};`); + buf.push(`${mainTemplate.requireFn}.h = ${JSON.stringify(hash)};`); buf.push(""); buf.push("// __webpack_chunkname__"); - buf.push(`${this.requireFn}.cn = ${JSON.stringify(chunk.name)};`); - return this.asString(buf); + buf.push(`${mainTemplate.requireFn}.cn = ${JSON.stringify(chunk.name)};`); + return mainTemplate.asString(buf); }); - compilation.mainTemplate.plugin("global-hash", () => true); + mainTemplate.plugin("global-hash", () => true); params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { Object.keys(REPLACEMENTS).forEach(key => { diff --git a/lib/ExternalModuleFactoryPlugin.js b/lib/ExternalModuleFactoryPlugin.js index 77fbd1b49..eb5d673a8 100644 --- a/lib/ExternalModuleFactoryPlugin.js +++ b/lib/ExternalModuleFactoryPlugin.js @@ -18,7 +18,7 @@ class ExternalModuleFactoryPlugin { const context = data.context; const dependency = data.dependencies[0]; - function handleExternal(value, type, callback) { + const handleExternal = (value, type, callback) => { if(typeof type === "function") { callback = type; type = undefined; @@ -32,17 +32,18 @@ class ExternalModuleFactoryPlugin { } callback(null, new ExternalModule(value, type || globalType, dependency.request)); return true; - } - (function handleExternals(externals, callback) { + }; + + const handleExternals = (externals, callback) => { if(typeof externals === "string") { if(externals === dependency.request) { return handleExternal(dependency.request, callback); } } else if(Array.isArray(externals)) { let i = 0; - (function next() { + const next = () => { let asyncFlag; - const handleExternalsAndCallback = function handleExternalsAndCallback(err, module) { + const handleExternalsAndCallback = (err, module) => { if(err) return callback(err); if(!module) { if(asyncFlag) { @@ -60,14 +61,16 @@ class ExternalModuleFactoryPlugin { handleExternals(externals[i++], handleExternalsAndCallback); } while (!asyncFlag); // eslint-disable-line keyword-spacing asyncFlag = false; - }()); + }; + + next(); return; } else if(externals instanceof RegExp) { if(externals.test(dependency.request)) { return handleExternal(dependency.request, callback); } } else if(typeof externals === "function") { - externals.call(null, context, dependency.request, function(err, value, type) { + externals.call(null, context, dependency.request, (err, value, type) => { if(err) return callback(err); if(typeof value !== "undefined") { handleExternal(value, type, callback); @@ -80,11 +83,13 @@ class ExternalModuleFactoryPlugin { return handleExternal(externals[dependency.request], callback); } callback(); - }(this.externals, function(err, module) { + }; + + handleExternals(this.externals, (err, module) => { if(err) return callback(err); if(!module) return handleExternal(false, callback); return callback(null, module); - })); + }); }); } } diff --git a/lib/FlagDependencyExportsPlugin.js b/lib/FlagDependencyExportsPlugin.js index 2d7b71ee1..e6e8a13cb 100644 --- a/lib/FlagDependencyExportsPlugin.js +++ b/lib/FlagDependencyExportsPlugin.js @@ -4,6 +4,17 @@ */ "use strict"; +const addToSet = (a, b) => { + let changed = false; + b.forEach((item) => { + if(!a.has(item)) { + a.add(item); + changed = true; + } + }); + return changed; +}; + class FlagDependencyExportsPlugin { apply(compiler) { @@ -11,35 +22,22 @@ class FlagDependencyExportsPlugin { compilation.plugin("finish-modules", (modules) => { const dependencies = Object.create(null); + // TODO maybe replace with utils/Queue for better performance? + const queue = modules.filter((m) => !m.providedExports); + let module; let moduleWithExports; let moduleProvidedExports; - const queue = modules.filter((m) => !m.providedExports); - for(let i = 0; i < queue.length; i++) { - module = queue[i]; - if(module.providedExports !== true) { - moduleWithExports = module.meta && module.meta.harmonyModule; - moduleProvidedExports = Array.isArray(module.providedExports) ? new Set(module.providedExports) : new Set(); - processDependenciesBlock(module); - if(!moduleWithExports) { - module.providedExports = true; - notifyDependencies(); - } else if(module.providedExports !== true) { - module.providedExports = Array.from(moduleProvidedExports); - } - } - } - - function processDependenciesBlock(depBlock) { + const processDependenciesBlock = depBlock => { depBlock.dependencies.forEach((dep) => processDependency(dep)); depBlock.variables.forEach((variable) => { variable.dependencies.forEach((dep) => processDependency(dep)); }); depBlock.blocks.forEach(processDependenciesBlock); - } + }; - function processDependency(dep) { + const processDependency = dep => { const exportDesc = dep.getExports && dep.getExports(); if(!exportDesc) return; moduleWithExports = true; @@ -74,26 +72,31 @@ class FlagDependencyExportsPlugin { if(changed) { notifyDependencies(); } - } + }; - function notifyDependencies() { + const notifyDependencies = () => { const deps = dependencies[module.identifier()]; if(deps) { deps.forEach((dep) => queue.push(dep)); } + }; + + for(let i = 0; i < queue.length; i++) { + module = queue[i]; + + if(module.providedExports !== true) { + moduleWithExports = module.meta && module.meta.harmonyModule; + moduleProvidedExports = Array.isArray(module.providedExports) ? new Set(module.providedExports) : new Set(); + processDependenciesBlock(module); + if(!moduleWithExports) { + module.providedExports = true; + notifyDependencies(); + } else if(module.providedExports !== true) { + module.providedExports = Array.from(moduleProvidedExports); + } + } } }); - - function addToSet(a, b) { - let changed = false; - b.forEach((item) => { - if(!a.has(item)) { - a.add(item); - changed = true; - } - }); - return changed; - } }); } } diff --git a/lib/FlagDependencyUsagePlugin.js b/lib/FlagDependencyUsagePlugin.js index 9e1930a6d..9e8e73225 100644 --- a/lib/FlagDependencyUsagePlugin.js +++ b/lib/FlagDependencyUsagePlugin.js @@ -4,26 +4,26 @@ */ "use strict"; +const addToSet = (a, b) => { + b.forEach(item => { + if(a.indexOf(item) < 0) + a.push(item); + }); + return a; +}; + +const isSubset = (biggerSet, subset) => { + if(biggerSet === true) return true; + if(subset === true) return false; + return subset.every(item => biggerSet.indexOf(item) >= 0); +}; + class FlagDependencyUsagePlugin { apply(compiler) { compiler.plugin("compilation", compilation => { compilation.plugin("optimize-modules-advanced", modules => { - modules.forEach(module => module.used = false); - - const queue = []; - compilation.chunks.forEach(chunk => { - if(chunk.entryModule) { - processModule(chunk.entryModule, true); - } - }); - - while(queue.length) { - const queueItem = queue.pop(); - processDependenciesBlock(queueItem[0], queueItem[1]); - } - - function processModule(module, usedExports) { + const processModule = (module, usedExports) => { module.used = true; if(module.usedExports === true) return; @@ -47,15 +47,15 @@ class FlagDependencyUsagePlugin { } queue.push([module, module.usedExports]); - } + }; - function processDependenciesBlock(depBlock, usedExports) { + const processDependenciesBlock = (depBlock, usedExports) => { depBlock.dependencies.forEach(dep => processDependency(dep)); depBlock.variables.forEach(variable => variable.dependencies.forEach(dep => processDependency(dep))); depBlock.blocks.forEach(block => queue.push([block, usedExports])); - } + }; - function processDependency(dep) { + const processDependency = dep => { const reference = dep.getReference && dep.getReference(); if(!reference) return; const module = reference.module; @@ -65,23 +65,22 @@ class FlagDependencyUsagePlugin { if(!oldUsed || (importedNames && (!oldUsedExports || !isSubset(oldUsedExports, importedNames)))) { processModule(module, importedNames); } - } + }; - }); + modules.forEach(module => module.used = false); - function addToSet(a, b) { - b.forEach(item => { - if(a.indexOf(item) < 0) - a.push(item); + const queue = []; + compilation.chunks.forEach(chunk => { + if(chunk.entryModule) { + processModule(chunk.entryModule, true); + } }); - return a; - } - function isSubset(biggerSet, subset) { - if(biggerSet === true) return true; - if(subset === true) return false; - return subset.every(item => biggerSet.indexOf(item) >= 0); - } + while(queue.length) { + const queueItem = queue.pop(); + processDependenciesBlock(queueItem[0], queueItem[1]); + } + }); }); } } diff --git a/lib/FunctionModuleTemplatePlugin.js b/lib/FunctionModuleTemplatePlugin.js index 1e78961e2..b7f8949cd 100644 --- a/lib/FunctionModuleTemplatePlugin.js +++ b/lib/FunctionModuleTemplatePlugin.js @@ -9,7 +9,7 @@ const Template = require("./Template"); class FunctionModuleTemplatePlugin { apply(moduleTemplate) { - moduleTemplate.plugin("render", function(moduleSource, module) { + moduleTemplate.plugin("render", (moduleSource, module) => { const source = new ConcatSource(); const defaultArguments = [module.moduleArgument || "module", module.exportsArgument || "exports"]; if((module.arguments && module.arguments.length !== 0) || module.hasDependencies(d => d.requireWebpackRequire !== false)) { @@ -22,10 +22,10 @@ class FunctionModuleTemplatePlugin { return source; }); - moduleTemplate.plugin("package", function(moduleSource, module) { - if(this.outputOptions.pathinfo) { + moduleTemplate.plugin("package", (moduleSource, module) => { + if(moduleTemplate.outputOptions.pathinfo) { const source = new ConcatSource(); - const req = module.readableIdentifier(this.requestShortener); + const req = module.readableIdentifier(moduleTemplate.requestShortener); source.add("/*!****" + req.replace(/./g, "*") + "****!*\\\n"); source.add(" !*** " + req.replace(/\*\//g, "*_/") + " ***!\n"); source.add(" \\****" + req.replace(/./g, "*") + "****/\n"); @@ -43,7 +43,7 @@ class FunctionModuleTemplatePlugin { source.add(Template.toComment("all exports used") + "\n"); if(module.optimizationBailout) { module.optimizationBailout.forEach(text => { - if(typeof text === "function") text = text(this.requestShortener); + if(typeof text === "function") text = text(moduleTemplate.requestShortener); source.add(Template.toComment(`${text}`) + "\n"); }); } @@ -53,7 +53,7 @@ class FunctionModuleTemplatePlugin { return moduleSource; }); - moduleTemplate.plugin("hash", function(hash) { + moduleTemplate.plugin("hash", hash => { hash.update("FunctionModuleTemplatePlugin"); hash.update("2"); }); diff --git a/lib/HotModuleReplacementPlugin.js b/lib/HotModuleReplacementPlugin.js index 00be1ecf6..d6b41994a 100644 --- a/lib/HotModuleReplacementPlugin.js +++ b/lib/HotModuleReplacementPlugin.js @@ -40,29 +40,29 @@ module.exports = class HotModuleReplacementPlugin { compilation.dependencyFactories.set(ModuleHotDeclineDependency, normalModuleFactory); compilation.dependencyTemplates.set(ModuleHotDeclineDependency, new ModuleHotDeclineDependency.Template()); - compilation.plugin("record", function(compilation, records) { - if(records.hash === this.hash) return; + compilation.plugin("record", (compilation, records) => { + if(records.hash === compilation.hash) return; records.hash = compilation.hash; records.moduleHashs = {}; - this.modules.forEach(module => { + compilation.modules.forEach(module => { const identifier = module.identifier(); const hash = require("crypto").createHash("md5"); module.updateHash(hash); records.moduleHashs[identifier] = hash.digest("hex"); }); records.chunkHashs = {}; - this.chunks.forEach(chunk => { + compilation.chunks.forEach(chunk => { records.chunkHashs[chunk.id] = chunk.hash; }); records.chunkModuleIds = {}; - this.chunks.forEach(chunk => { + compilation.chunks.forEach(chunk => { records.chunkModuleIds[chunk.id] = chunk.mapModules(m => m.id); }); }); let initialPass = false; let recompilation = false; - compilation.plugin("after-hash", function() { - let records = this.records; + compilation.plugin("after-hash", () => { + let records = compilation.records; if(!records) { initialPass = true; return; @@ -71,14 +71,14 @@ module.exports = class HotModuleReplacementPlugin { initialPass = true; const preHash = records.preHash || "x"; const prepreHash = records.prepreHash || "x"; - if(preHash === this.hash) { + if(preHash === compilation.hash) { recompilation = true; - this.modifyHash(prepreHash); + compilation.modifyHash(prepreHash); return; } records.prepreHash = records.hash || "x"; - records.preHash = this.hash; - this.modifyHash(records.prepreHash); + records.preHash = compilation.hash; + compilation.modifyHash(records.prepreHash); }); compilation.plugin("should-generate-chunk-assets", () => { if(multiStep && !recompilation && !initialPass) @@ -93,11 +93,11 @@ module.exports = class HotModuleReplacementPlugin { return setTimeout(callback, fullBuildTimeout); return callback(); }); - compilation.plugin("additional-chunk-assets", function() { - const records = this.records; - if(records.hash === this.hash) return; + compilation.plugin("additional-chunk-assets", () => { + const records = compilation.records; + if(records.hash === compilation.hash) return; if(!records.moduleHashs || !records.chunkHashs || !records.chunkModuleIds) return; - this.modules.forEach(module => { + compilation.modules.forEach(module => { const identifier = module.identifier(); let hash = require("crypto").createHash("md5"); module.updateHash(hash); @@ -105,12 +105,12 @@ module.exports = class HotModuleReplacementPlugin { module.hotUpdate = records.moduleHashs[identifier] !== hash; }); const hotUpdateMainContent = { - h: this.hash, + h: compilation.hash, c: {}, }; - Object.keys(records.chunkHashs).forEach(function(chunkId) { + Object.keys(records.chunkHashs).forEach(chunkId => { chunkId = isNaN(+chunkId) ? chunkId : +chunkId; - const currentChunk = this.chunks.find(chunk => chunk.id === chunkId); + const currentChunk = compilation.chunks.find(chunk => chunk.id === chunkId); if(currentChunk) { const newModules = currentChunk.getModules().filter(module => module.hotUpdate); const allModules = {}; @@ -119,68 +119,70 @@ module.exports = class HotModuleReplacementPlugin { }); const removedModules = records.chunkModuleIds[chunkId].filter(id => !allModules[id]); if(newModules.length > 0 || removedModules.length > 0) { - const source = hotUpdateChunkTemplate.render(chunkId, newModules, removedModules, this.hash, this.moduleTemplate, this.dependencyTemplates); - const filename = this.getPath(hotUpdateChunkFilename, { + const source = hotUpdateChunkTemplate.render(chunkId, newModules, removedModules, compilation.hash, compilation.moduleTemplate, compilation.dependencyTemplates); + const filename = compilation.getPath(hotUpdateChunkFilename, { hash: records.hash, chunk: currentChunk }); - this.additionalChunkAssets.push(filename); - this.assets[filename] = source; + compilation.additionalChunkAssets.push(filename); + compilation.assets[filename] = source; hotUpdateMainContent.c[chunkId] = true; currentChunk.files.push(filename); - this.applyPlugins("chunk-asset", currentChunk, filename); + compilation.applyPlugins("chunk-asset", currentChunk, filename); } } else { hotUpdateMainContent.c[chunkId] = false; } - }, this); + }, compilation); const source = new RawSource(JSON.stringify(hotUpdateMainContent)); - const filename = this.getPath(hotUpdateMainFilename, { + const filename = compilation.getPath(hotUpdateMainFilename, { hash: records.hash }); - this.assets[filename] = source; + compilation.assets[filename] = source; }); - compilation.mainTemplate.plugin("hash", hash => { + const mainTemplate = compilation.mainTemplate; + + mainTemplate.plugin("hash", hash => { hash.update("HotMainTemplateDecorator"); }); - compilation.mainTemplate.plugin("module-require", (_, chunk, hash, varModuleId) => { + mainTemplate.plugin("module-require", (_, chunk, hash, varModuleId) => { return `hotCreateRequire(${varModuleId})`; }); - compilation.mainTemplate.plugin("require-extensions", function(source) { + mainTemplate.plugin("require-extensions", source => { const buf = [source]; buf.push(""); buf.push("// __webpack_hash__"); - buf.push(this.requireFn + ".h = function() { return hotCurrentHash; };"); - return this.asString(buf); + buf.push(mainTemplate.requireFn + ".h = function() { return hotCurrentHash; };"); + return mainTemplate.asString(buf); }); - compilation.mainTemplate.plugin("bootstrap", function(source, chunk, hash) { - source = this.applyPluginsWaterfall("hot-bootstrap", source, chunk, hash); - return this.asString([ + mainTemplate.plugin("bootstrap", (source, chunk, hash) => { + source = mainTemplate.applyPluginsWaterfall("hot-bootstrap", source, chunk, hash); + return mainTemplate.asString([ source, "", hotInitCode - .replace(/\$require\$/g, this.requireFn) + .replace(/\$require\$/g, mainTemplate.requireFn) .replace(/\$hash\$/g, JSON.stringify(hash)) .replace(/\$requestTimeout\$/g, requestTimeout) .replace(/\/\*foreachInstalledChunks\*\//g, chunk.getNumberOfChunks() > 0 ? "for(var chunkId in installedChunks)" : `var chunkId = ${JSON.stringify(chunk.id)};`) ]); }); - compilation.mainTemplate.plugin("global-hash", () => true); + mainTemplate.plugin("global-hash", () => true); - compilation.mainTemplate.plugin("current-hash", (_, length) => { + mainTemplate.plugin("current-hash", (_, length) => { if(isFinite(length)) return `hotCurrentHash.substr(0, ${length})`; else return "hotCurrentHash"; }); - compilation.mainTemplate.plugin("module-obj", function(source, chunk, hash, varModuleId) { - return this.asString([ + mainTemplate.plugin("module-obj", (source, chunk, hash, varModuleId) => { + return mainTemplate.asString([ `${source},`, `hot: hotCreateModule(${varModuleId}),`, "parents: (hotCurrentParentsTemp = hotCurrentParents, hotCurrentParents = [], hotCurrentParentsTemp),", @@ -188,16 +190,16 @@ module.exports = class HotModuleReplacementPlugin { ]); }); - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + normalModuleFactory.plugin("parser", (parser, parserOptions) => { parser.plugin("expression __webpack_hash__", ParserHelpers.toConstantDependency("__webpack_require__.h()")); parser.plugin("evaluate typeof __webpack_hash__", ParserHelpers.evaluateToString("string")); - parser.plugin("evaluate Identifier module.hot", function(expr) { - return ParserHelpers.evaluateToIdentifier("module.hot", !!this.state.compilation.hotUpdateChunkTemplate)(expr); + parser.plugin("evaluate Identifier module.hot", expr => { + return ParserHelpers.evaluateToIdentifier("module.hot", !!parser.state.compilation.hotUpdateChunkTemplate)(expr); }); - parser.plugin("call module.hot.accept", function(expr) { - if(!this.state.compilation.hotUpdateChunkTemplate) return false; + parser.plugin("call module.hot.accept", expr => { + if(!parser.state.compilation.hotUpdateChunkTemplate) return false; if(expr.arguments.length >= 1) { - const arg = this.evaluateExpression(expr.arguments[0]); + const arg = parser.evaluateExpression(expr.arguments[0]); let params = []; let requests = []; if(arg.isString()) { @@ -212,20 +214,20 @@ module.exports = class HotModuleReplacementPlugin { dep.optional = true; dep.loc = Object.create(expr.loc); dep.loc.index = idx; - this.state.module.addDependency(dep); + parser.state.module.addDependency(dep); requests.push(request); }); if(expr.arguments.length > 1) - this.applyPluginsBailResult("hot accept callback", expr.arguments[1], requests); + parser.applyPluginsBailResult("hot accept callback", expr.arguments[1], requests); else - this.applyPluginsBailResult("hot accept without callback", expr, requests); + parser.applyPluginsBailResult("hot accept without callback", expr, requests); } } }); - parser.plugin("call module.hot.decline", function(expr) { - if(!this.state.compilation.hotUpdateChunkTemplate) return false; + parser.plugin("call module.hot.decline", expr => { + if(!parser.state.compilation.hotUpdateChunkTemplate) return false; if(expr.arguments.length === 1) { - const arg = this.evaluateExpression(expr.arguments[0]); + const arg = parser.evaluateExpression(expr.arguments[0]); let params = []; if(arg.isString()) { params = [arg]; @@ -237,7 +239,7 @@ module.exports = class HotModuleReplacementPlugin { dep.optional = true; dep.loc = Object.create(expr.loc); dep.loc.index = idx; - this.state.module.addDependency(dep); + parser.state.module.addDependency(dep); }); } }); diff --git a/lib/JsonpChunkTemplatePlugin.js b/lib/JsonpChunkTemplatePlugin.js index 639003369..20e20ae7e 100644 --- a/lib/JsonpChunkTemplatePlugin.js +++ b/lib/JsonpChunkTemplatePlugin.js @@ -8,8 +8,8 @@ const ConcatSource = require("webpack-sources").ConcatSource; class JsonpChunkTemplatePlugin { apply(chunkTemplate) { - chunkTemplate.plugin("render", function(modules, chunk) { - const jsonpFunction = this.outputOptions.jsonpFunction; + chunkTemplate.plugin("render", (modules, chunk) => { + const jsonpFunction = chunkTemplate.outputOptions.jsonpFunction; const source = new ConcatSource(); source.add(`(window[${JSON.stringify(jsonpFunction)}] = window[${JSON.stringify(jsonpFunction)}] || []).push([${JSON.stringify(chunk.ids)},`); source.add(modules); @@ -22,11 +22,11 @@ class JsonpChunkTemplatePlugin { source.add("])"); return source; }); - chunkTemplate.plugin("hash", function(hash) { + chunkTemplate.plugin("hash", hash => { hash.update("JsonpChunkTemplatePlugin"); hash.update("4"); - hash.update(`${this.outputOptions.jsonpFunction}`); - hash.update(`${this.outputOptions.library}`); + hash.update(`${chunkTemplate.outputOptions.jsonpFunction}`); + hash.update(`${chunkTemplate.outputOptions.library}`); }); } } diff --git a/lib/JsonpHotUpdateChunkTemplatePlugin.js b/lib/JsonpHotUpdateChunkTemplatePlugin.js index d42d1f1f4..abef86bed 100644 --- a/lib/JsonpHotUpdateChunkTemplatePlugin.js +++ b/lib/JsonpHotUpdateChunkTemplatePlugin.js @@ -8,18 +8,18 @@ const ConcatSource = require("webpack-sources").ConcatSource; class JsonpHotUpdateChunkTemplatePlugin { apply(hotUpdateChunkTemplate) { - hotUpdateChunkTemplate.plugin("render", function(modulesSource, modules, removedModules, hash, id) { + hotUpdateChunkTemplate.plugin("render", (modulesSource, modules, removedModules, hash, id) => { const source = new ConcatSource(); - source.add(`${this.outputOptions.hotUpdateFunction}(${JSON.stringify(id)},`); + source.add(`${hotUpdateChunkTemplate.outputOptions.hotUpdateFunction}(${JSON.stringify(id)},`); source.add(modulesSource); source.add(")"); return source; }); - hotUpdateChunkTemplate.plugin("hash", function(hash) { + hotUpdateChunkTemplate.plugin("hash", hash => { hash.update("JsonpHotUpdateChunkTemplatePlugin"); hash.update("3"); - hash.update(`${this.outputOptions.hotUpdateFunction}`); - hash.update(`${this.outputOptions.library}`); + hash.update(`${hotUpdateChunkTemplate.outputOptions.hotUpdateFunction}`); + hash.update(`${hotUpdateChunkTemplate.outputOptions.library}`); }); } } diff --git a/lib/JsonpMainTemplatePlugin.js b/lib/JsonpMainTemplatePlugin.js index f08cbee0f..6b0e4c609 100644 --- a/lib/JsonpMainTemplatePlugin.js +++ b/lib/JsonpMainTemplatePlugin.js @@ -9,21 +9,19 @@ const Template = require("./Template"); class JsonpMainTemplatePlugin { apply(mainTemplate) { - function needChunkLoadingCode(chunk) { - var otherChunksInEntry = chunk.entrypoints.some(function(entrypoint) { - return entrypoint.chunks.length > 1; - }); + const needChunkLoadingCode = chunk => { + var otherChunksInEntry = chunk.entrypoints.some(entrypoint => entrypoint.chunks.length > 1); var onDemandChunks = chunk.getNumberOfChunks() > 0; return otherChunksInEntry || onDemandChunks; - } - mainTemplate.plugin("local-vars", function(source, chunk) { + }; + mainTemplate.plugin("local-vars", (source, chunk) => { if(needChunkLoadingCode(chunk)) { - return this.asString([ + return mainTemplate.asString([ source, "", "// objects to store loaded and loading chunks", "var installedChunks = {", - this.indent( + mainTemplate.indent( chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(",\n") ), "};", @@ -33,14 +31,14 @@ class JsonpMainTemplatePlugin { } return source; }); - mainTemplate.plugin("jsonp-script", function(_, chunk, hash) { - const chunkFilename = this.outputOptions.chunkFilename; + mainTemplate.plugin("jsonp-script", (_, chunk, hash) => { + const chunkFilename = mainTemplate.outputOptions.chunkFilename; const chunkMaps = chunk.getChunkMaps(); - const crossOriginLoading = this.outputOptions.crossOriginLoading; - const chunkLoadTimeout = this.outputOptions.chunkLoadTimeout; - const scriptSrcPath = this.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), { - hash: `" + ${this.renderCurrentHashCode(hash)} + "`, - hashWithLength: length => `" + ${this.renderCurrentHashCode(hash, length)} + "`, + const crossOriginLoading = mainTemplate.outputOptions.crossOriginLoading; + const chunkLoadTimeout = mainTemplate.outputOptions.chunkLoadTimeout; + const scriptSrcPath = mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`, chunk: { id: "\" + chunkId + \"", hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`, @@ -55,31 +53,31 @@ class JsonpMainTemplatePlugin { name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "` } }); - return this.asString([ + return mainTemplate.asString([ "var script = document.createElement('script');", "script.charset = 'utf-8';", `script.timeout = ${chunkLoadTimeout};`, crossOriginLoading ? `script.crossOrigin = ${JSON.stringify(crossOriginLoading)};` : "", - `if (${this.requireFn}.nc) {`, - this.indent(`script.setAttribute("nonce", ${this.requireFn}.nc);`), + `if (${mainTemplate.requireFn}.nc) {`, + mainTemplate.indent(`script.setAttribute("nonce", ${mainTemplate.requireFn}.nc);`), "}", - `script.src = ${this.requireFn}.p + ${scriptSrcPath};`, + `script.src = ${mainTemplate.requireFn}.p + ${scriptSrcPath};`, "var timeout = setTimeout(function(){", - this.indent([ + mainTemplate.indent([ "onScriptComplete({ type: 'timeout', target: script });", ]), `}, ${chunkLoadTimeout});`, "script.onerror = script.onload = onScriptComplete;", "function onScriptComplete(event) {", - this.indent([ + mainTemplate.indent([ "// avoid mem leaks in IE.", "script.onerror = script.onload = null;", "clearTimeout(timeout);", "var chunk = installedChunks[chunkId];", "if(chunk !== 0) {", - this.indent([ + mainTemplate.indent([ "if(chunk) {", - this.indent([ + mainTemplate.indent([ "var errorType = event && (event.type === 'load' ? 'missing' : event.type);", "var realSrc = event && event.target && event.target.src;", "var error = new Error('Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')');", @@ -95,25 +93,25 @@ class JsonpMainTemplatePlugin { "};", ]); }); - mainTemplate.plugin("require-ensure", function(_, chunk, hash) { - return this.asString([ + mainTemplate.plugin("require-ensure", (_, chunk, hash) => { + return mainTemplate.asString([ "var installedChunkData = installedChunks[chunkId];", "if(installedChunkData === 0) {", - this.indent([ + mainTemplate.indent([ "return new Promise(function(resolve) { resolve(); });" ]), "}", "", "// a Promise means \"currently loading\".", "if(installedChunkData) {", - this.indent([ + mainTemplate.indent([ "return installedChunkData[2];" ]), "}", "", "// setup Promise in chunk cache", "var promise = new Promise(function(resolve, reject) {", - this.indent([ + mainTemplate.indent([ "installedChunkData = installedChunks[chunkId] = [resolve, reject];" ]), "});", @@ -121,71 +119,71 @@ class JsonpMainTemplatePlugin { "", "// start chunk loading", "var head = document.getElementsByTagName('head')[0];", - this.applyPluginsWaterfall("jsonp-script", "", chunk, hash), + mainTemplate.applyPluginsWaterfall("jsonp-script", "", chunk, hash), "head.appendChild(script);", "", "return promise;" ]); }); - mainTemplate.plugin("require-extensions", function(source, chunk) { + mainTemplate.plugin("require-extensions", (source, chunk) => { if(chunk.getNumberOfChunks() === 0) return source; - return this.asString([ + return mainTemplate.asString([ source, "", "// on error function for async loading", - `${this.requireFn}.oe = function(err) { console.error(err); throw err; };` + `${mainTemplate.requireFn}.oe = function(err) { console.error(err); throw err; };` ]); }); - mainTemplate.plugin("bootstrap", function(source, chunk, hash) { + mainTemplate.plugin("bootstrap", (source, chunk, hash) => { if(needChunkLoadingCode(chunk)) { - return this.asString([ + return mainTemplate.asString([ source, "", "// install a JSONP callback for chunk loading", "function webpackJsonpCallback(data) {", - this.indent([ + mainTemplate.indent([ "var chunkIds = data[0], moreModules = data[1], executeModules = data[2];", "// add \"moreModules\" to the modules object,", "// then flag all \"chunkIds\" as loaded and fire callback", "var moduleId, chunkId, i = 0, resolves = [], result;", "for(;i < chunkIds.length; i++) {", - this.indent([ + mainTemplate.indent([ "chunkId = chunkIds[i];", "if(installedChunks[chunkId]) {", - this.indent("resolves.push(installedChunks[chunkId][0]);"), + mainTemplate.indent("resolves.push(installedChunks[chunkId][0]);"), "}", "installedChunks[chunkId] = 0;" ]), "}", "for(moduleId in moreModules) {", - this.indent([ + mainTemplate.indent([ "if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {", - this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")), + mainTemplate.indent(mainTemplate.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")), "}" ]), "}", "if(parentJsonpFunction) parentJsonpFunction(data);", "while(resolves.length) {", - this.indent("resolves.shift()();"), + mainTemplate.indent("resolves.shift()();"), "}", - this.entryPointInChildren(chunk) ? [ + mainTemplate.entryPointInChildren(chunk) ? [ "scheduledModules.push.apply(scheduledModules, executeModules || []);", "", "for(i = 0; i < scheduledModules.length; i++) {", - this.indent([ + mainTemplate.indent([ "var scheduledModule = scheduledModules[i];", "var fullfilled = true;", "for(var j = 1; j < scheduledModule.length; j++) {", - this.indent([ + mainTemplate.indent([ "var depId = scheduledModule[j];", "if(installedChunks[depId] !== 0) fullfilled = false;" ]), "}", "if(fullfilled) {", - this.indent([ + mainTemplate.indent([ "scheduledModules.splice(i--, 1);", - "result = " + this.requireFn + "(" + this.requireFn + ".s = scheduledModule[0]);", + "result = " + mainTemplate.requireFn + "(" + mainTemplate.requireFn + ".s = scheduledModule[0]);", ]), "}" ]), @@ -198,10 +196,10 @@ class JsonpMainTemplatePlugin { } return source; }); - mainTemplate.plugin("startup", function(source, chunk, hash) { + mainTemplate.plugin("startup", (source, chunk, hash) => { if(needChunkLoadingCode(chunk)) { - var jsonpFunction = this.outputOptions.jsonpFunction; - return this.asString([ + var jsonpFunction = mainTemplate.outputOptions.jsonpFunction; + return mainTemplate.asString([ `var jsonpArray = window[${JSON.stringify(jsonpFunction)}] = window[${JSON.stringify(jsonpFunction)}] || [];`, "var parentJsonpFunction = jsonpArray.push.bind(jsonpArray);", "jsonpArray.push = webpackJsonpCallback;", @@ -213,25 +211,25 @@ class JsonpMainTemplatePlugin { } return source; }); - mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) { - const hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename; - const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename; - const crossOriginLoading = this.outputOptions.crossOriginLoading; - const hotUpdateFunction = this.outputOptions.hotUpdateFunction; - const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), { - hash: `" + ${this.renderCurrentHashCode(hash)} + "`, - hashWithLength: length => `" + ${this.renderCurrentHashCode(hash, length)} + "`, + mainTemplate.plugin("hot-bootstrap", (source, chunk, hash) => { + const hotUpdateChunkFilename = mainTemplate.outputOptions.hotUpdateChunkFilename; + const hotUpdateMainFilename = mainTemplate.outputOptions.hotUpdateMainFilename; + const crossOriginLoading = mainTemplate.outputOptions.crossOriginLoading; + const hotUpdateFunction = mainTemplate.outputOptions.hotUpdateFunction; + const currentHotUpdateChunkFilename = mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`, chunk: { id: "\" + chunkId + \"" } }); - const currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), { - hash: `" + ${this.renderCurrentHashCode(hash)} + "`, - hashWithLength: length => `" + ${this.renderCurrentHashCode(hash, length)} + "` + const currentHotUpdateMainFilename = mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "` }); const runtimeSource = Template.getFunctionContent(require("./JsonpMainTemplate.runtime.js")) .replace(/\/\/\$semicolon/g, ";") - .replace(/\$require\$/g, this.requireFn) + .replace(/\$require\$/g, mainTemplate.requireFn) .replace(/\$crossOriginLoading\$/g, crossOriginLoading ? `script.crossOrigin = ${JSON.stringify(crossOriginLoading)}` : "") .replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename) .replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename) @@ -243,13 +241,13 @@ function hotDisposeChunk(chunkId) { var parentHotUpdateCallback = this[${JSON.stringify(hotUpdateFunction)}]; this[${JSON.stringify(hotUpdateFunction)}] = ${runtimeSource}`; }); - mainTemplate.plugin("hash", function(hash) { + mainTemplate.plugin("hash", hash => { hash.update("jsonp"); hash.update("5"); - hash.update(`${this.outputOptions.filename}`); - hash.update(`${this.outputOptions.chunkFilename}`); - hash.update(`${this.outputOptions.jsonpFunction}`); - hash.update(`${this.outputOptions.hotUpdateFunction}`); + hash.update(`${mainTemplate.outputOptions.filename}`); + hash.update(`${mainTemplate.outputOptions.chunkFilename}`); + hash.update(`${mainTemplate.outputOptions.jsonpFunction}`); + hash.update(`${mainTemplate.outputOptions.hotUpdateFunction}`); }); } } diff --git a/lib/LibraryTemplatePlugin.js b/lib/LibraryTemplatePlugin.js index 78f62d8ab..93cb6b07b 100644 --- a/lib/LibraryTemplatePlugin.js +++ b/lib/LibraryTemplatePlugin.js @@ -6,13 +6,13 @@ const SetVarMainTemplatePlugin = require("./SetVarMainTemplatePlugin"); -function accessorToObjectAccess(accessor) { +const accessorToObjectAccess = (accessor) => { return accessor.map((a) => { return `[${JSON.stringify(a)}]`; }).join(""); -} +}; -function accessorAccess(base, accessor, joinWith) { +const accessorAccess = (base, accessor, joinWith) => { accessor = [].concat(accessor); return accessor.map((a, idx) => { a = base ? @@ -22,7 +22,7 @@ function accessorAccess(base, accessor, joinWith) { if(idx === 0 && typeof base === "undefined") return `${a} = typeof ${a} === "object" ? ${a} : {}`; return `${a} = ${a} || {}`; }).join(joinWith || "; "); -} +}; class LibraryTemplatePlugin { diff --git a/lib/ModuleFilenameHelpers.js b/lib/ModuleFilenameHelpers.js index 59010dee5..f04bee0b3 100644 --- a/lib/ModuleFilenameHelpers.js +++ b/lib/ModuleFilenameHelpers.js @@ -27,28 +27,28 @@ ModuleFilenameHelpers.REGEXP_ID = /\[id\]/gi; ModuleFilenameHelpers.HASH = "[hash]"; ModuleFilenameHelpers.REGEXP_HASH = /\[hash\]/gi; -function getAfter(str, token) { +const getAfter = (str, token) => { const idx = str.indexOf(token); return idx < 0 ? "" : str.substr(idx); -} +}; -function getBefore(str, token) { +const getBefore = (str, token) => { const idx = str.lastIndexOf(token); return idx < 0 ? "" : str.substr(0, idx); -} +}; -function getHash(str) { +const getHash = str => { const hash = require("crypto").createHash("md5"); hash.update(str); return hash.digest("hex").substr(0, 4); -} +}; -function asRegExp(test) { +const asRegExp = test => { if(typeof test === "string") test = new RegExp("^" + test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")); return test; -} +}; -ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFilenameTemplate, requestShortener) { +ModuleFilenameHelpers.createFilename = (module, moduleFilenameTemplate, requestShortener) => { let absoluteResourcePath; let hash; let identifier; @@ -99,7 +99,7 @@ ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFil .replace(ModuleFilenameHelpers.REGEXP_HASH, hash); }; -ModuleFilenameHelpers.createFooter = function createFooter(module, requestShortener) { +ModuleFilenameHelpers.createFooter = (module, requestShortener) => { if(!module) module = ""; if(typeof module === "string") { return [ @@ -117,7 +117,7 @@ ModuleFilenameHelpers.createFooter = function createFooter(module, requestShorte } }; -ModuleFilenameHelpers.replaceDuplicates = function replaceDuplicates(array, fn, comparator) { +ModuleFilenameHelpers.replaceDuplicates = (array, fn, comparator) => { const countMap = Object.create(null); const posMap = Object.create(null); array.forEach((item, idx) => { @@ -139,19 +139,17 @@ ModuleFilenameHelpers.replaceDuplicates = function replaceDuplicates(array, fn, }); }; -ModuleFilenameHelpers.matchPart = function matchPart(str, test) { +ModuleFilenameHelpers.matchPart = (str, test) => { if(!test) return true; test = asRegExp(test); if(Array.isArray(test)) { - return test.map(asRegExp).filter(function(regExp) { - return regExp.test(str); - }).length > 0; + return test.map(asRegExp).some(regExp => regExp.test(str)); } else { return test.test(str); } }; -ModuleFilenameHelpers.matchObject = function matchObject(obj, str) { +ModuleFilenameHelpers.matchObject = (obj, str) => { if(obj.test) if(!ModuleFilenameHelpers.matchPart(str, obj.test)) return false; if(obj.include) diff --git a/lib/MultiModule.js b/lib/MultiModule.js index 80f4c91b0..dde3477e9 100644 --- a/lib/MultiModule.js +++ b/lib/MultiModule.js @@ -48,7 +48,7 @@ class MultiModule extends Module { source(dependencyTemplates, outputOptions) { const str = []; - this.dependencies.forEach(function(dep, idx) { + this.dependencies.forEach((dep, idx) => { if(dep.module) { if(idx === this.dependencies.length - 1) str.push("module.exports = "); @@ -58,6 +58,7 @@ class MultiModule extends Module { str.push(`${JSON.stringify(dep.module.id)}`); str.push(")"); } else { + // TODO replace with WebpackMissingModule module str.push("(function webpackMissingModule() { throw new Error("); str.push(JSON.stringify(`Cannot find module "${dep.request}"`)); str.push("); }())"); diff --git a/lib/NewWatchingPlugin.js b/lib/NewWatchingPlugin.js index 45b9c5bc5..330f2fbbd 100644 --- a/lib/NewWatchingPlugin.js +++ b/lib/NewWatchingPlugin.js @@ -6,7 +6,7 @@ class NewWatchingPlugin { apply(compiler) { - compiler.plugin("compilation", function(compilation) { + compiler.plugin("compilation", compilation => { compilation.warnings.push(new Error("The 'NewWatchingPlugin' is no longer necessary (now default)")); }); } diff --git a/lib/NodeStuffPlugin.js b/lib/NodeStuffPlugin.js index 6111f7266..1f45c397e 100644 --- a/lib/NodeStuffPlugin.js +++ b/lib/NodeStuffPlugin.js @@ -30,28 +30,28 @@ class NodeStuffPlugin { if(parserOptions.node) localOptions = Object.assign({}, localOptions, parserOptions.node); - function setConstant(expressionName, value) { - parser.plugin(`expression ${expressionName}`, function() { - this.state.current.addVariable(expressionName, JSON.stringify(value)); + const setConstant = (expressionName, value) => { + parser.plugin(`expression ${expressionName}`, () => { + parser.state.current.addVariable(expressionName, JSON.stringify(value)); return true; }); - } + }; - function setModuleConstant(expressionName, fn) { - parser.plugin(`expression ${expressionName}`, function() { - this.state.current.addVariable(expressionName, JSON.stringify(fn(this.state.module))); + const setModuleConstant = (expressionName, fn) => { + parser.plugin(`expression ${expressionName}`, () => { + parser.state.current.addVariable(expressionName, JSON.stringify(fn(parser.state.module))); return true; }); - } + }; const context = compiler.context; if(localOptions.__filename === "mock") { setConstant("__filename", "/index.js"); } else if(localOptions.__filename) { setModuleConstant("__filename", module => path.relative(context, module.resource)); } - parser.plugin("evaluate Identifier __filename", function(expr) { - if(!this.state.module) return; - const resource = this.state.module.resource; + parser.plugin("evaluate Identifier __filename", expr => { + if(!parser.state.module) return; + const resource = parser.state.module.resource; const i = resource.indexOf("?"); return ParserHelpers.evaluateToString(i < 0 ? resource : resource.substr(0, i))(expr); }); @@ -60,9 +60,9 @@ class NodeStuffPlugin { } else if(localOptions.__dirname) { setModuleConstant("__dirname", module => path.relative(context, module.context)); } - parser.plugin("evaluate Identifier __dirname", function(expr) { - if(!this.state.module) return; - return ParserHelpers.evaluateToString(this.state.module.context)(expr); + parser.plugin("evaluate Identifier __dirname", expr => { + if(!parser.state.module) return; + return ParserHelpers.evaluateToString(parser.state.module.context)(expr); }); parser.plugin("expression require.main", ParserHelpers.toConstantDependency("__webpack_require__.c[__webpack_require__.s]")); parser.plugin( @@ -71,24 +71,24 @@ class NodeStuffPlugin { ); parser.plugin("expression module.loaded", ParserHelpers.toConstantDependency("module.l")); parser.plugin("expression module.id", ParserHelpers.toConstantDependency("module.i")); - parser.plugin("expression module.exports", function() { - const module = this.state.module; + parser.plugin("expression module.exports", () => { + const module = parser.state.module; const isHarmony = module.meta && module.meta.harmonyModule; if(!isHarmony) return true; }); parser.plugin("evaluate Identifier module.hot", ParserHelpers.evaluateToIdentifier("module.hot", false)); - parser.plugin("expression module", function() { - const module = this.state.module; + parser.plugin("expression module", () => { + const module = parser.state.module; const isHarmony = module.meta && module.meta.harmonyModule; let moduleJsPath = path.join(__dirname, "..", "buildin", isHarmony ? "harmony-module.js" : "module.js"); if(module.context) { - moduleJsPath = path.relative(this.state.module.context, moduleJsPath); + moduleJsPath = path.relative(parser.state.module.context, moduleJsPath); if(!/^[A-Z]:/i.test(moduleJsPath)) { moduleJsPath = `./${moduleJsPath.replace(/\\/g, "/")}`; } } - return ParserHelpers.addParsedVariableToModule(this, "module", `require(${JSON.stringify(moduleJsPath)})(module)`); + return ParserHelpers.addParsedVariableToModule(parser, "module", `require(${JSON.stringify(moduleJsPath)})(module)`); }); }); }); diff --git a/lib/NormalModule.js b/lib/NormalModule.js index 253bb07e0..4f4ffa3c3 100644 --- a/lib/NormalModule.js +++ b/lib/NormalModule.js @@ -25,15 +25,15 @@ const ModuleWarning = require("./ModuleWarning"); const runLoaders = require("loader-runner").runLoaders; const getContext = require("loader-runner").getContext; -function asString(buf) { +const asString = (buf) => { if(Buffer.isBuffer(buf)) { return buf.toString("utf-8"); } return buf; -} +}; -function contextify(context, request) { - return request.split("!").map(function(r) { +const contextify = (context, request) => { + return request.split("!").map(r => { const splitPath = r.split("?"); splitPath[0] = path.relative(context, splitPath[0]); if(path.sep === "\\") @@ -42,7 +42,7 @@ function contextify(context, request) { splitPath[0] = "./" + splitPath[0]; return splitPath.join("?"); }).join("!"); -} +}; class NonErrorEmittedError extends WebpackError { constructor(error) { diff --git a/lib/NormalModuleFactory.js b/lib/NormalModuleFactory.js index 250b21008..dab9c8b01 100644 --- a/lib/NormalModuleFactory.js +++ b/lib/NormalModuleFactory.js @@ -11,7 +11,7 @@ const RawModule = require("./RawModule"); const Parser = require("./Parser"); const RuleSet = require("./RuleSet"); -function loaderToIdent(data) { +const loaderToIdent = data => { if(!data.options) return data.loader; if(typeof data.options === "string") @@ -21,9 +21,9 @@ function loaderToIdent(data) { if(data.ident) return data.loader + "??" + data.ident; return data.loader + "?" + JSON.stringify(data.options); -} +}; -function identToLoaderRequest(resultString) { +const identToLoaderRequest = resultString => { const idx = resultString.indexOf("?"); let options; @@ -40,7 +40,7 @@ function identToLoaderRequest(resultString) { loader: resultString }; } -} +}; class NormalModuleFactory extends Tapable { constructor(context, resolvers, options) { diff --git a/lib/OptionsDefaulter.js b/lib/OptionsDefaulter.js index 83ccd8f4f..06b740197 100644 --- a/lib/OptionsDefaulter.js +++ b/lib/OptionsDefaulter.js @@ -4,16 +4,16 @@ */ "use strict"; -function getProperty(obj, name) { +const getProperty = (obj, name) => { name = name.split("."); for(var i = 0; i < name.length - 1; i++) { obj = obj[name[i]]; if(typeof obj !== "object" || !obj) return; } return obj[name.pop()]; -} +}; -function setProperty(obj, name, value) { +const setProperty = (obj, name, value) => { name = name.split("."); for(var i = 0; i < name.length - 1; i++) { if(typeof obj[name[i]] !== "object" && typeof obj[name[i]] !== "undefined") return; @@ -21,7 +21,7 @@ function setProperty(obj, name, value) { obj = obj[name[i]]; } obj[name.pop()] = value; -} +}; class OptionsDefaulter { constructor() { @@ -48,7 +48,7 @@ class OptionsDefaulter { { let oldValue = getProperty(options, name); if(!Array.isArray(oldValue)) oldValue = []; - oldValue.push.apply(oldValue, this.defaults[name]); + oldValue.push(...this.defaults[name]); setProperty(options, name, oldValue); break; } @@ -60,7 +60,7 @@ class OptionsDefaulter { } set(name, config, def) { - if(arguments.length === 3) { + if(def !== undefined) { this.defaults[name] = def; this.config[name] = config; } else { diff --git a/lib/Parser.js b/lib/Parser.js index 35fcb8343..f4196d729 100644 --- a/lib/Parser.js +++ b/lib/Parser.js @@ -12,11 +12,11 @@ const vm = require("vm"); const BasicEvaluatedExpression = require("./BasicEvaluatedExpression"); const StackedSetMap = require("./util/StackedSetMap"); -function joinRanges(startRange, endRange) { +const joinRanges = (startRange, endRange) => { if(!endRange) return startRange; if(!startRange) return endRange; return [startRange[0], endRange[1]]; -} +}; const ECMA_VERSION = 2017; @@ -93,7 +93,7 @@ class Parser extends Tapable { if(expr.value instanceof RegExp) return new BasicEvaluatedExpression().setRegExp(expr.value).setRange(expr.range); }); - this.plugin("evaluate LogicalExpression", function(expr) { + this.plugin("evaluate LogicalExpression", expr => { let left; let leftAsBool; let right; @@ -113,7 +113,7 @@ class Parser extends Tapable { return right.setRange(expr.range); } }); - this.plugin("evaluate BinaryExpression", function(expr) { + this.plugin("evaluate BinaryExpression", expr => { let left; let right; let res; @@ -233,7 +233,7 @@ class Parser extends Tapable { } } }); - this.plugin("evaluate UnaryExpression", function(expr) { + this.plugin("evaluate UnaryExpression", expr => { if(expr.operator === "typeof") { let res; let name; @@ -275,10 +275,10 @@ class Parser extends Tapable { } } }); - this.plugin("evaluate typeof undefined", function(expr) { + this.plugin("evaluate typeof undefined", expr => { return new BasicEvaluatedExpression().setString("undefined").setRange(expr.range); }); - this.plugin("evaluate Identifier", function(expr) { + this.plugin("evaluate Identifier", expr => { const name = this.scope.renames.get(expr.name) || expr.name; if(!this.scope.definitions.has(expr.name)) { const result = this.applyPluginsBailResult1("evaluate Identifier " + name, expr); @@ -288,7 +288,7 @@ class Parser extends Tapable { return this.applyPluginsBailResult1("evaluate defined Identifier " + name, expr); } }); - this.plugin("evaluate ThisExpression", function(expr) { + this.plugin("evaluate ThisExpression", expr => { const name = this.scope.renames.get("this"); if(name) { const result = this.applyPluginsBailResult1("evaluate Identifier " + name, expr); @@ -296,7 +296,7 @@ class Parser extends Tapable { return new BasicEvaluatedExpression().setIdentifier(name).setRange(expr.range); } }); - this.plugin("evaluate MemberExpression", function(expression) { + this.plugin("evaluate MemberExpression", expression => { let exprName = this.getNameForExpression(expression); if(exprName) { if(exprName.free) { @@ -308,7 +308,7 @@ class Parser extends Tapable { } } }); - this.plugin("evaluate CallExpression", function(expr) { + this.plugin("evaluate CallExpression", expr => { if(expr.callee.type !== "MemberExpression") return; if(expr.callee.property.type !== (expr.callee.computed ? "Literal" : "Identifier")) return; const param = this.evaluateExpression(expr.callee.object); @@ -316,7 +316,7 @@ class Parser extends Tapable { const property = expr.callee.property.name || expr.callee.property.value; return this.applyPluginsBailResult2("evaluate CallExpression ." + property, expr, param); }); - this.plugin("evaluate CallExpression .replace", function(expr, param) { + this.plugin("evaluate CallExpression .replace", (expr, param) => { if(!param.isString()) return; if(expr.arguments.length !== 2) return; let arg1 = this.evaluateExpression(expr.arguments[0]); @@ -328,7 +328,7 @@ class Parser extends Tapable { return new BasicEvaluatedExpression().setString(param.string.replace(arg1, arg2)).setRange(expr.range); }); ["substr", "substring"].forEach(fn => { - this.plugin("evaluate CallExpression ." + fn, function(expr, param) { + this.plugin("evaluate CallExpression ." + fn, (expr, param) => { if(!param.isString()) return; let arg1; let result, str = param.string; @@ -360,7 +360,7 @@ class Parser extends Tapable { * @param {any[]} expressions expressions * @return {BasicEvaluatedExpression[]} Simplified template */ - function getSimplifiedTemplateResult(kind, quasis, expressions) { + const getSimplifiedTemplateResult = (kind, quasis, expressions) => { const parts = []; for(let i = 0; i < quasis.length; i++) { @@ -378,22 +378,22 @@ class Parser extends Tapable { } } return parts; - } + }; - this.plugin("evaluate TemplateLiteral", function(node) { + this.plugin("evaluate TemplateLiteral", node => { const parts = getSimplifiedTemplateResult.call(this, "cooked", node.quasis, node.expressions); if(parts.length === 1) { return parts[0].setRange(node.range); } return new BasicEvaluatedExpression().setTemplateString(parts).setRange(node.range); }); - this.plugin("evaluate TaggedTemplateExpression", function(node) { + this.plugin("evaluate TaggedTemplateExpression", node => { if(this.evaluateExpression(node.tag).identifier !== "String.raw") return; const parts = getSimplifiedTemplateResult.call(this, "raw", node.quasi.quasis, node.quasi.expressions); return new BasicEvaluatedExpression().setTemplateString(parts).setRange(node.range); }); - this.plugin("evaluate CallExpression .concat", function(expr, param) { + this.plugin("evaluate CallExpression .concat", (expr, param) => { if(!param.isString() && !param.isWrapped()) return; let stringSuffix = null; @@ -423,7 +423,7 @@ class Parser extends Tapable { return new BasicEvaluatedExpression().setString(newString).setRange(expr.range); } }); - this.plugin("evaluate CallExpression .split", function(expr, param) { + this.plugin("evaluate CallExpression .split", (expr, param) => { if(!param.isString()) return; if(expr.arguments.length !== 1) return; let result; @@ -435,7 +435,7 @@ class Parser extends Tapable { } else return; return new BasicEvaluatedExpression().setArray(result).setRange(expr.range); }); - this.plugin("evaluate ConditionalExpression", function(expr) { + this.plugin("evaluate ConditionalExpression", expr => { const condition = this.evaluateExpression(expr.test); const conditionValue = condition.asBool(); let res; @@ -458,9 +458,9 @@ class Parser extends Tapable { res.setRange(expr.range); return res; }); - this.plugin("evaluate ArrayExpression", function(expr) { - const items = expr.elements.map(function(element) { - return element !== null && this.evaluateExpression(element); + this.plugin("evaluate ArrayExpression", expr => { + const items = expr.elements.map(element => { + return element !== null && this.evaluateExpression(element); }, this); if(!items.every(Boolean)) return; return new BasicEvaluatedExpression().setItems(items).setRange(expr.range); @@ -709,7 +709,7 @@ class Parser extends Tapable { prewalkImportDeclaration(statement) { const source = statement.source.value; this.applyPluginsBailResult2("import", statement, source); - statement.specifiers.forEach(function(specifier) { + statement.specifiers.forEach(specifier => { const name = specifier.local.name; this.scope.renames.set(name, null); this.scope.definitions.add(name); @@ -1110,21 +1110,19 @@ class Parser extends Tapable { walkCallExpression(expression) { let result; - function walkIIFE(functionExpression, options, currentThis) { - function renameArgOrThis(argOrThis) { + const walkIIFE = (functionExpression, options, currentThis) => { + const renameArgOrThis = argOrThis => { const renameIdentifier = this.getRenameIdentifier(argOrThis); if(renameIdentifier && this.applyPluginsBailResult1("can-rename " + renameIdentifier, argOrThis)) { if(!this.applyPluginsBailResult1("rename " + renameIdentifier, argOrThis)) return renameIdentifier; } this.walkExpression(argOrThis); - } + }; const params = functionExpression.params; const renameThis = currentThis ? renameArgOrThis.call(this, currentThis) : null; const args = options.map(renameArgOrThis, this); - this.inScope(params.filter(function(identifier, idx) { - return !args[idx]; - }), () => { + this.inScope(params.filter((identifier, idx) => !args[idx]), () => { if(renameThis) { this.scope.renames.set("this", renameThis); } @@ -1140,7 +1138,7 @@ class Parser extends Tapable { } else this.walkExpression(functionExpression.body); }); - } + }; if(expression.callee.type === "MemberExpression" && expression.callee.object.type === "FunctionExpression" && !expression.callee.computed && @@ -1321,12 +1319,12 @@ class Parser extends Tapable { const alternate = this.parseCalculatedString(expression.alternate); const items = []; if(consequent.conditional) - Array.prototype.push.apply(items, consequent.conditional); + items.push(...consequent.conditional); else if(!consequent.code) items.push(consequent); else break; if(alternate.conditional) - Array.prototype.push.apply(items, alternate.conditional); + items.push(...alternate.conditional); else if(!alternate.code) items.push(alternate); else break; @@ -1355,7 +1353,7 @@ class Parser extends Tapable { const arr = []; if(expression.elements) - expression.elements.forEach(function(expr) { + expression.elements.forEach(expr => { arr.push(this.parseString(expr)); }, this); return arr; @@ -1368,7 +1366,7 @@ class Parser extends Tapable { const arr = []; if(expression.elements) - expression.elements.forEach(function(expr) { + expression.elements.forEach(expr => { arr.push(this.parseCalculatedString(expr)); }, this); return arr; diff --git a/lib/ParserHelpers.js b/lib/ParserHelpers.js index 180c5b4b8..d6ae65612 100644 --- a/lib/ParserHelpers.js +++ b/lib/ParserHelpers.js @@ -11,12 +11,12 @@ const UnsupportedFeatureWarning = require("./UnsupportedFeatureWarning"); const ParserHelpers = exports; -ParserHelpers.addParsedVariableToModule = function(parser, name, expression) { +ParserHelpers.addParsedVariableToModule = (parser, name, expression) => { if(!parser.state.current.addVariable) return false; var deps = []; parser.parse(expression, { current: { - addDependency: function(dep) { + addDependency: dep => { dep.userRequest = name; deps.push(dep); } @@ -27,7 +27,7 @@ ParserHelpers.addParsedVariableToModule = function(parser, name, expression) { return true; }; -ParserHelpers.requireFileAsExpression = function(context, pathToModule) { +ParserHelpers.requireFileAsExpression = (context, pathToModule) => { var moduleJsPath = path.relative(context, pathToModule); if(!/^[A-Z]:/i.test(moduleJsPath)) { moduleJsPath = "./" + moduleJsPath.replace(/\\/g, "/"); @@ -35,7 +35,7 @@ ParserHelpers.requireFileAsExpression = function(context, pathToModule) { return "require(" + JSON.stringify(moduleJsPath) + ")"; }; -ParserHelpers.toConstantDependency = function(value) { +ParserHelpers.toConstantDependency = value => { return function constDependency(expr) { var dep = new ConstDependency(value, expr.range); dep.loc = expr.loc; @@ -44,19 +44,19 @@ ParserHelpers.toConstantDependency = function(value) { }; }; -ParserHelpers.evaluateToString = function(value) { +ParserHelpers.evaluateToString = value => { return function stringExpression(expr) { return new BasicEvaluatedExpression().setString(value).setRange(expr.range); }; }; -ParserHelpers.evaluateToBoolean = function(value) { +ParserHelpers.evaluateToBoolean = value => { return function booleanExpression(expr) { return new BasicEvaluatedExpression().setBoolean(value).setRange(expr.range); }; }; -ParserHelpers.evaluateToIdentifier = function(identifier, truthy) { +ParserHelpers.evaluateToIdentifier = (identifier, truthy) => { return function identifierExpression(expr) { let evex = new BasicEvaluatedExpression().setIdentifier(identifier).setRange(expr.range); if(truthy === true) evex = evex.setTruthy(); @@ -65,7 +65,7 @@ ParserHelpers.evaluateToIdentifier = function(identifier, truthy) { }; }; -ParserHelpers.expressionIsUnsupported = function(message) { +ParserHelpers.expressionIsUnsupported = (message) => { return function unsupportedExpression(expr) { var dep = new ConstDependency("(void 0)", expr.range); dep.loc = expr.loc; diff --git a/lib/ProgressPlugin.js b/lib/ProgressPlugin.js index f0bad2fad..2a6bff265 100644 --- a/lib/ProgressPlugin.js +++ b/lib/ProgressPlugin.js @@ -4,6 +4,70 @@ */ "use strict"; +const createDefaultHandler = profile => { + + let lineCaretPosition = 0; + let lastState; + let lastStateTime; + + const defaultHandler = (percentage, msg, ...args) => { + let state = msg; + const details = args; + if(percentage < 1) { + percentage = Math.floor(percentage * 100); + msg = `${percentage}% ${msg}`; + if(percentage < 100) { + msg = ` ${msg}`; + } + if(percentage < 10) { + msg = ` ${msg}`; + } + details.forEach(detail => { + if(!detail) return; + if(detail.length > 40) { + detail = `...${detail.substr(detail.length - 37)}`; + } + msg += ` ${detail}`; + }); + } + if(profile) { + state = state.replace(/^\d+\/\d+\s+/, ""); + if(percentage === 0) { + lastState = null; + lastStateTime = Date.now(); + } else if(state !== lastState || percentage === 1) { + const now = Date.now(); + if(lastState) { + const stateMsg = `${now - lastStateTime}ms ${lastState}`; + goToLineStart(stateMsg); + process.stderr.write(stateMsg + "\n"); + lineCaretPosition = 0; + } + lastState = state; + lastStateTime = now; + } + } + goToLineStart(msg); + process.stderr.write(msg); + }; + + const goToLineStart = nextMessage => { + let str = ""; + for(; lineCaretPosition > nextMessage.length; lineCaretPosition--) { + str += "\b \b"; + } + for(var i = 0; i < lineCaretPosition; i++) { + str += "\b"; + } + lineCaretPosition = nextMessage.length; + if(str) process.stderr.write(str); + }; + + return defaultHandler; + +}; + + class ProgressPlugin { constructor(options) { @@ -18,17 +82,17 @@ class ProgressPlugin { } apply(compiler) { - const handler = this.handler || defaultHandler; - const profile = this.profile; + const handler = this.handler || createDefaultHandler(this.profile); if(compiler.compilers) { const states = new Array(compiler.compilers.length); - compiler.compilers.forEach(function(compiler, idx) { - compiler.apply(new ProgressPlugin(function(p, msg) { - states[idx] = Array.prototype.slice.apply(arguments); - handler.apply(null, [ + compiler.compilers.forEach((compiler, idx) => { + compiler.apply(new ProgressPlugin((p, msg, ...args) => { + states[idx] = args; + handler( states.map(state => state && state[0] || 0).reduce((a, b) => a + b) / states.length, - `[${idx}] ${msg}` - ].concat(Array.prototype.slice.call(arguments, 2))); + `[${idx}] ${msg}`, + ...args + ); })); }); } else { @@ -37,7 +101,7 @@ class ProgressPlugin { let doneModules = 0; const activeModules = []; - const update = function update(module) { + const update = module => { handler( 0.1 + (doneModules / Math.max(lastModulesCount, moduleCount)) * 0.6, "building modules", @@ -47,7 +111,7 @@ class ProgressPlugin { ); }; - const moduleDone = function moduleDone(module) { + const moduleDone = module => { doneModules++; const ident = module.identifier(); if(ident) { @@ -56,13 +120,13 @@ class ProgressPlugin { } update(); }; - compiler.plugin("compilation", function(compilation) { + compiler.plugin("compilation", compilation => { if(compilation.compiler.isChild()) return; lastModulesCount = moduleCount; moduleCount = 0; doneModules = 0; handler(0, "compiling"); - compilation.plugin("build-module", function(module) { + compilation.plugin("build-module", module => { moduleCount++; const ident = module.identifier(); if(ident) { @@ -131,62 +195,6 @@ class ProgressPlugin { handler(1, ""); }); } - - let lineCaretPosition = 0, - lastState, lastStateTime; - - function defaultHandler(percentage, msg) { - let state = msg; - const details = Array.prototype.slice.call(arguments, 2); - if(percentage < 1) { - percentage = Math.floor(percentage * 100); - msg = `${percentage}% ${msg}`; - if(percentage < 100) { - msg = ` ${msg}`; - } - if(percentage < 10) { - msg = ` ${msg}`; - } - details.forEach(detail => { - if(!detail) return; - if(detail.length > 40) { - detail = `...${detail.substr(detail.length - 37)}`; - } - msg += ` ${detail}`; - }); - } - if(profile) { - state = state.replace(/^\d+\/\d+\s+/, ""); - if(percentage === 0) { - lastState = null; - lastStateTime = Date.now(); - } else if(state !== lastState || percentage === 1) { - const now = Date.now(); - if(lastState) { - const stateMsg = `${now - lastStateTime}ms ${lastState}`; - goToLineStart(stateMsg); - process.stderr.write(stateMsg + "\n"); - lineCaretPosition = 0; - } - lastState = state; - lastStateTime = now; - } - } - goToLineStart(msg); - process.stderr.write(msg); - } - - function goToLineStart(nextMessage) { - let str = ""; - for(; lineCaretPosition > nextMessage.length; lineCaretPosition--) { - str += "\b \b"; - } - for(var i = 0; i < lineCaretPosition; i++) { - str += "\b"; - } - lineCaretPosition = nextMessage.length; - if(str) process.stderr.write(str); - } } } module.exports = ProgressPlugin; diff --git a/lib/ProvidePlugin.js b/lib/ProvidePlugin.js index fdcfaf48a..a23402797 100644 --- a/lib/ProvidePlugin.js +++ b/lib/ProvidePlugin.js @@ -29,7 +29,7 @@ class ProvidePlugin { parser.plugin(`can-rename ${name}`, ParserHelpers.approve); }); } - parser.plugin(`expression ${name}`, function(expr) { + parser.plugin(`expression ${name}`, expr => { let nameIdentifier = name; const scopedName = name.indexOf(".") >= 0; let expression = `require(${JSON.stringify(request[0])})`; @@ -39,11 +39,11 @@ class ProvidePlugin { if(request.length > 1) { expression += request.slice(1).map(r => `[${JSON.stringify(r)}]`).join(""); } - if(!ParserHelpers.addParsedVariableToModule(this, nameIdentifier, expression)) { + if(!ParserHelpers.addParsedVariableToModule(parser, nameIdentifier, expression)) { return false; } if(scopedName) { - ParserHelpers.toConstantDependency(nameIdentifier).bind(this)(expr); + ParserHelpers.toConstantDependency(nameIdentifier).call(parser, expr); } return true; }); diff --git a/lib/RecordIdsPlugin.js b/lib/RecordIdsPlugin.js index 492526e99..99b569905 100644 --- a/lib/RecordIdsPlugin.js +++ b/lib/RecordIdsPlugin.js @@ -16,7 +16,7 @@ class RecordIdsPlugin { if(!records.modules) records.modules = {}; if(!records.modules.byIdentifier) records.modules.byIdentifier = {}; if(!records.modules.usedIds) records.modules.usedIds = {}; - modules.forEach(function(module) { + modules.forEach(module => { let identifier = portableIdCache.get(module); if(!identifier) portableIdCache.set(module, identifier = identifierUtils.makePathsRelative(compiler.context, module.identifier())); records.modules.byIdentifier[identifier] = module.id; @@ -27,7 +27,7 @@ class RecordIdsPlugin { if(!records.modules) return; if(records.modules.byIdentifier) { const usedIds = {}; - modules.forEach(function(module) { + modules.forEach(module => { if(module.id !== null) return; let identifier = portableIdCache.get(module); if(!identifier) portableIdCache.set(module, identifier = identifierUtils.makePathsRelative(compiler.context, module.identifier())); @@ -41,7 +41,7 @@ class RecordIdsPlugin { compilation.usedModuleIds = records.modules.usedIds; }); - function getDepBlockIdent(chunk, block) { + const getDepBlockIdent = (chunk, block) => { const ident = []; if(block.chunks.length > 1) ident.push(block.chunks.indexOf(chunk)); @@ -55,7 +55,8 @@ class RecordIdsPlugin { if(!block.identifier) return null; ident.push(identifierUtils.makePathsRelative(compiler.context, block.identifier())); return ident.reverse().join(":"); - } + }; + compilation.plugin("record-chunks", (chunks, records) => { records.nextFreeChunkId = compilation.nextFreeChunkId; if(!records.chunks) records.chunks = {}; @@ -76,7 +77,7 @@ class RecordIdsPlugin { if(!records.chunks) return; const usedIds = {}; if(records.chunks.byName) { - chunks.forEach(function(chunk) { + chunks.forEach(chunk => { if(chunk.id !== null) return; if(!chunk.name) return; const id = records.chunks.byName[chunk.name]; @@ -101,7 +102,7 @@ class RecordIdsPlugin { }); }); blockIdentsCount = Object.keys(blockIdentsCount).map(accessor => [blockIdentsCount[accessor]].concat(accessor.split(":").map(Number))).sort((a, b) => b[0] - a[0]); - blockIdentsCount.forEach(function(arg) { + blockIdentsCount.forEach(arg => { const id = arg[1]; if(usedIds[id]) return; const idx = arg[2]; diff --git a/lib/RequireJsStuffPlugin.js b/lib/RequireJsStuffPlugin.js index 42a39d536..c2f8f200e 100644 --- a/lib/RequireJsStuffPlugin.js +++ b/lib/RequireJsStuffPlugin.js @@ -11,10 +11,10 @@ const NullFactory = require("./NullFactory"); module.exports = class RequireJsStuffPlugin { apply(compiler) { - compiler.plugin("compilation", function(compilation, params) { + compiler.plugin("compilation", (compilation, params) => { compilation.dependencyFactories.set(ConstDependency, new NullFactory()); compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); - params.normalModuleFactory.plugin("parser", function(parser, parserOptions) { + params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { if(typeof parserOptions.requireJs !== "undefined" && !parserOptions.requireJs) return; diff --git a/lib/RuleSet.js b/lib/RuleSet.js index 3c4a37451..20f60310c 100644 --- a/lib/RuleSet.js +++ b/lib/RuleSet.js @@ -74,6 +74,32 @@ normalized: "use strict"; +const notMatcher = matcher => { + return function(str) { + return !matcher(str); + }; +}; + +const orMatcher = items => { + return function(str) { + for(let i = 0; i < items.length; i++) { + if(items[i](str)) + return true; + } + return false; + }; +}; + +const andMatcher = items => { + return function(str) { + for(let i = 0; i < items.length; i++) { + if(!items[i](str)) + return false; + } + return true; + }; +}; + module.exports = class RuleSet { constructor(rules) { this.references = Object.create(null); @@ -109,6 +135,19 @@ module.exports = class RuleSet { let resourceSource; let condition; + const checkUseSource = newSource => { + if(useSource && useSource !== newSource) + throw new Error(RuleSet.buildErrorMessage(rule, new Error("Rule can only have one result source (provided " + newSource + " and " + useSource + ")"))); + useSource = newSource; + }; + + const checkResourceSource = newSource => { + if(resourceSource && resourceSource !== newSource) + throw new Error(RuleSet.buildErrorMessage(rule, new Error("Rule can only have one resource source (provided " + newSource + " and " + resourceSource + ")"))); + resourceSource = newSource; + }; + + if(rule.test || rule.include || rule.exclude) { checkResourceSource("test + include + exclude"); condition = { @@ -197,18 +236,6 @@ module.exports = class RuleSet { newRule[key] = rule[key]; }); - function checkUseSource(newSource) { - if(useSource && useSource !== newSource) - throw new Error(RuleSet.buildErrorMessage(rule, new Error("Rule can only have one result source (provided " + newSource + " and " + useSource + ")"))); - useSource = newSource; - } - - function checkResourceSource(newSource) { - if(resourceSource && resourceSource !== newSource) - throw new Error(RuleSet.buildErrorMessage(rule, new Error("Rule can only have one resource source (provided " + newSource + " and " + resourceSource + ")"))); - resourceSource = newSource; - } - if(Array.isArray(newRule.use)) { newRule.use.forEach((item) => { if(item.ident) { @@ -416,29 +443,3 @@ module.exports = class RuleSet { return options; } }; - -function notMatcher(matcher) { - return function(str) { - return !matcher(str); - }; -} - -function orMatcher(items) { - return function(str) { - for(let i = 0; i < items.length; i++) { - if(items[i](str)) - return true; - } - return false; - }; -} - -function andMatcher(items) { - return function(str) { - for(let i = 0; i < items.length; i++) { - if(!items[i](str)) - return false; - } - return true; - }; -} diff --git a/lib/SourceMapDevToolPlugin.js b/lib/SourceMapDevToolPlugin.js index 031574612..8416d5739 100644 --- a/lib/SourceMapDevToolPlugin.js +++ b/lib/SourceMapDevToolPlugin.js @@ -17,7 +17,7 @@ const basename = (name) => { return name.substr(name.lastIndexOf("/") + 1); }; -function getTaskForFile(file, chunk, options, compilation) { +const getTaskForFile = (file, chunk, options, compilation) => { const asset = compilation.assets[file]; if(asset.__SourceMapDevToolFile === file && asset.__SourceMapDevToolData) { const data = asset.__SourceMapDevToolData; @@ -47,7 +47,7 @@ function getTaskForFile(file, chunk, options, compilation) { modules: undefined }; } -} +}; class SourceMapDevToolPlugin { constructor(options) { @@ -77,11 +77,11 @@ class SourceMapDevToolPlugin { compiler.plugin("compilation", compilation => { new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation); - compilation.plugin("after-optimize-chunk-assets", function(chunks) { + compilation.plugin("after-optimize-chunk-assets", chunks => { const moduleToSourceNameMapping = new Map(); const tasks = []; - chunks.forEach(function(chunk) { + chunks.forEach(chunk => { chunk.files.forEach(file => { if(matchObject(file)) { const task = getTaskForFile(file, chunk, options, compilation); @@ -144,7 +144,7 @@ class SourceMapDevToolPlugin { moduleToSourceNameMapping.set(module, sourceName); usedNamesSet.add(sourceName); } - tasks.forEach(function(task) { + tasks.forEach(task => { const chunk = task.chunk; const file = task.file; const asset = task.asset; diff --git a/lib/Stats.js b/lib/Stats.js index a0a94c8f5..836460dcf 100644 --- a/lib/Stats.js +++ b/lib/Stats.js @@ -9,9 +9,9 @@ const SizeFormatHelpers = require("./SizeFormatHelpers"); const formatLocation = require("./formatLocation"); const identifierUtils = require("./util/identifier"); -const optionsOrFallback = function() { +const optionsOrFallback = (...args) => { let optionValues = []; - optionValues.push.apply(optionValues, arguments); + optionValues.push(...args); return optionValues.find(optionValue => typeof optionValue !== "undefined"); }; @@ -316,7 +316,7 @@ class Stats { }); } - function fnModule(module) { + const fnModule = module => { const path = []; let current = module; while(current.issuer) { @@ -386,7 +386,7 @@ class Stats { obj.source = module._source.source(); } return obj; - } + }; if(showChunks) { obj.chunks = compilation.chunks.map(chunk => { const obj = { diff --git a/lib/Template.js b/lib/Template.js index 94788becc..78a85543f 100644 --- a/lib/Template.js +++ b/lib/Template.js @@ -19,6 +19,18 @@ const COMMENT_END_REGEX = /\*\//g; const PATH_NAME_NORMALIZE_REPLACE_REGEX = /[^a-zA-Z0-9_!§$()=\-^°]+/g; const MATCH_PADDED_HYPHENS_REPLACE_REGEX = /^-|-$/g; +const stringifyIdSortPredicate = (a, b) => { + var aId = a.id + ""; + var bId = b.id + ""; + if(aId < bId) return -1; + if(aId > bId) return 1; + return 0; +}; + +const moduleIdIsNumber = module => { + return typeof module.id === "number"; +}; + module.exports = class Template extends Tapable { constructor(outputOptions) { super(); @@ -96,7 +108,7 @@ module.exports = class Template extends Tapable { return false; var maxId = -Infinity; var minId = Infinity; - modules.forEach(function(module) { + modules.forEach(module => { if(maxId < module.id) maxId = module.id; if(minId > module.id) minId = module.id; }); @@ -104,10 +116,10 @@ module.exports = class Template extends Tapable { // add minId x ',' instead of 'Array(minId).concat(...)' minId = 0; } - var objectOverhead = modules.map(function(module) { + var objectOverhead = modules.map(module => { var idLength = (module.id + "").length; return idLength + 2; - }).reduce(function(a, b) { + }).reduce((a, b) => { return a + b; }, -1); var arrayOverhead = minId === 0 ? maxId : 16 + ("" + minId).length + maxId; @@ -122,14 +134,14 @@ module.exports = class Template extends Tapable { return source; } var removedModules = chunk.removedModules; - var allModules = chunk.mapModules(function(module) { + var allModules = chunk.mapModules(module => { return { id: module.id, source: moduleTemplate.render(module, dependencyTemplates, chunk) }; }); if(removedModules && removedModules.length > 0) { - removedModules.forEach(function(id) { + removedModules.forEach(id => { allModules.push({ id: id, source: "false" @@ -145,7 +157,7 @@ module.exports = class Template extends Tapable { if(minId !== 0) source.add("Array(" + minId + ").concat("); source.add("[\n"); var modules = {}; - allModules.forEach(function(module) { + allModules.forEach(module => { modules[module.id] = module; }); for(var idx = minId; idx <= maxId; idx++) { @@ -164,7 +176,7 @@ module.exports = class Template extends Tapable { source.add("{\n"); allModules .sort(stringifyIdSortPredicate) - .forEach(function(module, idx) { + .forEach((module, idx) => { if(idx !== 0) source.add(",\n"); source.add(`\n/***/ ${JSON.stringify(module.id)}:\n`); source.add(module.source); @@ -174,15 +186,3 @@ module.exports = class Template extends Tapable { return source; } }; - -function stringifyIdSortPredicate(a, b) { - var aId = a.id + ""; - var bId = b.id + ""; - if(aId < bId) return -1; - if(aId > bId) return 1; - return 0; -} - -function moduleIdIsNumber(module) { - return typeof module.id === "number"; -} diff --git a/lib/TemplatedPathPlugin.js b/lib/TemplatedPathPlugin.js index ffe548498..918563619 100644 --- a/lib/TemplatedPathPlugin.js +++ b/lib/TemplatedPathPlugin.js @@ -19,20 +19,20 @@ const REGEXP_HASH_FOR_TEST = new RegExp(REGEXP_HASH.source, "i"), REGEXP_NAME_FOR_TEST = new RegExp(REGEXP_NAME.source, "i"); const withHashLength = (replacer, handlerFn) => { - return function(_, hashLength) { + return (match, hashLength, ...args) => { const length = hashLength && parseInt(hashLength, 10); if(length && handlerFn) { return handlerFn(length); } - const hash = replacer.apply(this, arguments); + const hash = replacer(match, hashLength, ...args); return length ? hash.slice(0, length) : hash; }; }; const getReplacer = (value, allowEmpty) => { - return function(match) { + return (match, ...args) => { // last argument in replacer is the entire input string - const input = arguments[arguments.length - 1]; + const input = args[args.length - 1]; if(value === null || value === undefined) { if(!allowEmpty) throw new Error(`Path variable ${match} not implemented in this context: ${input}`); return ""; @@ -71,8 +71,8 @@ class TemplatedPathPlugin { mainTemplate.plugin("asset-path", replacePathVariables); - mainTemplate.plugin("global-hash", function(chunk, paths) { - const outputOptions = this.outputOptions; + mainTemplate.plugin("global-hash", (chunk, paths) => { + const outputOptions = mainTemplate.outputOptions; const publicPath = outputOptions.publicPath || ""; const filename = outputOptions.filename || ""; const chunkFilename = outputOptions.chunkFilename || outputOptions.filename; @@ -86,8 +86,8 @@ class TemplatedPathPlugin { return true; }); - mainTemplate.plugin("hash-for-chunk", function(hash, chunk) { - const outputOptions = this.outputOptions; + mainTemplate.plugin("hash-for-chunk", (hash, chunk) => { + const outputOptions = mainTemplate.outputOptions; const chunkFilename = outputOptions.chunkFilename || outputOptions.filename; if(REGEXP_CHUNKHASH_FOR_TEST.test(chunkFilename)) hash.update(JSON.stringify(chunk.getChunkMaps(true, true).hash)); diff --git a/lib/compareLocations.js b/lib/compareLocations.js index 8f4ae0d3a..f4ccb1aef 100644 --- a/lib/compareLocations.js +++ b/lib/compareLocations.js @@ -3,7 +3,7 @@ Author Tobias Koppers @sokra */ "use strict"; -module.exports = function compareLocations(a, b) { +module.exports = (a, b) => { if(typeof a === "string") { if(typeof b === "string") { if(a < b) return -1; diff --git a/lib/dependencies/AMDDefineDependencyParserPlugin.js b/lib/dependencies/AMDDefineDependencyParserPlugin.js index 390c47823..31f55284a 100644 --- a/lib/dependencies/AMDDefineDependencyParserPlugin.js +++ b/lib/dependencies/AMDDefineDependencyParserPlugin.js @@ -13,7 +13,7 @@ const LocalModuleDependency = require("./LocalModuleDependency"); const ContextDependencyHelpers = require("./ContextDependencyHelpers"); const LocalModulesHelpers = require("./LocalModulesHelpers"); -function isBoundFunctionExpression(expr) { +const isBoundFunctionExpression = expr => { if(expr.type !== "CallExpression") return false; if(expr.callee.type !== "MemberExpression") return false; if(expr.callee.computed) return false; @@ -21,7 +21,7 @@ function isBoundFunctionExpression(expr) { if(expr.callee.property.type !== "Identifier") return false; if(expr.callee.property.name !== "bind") return false; return true; -} +}; class AMDDefineDependencyParserPlugin { constructor(options) { diff --git a/lib/dependencies/AMDPlugin.js b/lib/dependencies/AMDPlugin.js index 59e149f05..fd3c605cd 100644 --- a/lib/dependencies/AMDPlugin.js +++ b/lib/dependencies/AMDPlugin.js @@ -61,7 +61,7 @@ class AMDPlugin { if(typeof parserOptions.amd !== "undefined" && !parserOptions.amd) return; - function setExpressionToModule(outerExpr, module) { + const setExpressionToModule = (outerExpr, module) => { parser.plugin("expression " + outerExpr, (expr) => { const dep = new AMDRequireItemDependency(module, expr.range); dep.userRequest = outerExpr; @@ -69,7 +69,7 @@ class AMDPlugin { parser.state.current.addDependency(dep); return true; }); - } + }; parser.apply( new AMDRequireDependenciesBlockParserPlugin(options), diff --git a/lib/dependencies/CommonJsRequireDependencyParserPlugin.js b/lib/dependencies/CommonJsRequireDependencyParserPlugin.js index 4756f71f0..1a3d9f494 100644 --- a/lib/dependencies/CommonJsRequireDependencyParserPlugin.js +++ b/lib/dependencies/CommonJsRequireDependencyParserPlugin.js @@ -43,7 +43,7 @@ class CommonJsRequireDependencyParserPlugin { const dep = new RequireHeaderDependency(expr.callee.range); dep.loc = expr.loc; parser.state.current.addDependency(dep); - param.options.forEach(function(param) { + param.options.forEach(param => { const result = parser.applyPluginsBailResult("call require:commonjs:item", expr, param); if(result === undefined) { isExpression = true; diff --git a/lib/dependencies/ContextDependency.js b/lib/dependencies/ContextDependency.js index 732343c4d..6d5131624 100644 --- a/lib/dependencies/ContextDependency.js +++ b/lib/dependencies/ContextDependency.js @@ -6,11 +6,11 @@ const Dependency = require("../Dependency"); const CriticalDependencyWarning = require("./CriticalDependencyWarning"); -function equalRegExp(a, b) { +const equalRegExp = (a, b) => { if(a === b) return true; if(typeof a !== "object" || typeof b !== "object") return false; return a + "" === b + ""; -} +}; class ContextDependency extends Dependency { // options: { request, recursive, regExp, include, exclude, mode, chunkName } diff --git a/lib/dependencies/ContextDependencyHelpers.js b/lib/dependencies/ContextDependencyHelpers.js index b5cafcece..059f68e16 100644 --- a/lib/dependencies/ContextDependencyHelpers.js +++ b/lib/dependencies/ContextDependencyHelpers.js @@ -11,11 +11,11 @@ const ContextDependencyHelpers = exports; * @param {string} str String to quote * @return {string} Escaped string */ -function quotemeta(str) { +const quotemeta = str => { return str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&"); -} +}; -ContextDependencyHelpers.create = function(Dep, range, param, expr, options, contextOptions) { +ContextDependencyHelpers.create = (Dep, range, param, expr, options, contextOptions) => { let dep; let prefix; let postfix; diff --git a/lib/dependencies/DepBlockHelpers.js b/lib/dependencies/DepBlockHelpers.js index b9702fd18..011220d53 100644 --- a/lib/dependencies/DepBlockHelpers.js +++ b/lib/dependencies/DepBlockHelpers.js @@ -22,9 +22,9 @@ DepBlockHelpers.getDepBlockPromise = (depBlock, outputOptions, requestShortener, 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 chunkReason = Template.toNormalComment(depBlock.chunkReason); const requireChunkId = chunk => "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")"; - name = asComment(name); + name = Template.toNormalComment(name); if(chunks.length === 1) { const chunkId = JSON.stringify(chunks[0].id); return `__webpack_require__.e${name}(${chunkId}${pathChunkCheck ? Template.toComment(shortChunkName) : ""}${chunkReason})`; @@ -34,8 +34,3 @@ DepBlockHelpers.getDepBlockPromise = (depBlock, outputOptions, requestShortener, } return "new Promise(function(resolve) { resolve(); })"; }; - -function asComment(str) { - if(!str) return ""; - return `/* ${str} */`; -} diff --git a/lib/dependencies/HarmonyDetectionParserPlugin.js b/lib/dependencies/HarmonyDetectionParserPlugin.js index fe892cf53..224286a1b 100644 --- a/lib/dependencies/HarmonyDetectionParserPlugin.js +++ b/lib/dependencies/HarmonyDetectionParserPlugin.js @@ -47,6 +47,19 @@ module.exports = class HarmonyDetectionParserPlugin { module.exportsArgument = "__webpack_exports__"; } }); + + const skipInHarmony = () => { + const module = parser.state.module; + if(module && module.meta && module.meta.harmonyModule) + return true; + }; + + const nullInHarmony = () => { + const module = parser.state.module; + if(module && module.meta && module.meta.harmonyModule) + return null; + }; + var nonHarmonyIdentifiers = ["define", "exports"]; nonHarmonyIdentifiers.forEach(identifer => { parser.plugin(`evaluate typeof ${identifer}`, nullInHarmony); @@ -55,17 +68,5 @@ module.exports = class HarmonyDetectionParserPlugin { parser.plugin(`expression ${identifer}`, skipInHarmony); parser.plugin(`call ${identifer}`, skipInHarmony); }); - - function skipInHarmony() { - const module = this.state.module; - if(module && module.meta && module.meta.harmonyModule) - return true; - } - - function nullInHarmony() { - const module = this.state.module; - if(module && module.meta && module.meta.harmonyModule) - return null; - } } }; diff --git a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js index c5a641688..925659c20 100644 --- a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +++ b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js @@ -277,7 +277,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS if(Array.isArray(dep.originModule.usedExports)) { // we know which exports are used - const unused = dep.originModule.usedExports.every(function(id) { + const unused = dep.originModule.usedExports.every(id => { if(id === "default") return true; if(dep.activeExports.has(id)) return true; if(importedModule.isProvided(id) === false) return true; @@ -289,7 +289,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS } else if(dep.originModule.usedExports && importedModule && Array.isArray(importedModule.providedExports)) { // not sure which exports are used, but we know which are provided - const unused = importedModule.providedExports.every(function(id) { + const unused = importedModule.providedExports.every(id => { if(id === "default") return true; if(dep.activeExports.has(id)) return true; if(activeFromOtherStarExports.has(id)) return true; diff --git a/lib/dependencies/LoaderPlugin.js b/lib/dependencies/LoaderPlugin.js index 456d104aa..a14af8c66 100644 --- a/lib/dependencies/LoaderPlugin.js +++ b/lib/dependencies/LoaderPlugin.js @@ -16,12 +16,12 @@ class LoaderPlugin { }); compiler.plugin("compilation", (compilation) => { compilation.plugin("normal-module-loader", (loaderContext, module) => { - loaderContext.loadModule = function loadModule(request, callback) { + loaderContext.loadModule = (request, callback) => { const dep = new LoaderDependency(request); dep.loc = request; compilation.addModuleDependencies(module, [ [dep] - ], true, "lm", false, (err) => { + ], true, "lm", false, err => { if(err) return callback(err); if(!dep.module) return callback(new Error("Cannot load the module")); @@ -39,10 +39,10 @@ class LoaderPlugin { source = moduleSource.source(); } if(dep.module.fileDependencies) { - dep.module.fileDependencies.forEach((dep) => loaderContext.addDependency(dep)); + dep.module.fileDependencies.forEach(dep => loaderContext.addDependency(dep)); } if(dep.module.contextDependencies) { - dep.module.contextDependencies.forEach((dep) => loaderContext.addContextDependency(dep)); + dep.module.contextDependencies.forEach(dep => loaderContext.addContextDependency(dep)); } return callback(null, source, map, dep.module); }); diff --git a/lib/dependencies/SystemPlugin.js b/lib/dependencies/SystemPlugin.js index 08e5fb4c1..895302a73 100644 --- a/lib/dependencies/SystemPlugin.js +++ b/lib/dependencies/SystemPlugin.js @@ -17,12 +17,12 @@ class SystemPlugin { if(typeof parserOptions.system !== "undefined" && !parserOptions.system) return; - function setNotSupported(name) { + const setNotSupported = name => { parser.plugin("evaluate typeof " + name, ParserHelpers.evaluateToString("undefined")); parser.plugin("expression " + name, ParserHelpers.expressionIsUnsupported(name + " is not supported by webpack.") ); - } + }; parser.plugin("typeof System.import", ParserHelpers.toConstantDependency(JSON.stringify("function"))); parser.plugin("evaluate typeof System.import", ParserHelpers.evaluateToString("function")); @@ -32,10 +32,10 @@ class SystemPlugin { setNotSupported("System.set"); setNotSupported("System.get"); setNotSupported("System.register"); - parser.plugin("expression System", function() { + parser.plugin("expression System", () => { const systemPolyfillRequire = ParserHelpers.requireFileAsExpression( - this.state.module.context, require.resolve("../../buildin/system.js")); - return ParserHelpers.addParsedVariableToModule(this, "System", systemPolyfillRequire); + parser.state.module.context, require.resolve("../../buildin/system.js")); + return ParserHelpers.addParsedVariableToModule(parser, "System", systemPolyfillRequire); }); }); }); diff --git a/lib/dependencies/getFunctionExpression.js b/lib/dependencies/getFunctionExpression.js index d7f80fa94..abef04030 100644 --- a/lib/dependencies/getFunctionExpression.js +++ b/lib/dependencies/getFunctionExpression.js @@ -2,7 +2,7 @@ MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ -module.exports = function(expr) { +module.exports = expr => { // if(expr.type === "FunctionExpression" || expr.type === "ArrowFunctionExpression") { return { diff --git a/lib/node/NodeChunkTemplatePlugin.js b/lib/node/NodeChunkTemplatePlugin.js index aacafbbf9..99925fe62 100644 --- a/lib/node/NodeChunkTemplatePlugin.js +++ b/lib/node/NodeChunkTemplatePlugin.js @@ -10,14 +10,14 @@ const ConcatSource = require("webpack-sources").ConcatSource; class NodeChunkTemplatePlugin { apply(chunkTemplate) { - chunkTemplate.plugin("render", function(modules, chunk) { + chunkTemplate.plugin("render", (modules, chunk) => { const source = new ConcatSource(); source.add(`exports.ids = ${JSON.stringify(chunk.ids)};\nexports.modules = `); source.add(modules); source.add(";"); return source; }); - chunkTemplate.plugin("hash", function(hash) { + chunkTemplate.plugin("hash", hash => { hash.update("node"); hash.update("3"); }); diff --git a/lib/node/NodeHotUpdateChunkTemplatePlugin.js b/lib/node/NodeHotUpdateChunkTemplatePlugin.js index aad593d38..d17668841 100644 --- a/lib/node/NodeHotUpdateChunkTemplatePlugin.js +++ b/lib/node/NodeHotUpdateChunkTemplatePlugin.js @@ -16,11 +16,11 @@ class NodeHotUpdateChunkTemplatePlugin { source.add(";"); return source; }); - hotUpdateChunkTemplate.plugin("hash", function(hash) { + hotUpdateChunkTemplate.plugin("hash", hash => { hash.update("NodeHotUpdateChunkTemplatePlugin"); hash.update("3"); - hash.update(this.outputOptions.hotUpdateFunction + ""); - hash.update(this.outputOptions.library + ""); + hash.update(hotUpdateChunkTemplate.outputOptions.hotUpdateFunction + ""); + hash.update(hotUpdateChunkTemplate.outputOptions.library + ""); }); } } diff --git a/lib/node/NodeMainTemplatePlugin.js b/lib/node/NodeMainTemplatePlugin.js index 05b03ce7c..b4e299832 100644 --- a/lib/node/NodeMainTemplatePlugin.js +++ b/lib/node/NodeMainTemplatePlugin.js @@ -13,30 +13,30 @@ module.exports = class NodeMainTemplatePlugin { apply(mainTemplate) { const asyncChunkLoading = this.asyncChunkLoading; - mainTemplate.plugin("local-vars", function(source, chunk) { + mainTemplate.plugin("local-vars", (source, chunk) => { if(chunk.getNumberOfChunks() > 0) { - return this.asString([ + return mainTemplate.asString([ source, "", "// object to store loaded chunks", "// \"0\" means \"already loaded\"", "var installedChunks = {", - this.indent(chunk.ids.map((id) => `${id}: 0`).join(",\n")), + mainTemplate.indent(chunk.ids.map((id) => `${id}: 0`).join(",\n")), "};" ]); } return source; }); - mainTemplate.plugin("require-extensions", function(source, chunk) { + mainTemplate.plugin("require-extensions", (source, chunk) => { if(chunk.getNumberOfChunks() > 0) { - return this.asString([ + return mainTemplate.asString([ source, "", "// uncatched error handler for webpack runtime", - `${this.requireFn}.oe = function(err) {`, - this.indent([ + `${mainTemplate.requireFn}.oe = function(err) {`, + mainTemplate.indent([ "process.nextTick(function() {", - this.indent("throw err; // catch this error by using System.import().catch()"), + mainTemplate.indent("throw err; // catch this error by using System.import().catch()"), "});" ]), "};" @@ -44,34 +44,34 @@ module.exports = class NodeMainTemplatePlugin { } return source; }); - mainTemplate.plugin("require-ensure", function(_, chunk, hash) { - const chunkFilename = this.outputOptions.chunkFilename; + mainTemplate.plugin("require-ensure", (_, chunk, hash) => { + const chunkFilename = mainTemplate.outputOptions.chunkFilename; const chunkMaps = chunk.getChunkMaps(); const insertMoreModules = [ "var moreModules = chunk.modules, chunkIds = chunk.ids;", "for(var moduleId in moreModules) {", - this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")), + mainTemplate.indent(mainTemplate.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")), "}" ]; if(asyncChunkLoading) { - return this.asString([ + return mainTemplate.asString([ "// \"0\" is the signal for \"already loaded\"", "if(installedChunks[chunkId] === 0)", - this.indent([ + mainTemplate.indent([ "return Promise.resolve();" ]), "// array of [resolve, reject, promise] means \"currently loading\"", "if(installedChunks[chunkId])", - this.indent([ + mainTemplate.indent([ "return installedChunks[chunkId][2];" ]), "// load the chunk and return promise to it", "var promise = new Promise(function(resolve, reject) {", - this.indent([ + mainTemplate.indent([ "installedChunks[chunkId] = [resolve, reject];", - "var filename = __dirname + " + this.applyPluginsWaterfall("asset-path", JSON.stringify(`/${chunkFilename}`), { - hash: `" + ${this.renderCurrentHashCode(hash)} + "`, - hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`, + "var filename = __dirname + " + mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(`/${chunkFilename}`), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: (length) => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`, chunk: { id: "\" + chunkId + \"", hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`, @@ -87,7 +87,7 @@ module.exports = class NodeMainTemplatePlugin { } }) + ";", "require('fs').readFile(filename, 'utf-8', function(err, content) {", - this.indent([ + mainTemplate.indent([ "if(err) return reject(err);", "var chunk = {};", "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" + @@ -95,16 +95,16 @@ module.exports = class NodeMainTemplatePlugin { ].concat(insertMoreModules).concat([ "var callbacks = [];", "for(var i = 0; i < chunkIds.length; i++) {", - this.indent([ + mainTemplate.indent([ "if(installedChunks[chunkIds[i]])", - this.indent([ + mainTemplate.indent([ "callbacks = callbacks.concat(installedChunks[chunkIds[i]][0]);" ]), "installedChunks[chunkIds[i]] = 0;" ]), "}", "for(i = 0; i < callbacks.length; i++)", - this.indent("callbacks[i]();") + mainTemplate.indent("callbacks[i]();") ])), "});" ]), @@ -112,9 +112,9 @@ module.exports = class NodeMainTemplatePlugin { "return installedChunks[chunkId][2] = promise;" ]); } else { - const request = this.applyPluginsWaterfall("asset-path", JSON.stringify(`./${chunkFilename}`), { - hash: `" + ${this.renderCurrentHashCode(hash)} + "`, - hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`, + const request = mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(`./${chunkFilename}`), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: (length) => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`, chunk: { id: "\" + chunkId + \"", hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`, @@ -129,27 +129,27 @@ module.exports = class NodeMainTemplatePlugin { name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "` } }); - return this.asString([ + return mainTemplate.asString([ "// \"0\" is the signal for \"already loaded\"", "if(installedChunks[chunkId] !== 0) {", - this.indent([ + mainTemplate.indent([ `var chunk = require(${request});` ].concat(insertMoreModules).concat([ "for(var i = 0; i < chunkIds.length; i++)", - this.indent("installedChunks[chunkIds[i]] = 0;") + mainTemplate.indent("installedChunks[chunkIds[i]] = 0;") ])), "}", "return Promise.resolve();" ]); } }); - mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) { - const hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename; - const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename; + mainTemplate.plugin("hot-bootstrap", (source, chunk, hash) => { + const hotUpdateChunkFilename = mainTemplate.outputOptions.hotUpdateChunkFilename; + const hotUpdateMainFilename = mainTemplate.outputOptions.hotUpdateMainFilename; const chunkMaps = chunk.getChunkMaps(); - const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), { - hash: `" + ${this.renderCurrentHashCode(hash)} + "`, - hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`, + const currentHotUpdateChunkFilename = mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: (length) => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`, chunk: { id: "\" + chunkId + \"", hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`, @@ -164,20 +164,20 @@ module.exports = class NodeMainTemplatePlugin { name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "` } }); - const currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), { - hash: `" + ${this.renderCurrentHashCode(hash)} + "`, - hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "` + const currentHotUpdateMainFilename = mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: (length) => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "` }); return Template.getFunctionContent(asyncChunkLoading ? require("./NodeMainTemplateAsync.runtime.js") : require("./NodeMainTemplate.runtime.js")) - .replace(/\$require\$/g, this.requireFn) + .replace(/\$require\$/g, mainTemplate.requireFn) .replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename) .replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename); }); - mainTemplate.plugin("hash", function(hash) { + mainTemplate.plugin("hash", hash => { hash.update("node"); hash.update("3"); - hash.update(this.outputOptions.filename + ""); - hash.update(this.outputOptions.chunkFilename + ""); + hash.update(mainTemplate.outputOptions.filename + ""); + hash.update(mainTemplate.outputOptions.chunkFilename + ""); }); } }; diff --git a/lib/node/NodeSourcePlugin.js b/lib/node/NodeSourcePlugin.js index 1c3913ecc..42520a2f0 100644 --- a/lib/node/NodeSourcePlugin.js +++ b/lib/node/NodeSourcePlugin.js @@ -16,7 +16,7 @@ module.exports = class NodeSourcePlugin { if(options === false) // allow single kill switch to turn off this plugin return; - function getPathToModule(module, type) { + const getPathToModule = (module, type) => { if(type === true || (type === undefined && nodeLibsBrowser[module])) { if(!nodeLibsBrowser[module]) throw new Error(`No browser version for node.js core module ${module} available`); return nodeLibsBrowser[module]; @@ -25,19 +25,19 @@ module.exports = class NodeSourcePlugin { } else if(type === "empty") { return require.resolve("node-libs-browser/mock/empty"); } else return module; - } + }; - function addExpression(parser, name, module, type, suffix) { + const addExpression = (parser, name, module, type, suffix) => { suffix = suffix || ""; - parser.plugin(`expression ${name}`, function() { - if(this.state.module && this.state.module.resource === getPathToModule(module, type)) return; - const mockModule = ParserHelpers.requireFileAsExpression(this.state.module.context, getPathToModule(module, type)); - return ParserHelpers.addParsedVariableToModule(this, name, mockModule + suffix); + parser.plugin(`expression ${name}`, () => { + if(parser.state.module && parser.state.module.resource === getPathToModule(module, type)) return; + const mockModule = ParserHelpers.requireFileAsExpression(parser.state.module.context, getPathToModule(module, type)); + return ParserHelpers.addParsedVariableToModule(parser, name, mockModule + suffix); }); - } + }; - compiler.plugin("compilation", function(compilation, params) { - params.normalModuleFactory.plugin("parser", function(parser, parserOptions) { + compiler.plugin("compilation", (compilation, params) => { + params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { if(parserOptions.node === false) return; @@ -47,9 +47,9 @@ module.exports = class NodeSourcePlugin { localOptions = Object.assign({}, localOptions, parserOptions.node); if(localOptions.global) { - parser.plugin("expression global", function() { - const retrieveGlobalModule = ParserHelpers.requireFileAsExpression(this.state.module.context, require.resolve("../../buildin/global.js")); - return ParserHelpers.addParsedVariableToModule(this, "global", retrieveGlobalModule); + parser.plugin("expression global", () => { + const retrieveGlobalModule = ParserHelpers.requireFileAsExpression(parser.state.module.context, require.resolve("../../buildin/global.js")); + return ParserHelpers.addParsedVariableToModule(parser, "global", retrieveGlobalModule); }); } if(localOptions.process) { diff --git a/lib/optimize/AggressiveMergingPlugin.js b/lib/optimize/AggressiveMergingPlugin.js index e896f97f9..e7bb20673 100644 --- a/lib/optimize/AggressiveMergingPlugin.js +++ b/lib/optimize/AggressiveMergingPlugin.js @@ -16,13 +16,14 @@ class AggressiveMergingPlugin { const options = this.options; const minSizeReduce = options.minSizeReduce || 1.5; - function getParentsWeight(chunk) { + const getParentsWeight = chunk => { return chunk.mapParents((p) => { return p.isInitial() ? options.entryChunkMultiplicator || 10 : 1; }).reduce((a, b) => { return a + b; }, 0); - } + }; + compiler.plugin("this-compilation", (compilation) => { compilation.plugin("optimize-chunks-advanced", (chunks) => { let combinations = []; diff --git a/lib/optimize/AggressiveSplittingPlugin.js b/lib/optimize/AggressiveSplittingPlugin.js index be466d03a..20375a0da 100644 --- a/lib/optimize/AggressiveSplittingPlugin.js +++ b/lib/optimize/AggressiveSplittingPlugin.js @@ -6,27 +6,27 @@ const identifierUtils = require("../util/identifier"); -function moveModuleBetween(oldChunk, newChunk) { - return function(module) { +const moveModuleBetween = (oldChunk, newChunk) => { + return module => { oldChunk.moveModule(module, newChunk); }; -} +}; -function isNotAEntryModule(entryModule) { - return function(module) { +const isNotAEntryModule = entryModule => { + return module => { return entryModule !== module; }; -} +}; -function copyWithReason(obj) { +const copyWithReason = obj => { const newObj = {}; - Object.keys(obj).forEach((key) => { + Object.keys(obj).forEach(key => { newObj[key] = obj[key]; }); if(!newObj.reasons || newObj.reasons.indexOf("aggressive-splitted") < 0) newObj.reasons = (newObj.reasons || []).concat("aggressive-splitted"); return newObj; -} +}; class AggressiveSplittingPlugin { constructor(options) { diff --git a/lib/optimize/ConcatenatedModule.js b/lib/optimize/ConcatenatedModule.js index 2e6028611..ed464715d 100644 --- a/lib/optimize/ConcatenatedModule.js +++ b/lib/optimize/ConcatenatedModule.js @@ -19,7 +19,7 @@ const HarmonyExportExpressionDependency = require("../dependencies/HarmonyExport const HarmonyExportImportedSpecifierDependency = require("../dependencies/HarmonyExportImportedSpecifierDependency"); const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency"); -function ensureNsObjSource(info, moduleToInfoMap, requestShortener) { +const ensureNsObjSource = (info, moduleToInfoMap, requestShortener) => { if(!info.hasNamespaceObject) { info.hasNamespaceObject = true; const name = info.exportMap.get(true); @@ -30,9 +30,9 @@ function ensureNsObjSource(info, moduleToInfoMap, requestShortener) { } info.namespaceObjectSource = nsObj.join("\n") + "\n"; } -} +}; -function getExternalImport(importedModule, info, exportName, asCall) { +const getExternalImport = (importedModule, info, exportName, asCall) => { if(exportName === true) return info.name; const used = importedModule.isUsed(exportName); if(!used) return "/* unused reexport */undefined"; @@ -44,9 +44,9 @@ function getExternalImport(importedModule, info, exportName, asCall) { if(asCall) return `Object(${reference})`; return reference; -} +}; -function getFinalName(info, exportName, moduleToInfoMap, requestShortener, asCall) { +const getFinalName = (info, exportName, moduleToInfoMap, requestShortener, asCall) => { switch(info.type) { case "concatenated": { @@ -78,9 +78,9 @@ function getFinalName(info, exportName, moduleToInfoMap, requestShortener, asCal return getExternalImport(importedModule, info, exportName, asCall); } } -} +}; -function getSymbolsFromScope(s, untilScope) { +const getSymbolsFromScope = (s, untilScope) => { const allUsedNames = new Set(); let scope = s; while(scope) { @@ -89,9 +89,9 @@ function getSymbolsFromScope(s, untilScope) { scope = scope.upper; } return allUsedNames; -} +}; -function getAllReferences(variable) { +const getAllReferences = variable => { let set = variable.references; // Look for inner scope variables too (like in class Foo { t() { Foo } }) const identifiers = new Set(variable.identifiers); @@ -104,19 +104,35 @@ function getAllReferences(variable) { } } return set; -} +}; -function reduceSet(a, b) { +const reduceSet = (a, b) => { for(const item of b) a.add(item); return a; -} +}; -function getPathInAst(ast, node) { +const getPathInAst = (ast, node) => { if(ast === node) { return []; } + const nr = node.range; + + const enterNode = n => { + const r = n.range; + if(r) { + if(r[0] <= nr[0] && r[1] >= nr[1]) { + const path = getPathInAst(n, node); + if(path) { + path.push(n); + return path; + } + } + } + return undefined; + }; + var i; if(Array.isArray(ast)) { for(i = 0; i < ast.length; i++) { @@ -139,21 +155,7 @@ function getPathInAst(ast, node) { } } } - - function enterNode(n) { - const r = n.range; - if(r) { - if(r[0] <= nr[0] && r[1] >= nr[1]) { - const path = getPathInAst(n, node); - if(path) { - path.push(n); - return path; - } - } - } - return undefined; - } -} +}; class ConcatenatedModule extends Module { constructor(rootModule, modules) { @@ -265,7 +267,7 @@ class ConcatenatedModule extends Module { const list = []; const set = new Set(); - function getConcatenatedImports(module) { + const getConcatenatedImports = module => { return module.dependencies .filter(dep => dep instanceof HarmonyImportDependency) .sort((a, b) => a.sourceOrder - b.sourceOrder) @@ -273,9 +275,9 @@ class ConcatenatedModule extends Module { const ref = dep.getReference(); return ref && ref.module; }); - } + }; - function enterModule(getModule) { + const enterModule = getModule => { const module = getModule(); if(!module) return; if(set.has(module)) return; @@ -298,7 +300,7 @@ class ConcatenatedModule extends Module { } }); } - } + }; enterModule(() => rootModule); diff --git a/lib/optimize/ModuleConcatenationPlugin.js b/lib/optimize/ModuleConcatenationPlugin.js index 68249e5eb..e62ff9139 100644 --- a/lib/optimize/ModuleConcatenationPlugin.js +++ b/lib/optimize/ModuleConcatenationPlugin.js @@ -10,9 +10,9 @@ const ModuleHotDeclineDependency = require("../dependencies/ModuleHotDeclineDepe const ConcatenatedModule = require("./ConcatenatedModule"); const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency"); -function formatBailoutReason(msg) { +const formatBailoutReason = msg => { return "ModuleConcatenation bailout: " + msg; -} +}; class ModuleConcatenationPlugin { constructor(options) { @@ -29,16 +29,16 @@ class ModuleConcatenationPlugin { }); const bailoutReasonMap = new Map(); - function setBailoutReason(module, reason) { + const setBailoutReason = (module, reason) => { bailoutReasonMap.set(module, reason); module.optimizationBailout.push(typeof reason === "function" ? (rs) => formatBailoutReason(reason(rs)) : formatBailoutReason(reason)); - } + }; - function getBailoutReason(module, requestShortener) { + const getBailoutReason = (module, requestShortener) => { const reason = bailoutReasonMap.get(module); if(typeof reason === "function") return reason(requestShortener); return reason; - } + }; compilation.plugin("optimize-chunk-modules", (chunks, modules) => { const relevantModules = []; diff --git a/lib/optimize/OccurrenceOrderPlugin.js b/lib/optimize/OccurrenceOrderPlugin.js index e5de3dc41..664866a37 100644 --- a/lib/optimize/OccurrenceOrderPlugin.js +++ b/lib/optimize/OccurrenceOrderPlugin.js @@ -83,9 +83,9 @@ class OccurrenceOrderPlugin { return occursInInitialChunksMap.set(c, result); }); - function occurs(c) { + const occurs = c => { return c.getNumberOfBlocks(); - } + }; chunks.sort((a, b) => { const aEntryOccurs = occursInInitialChunksMap.get(a); diff --git a/lib/optimize/RemoveParentModulesPlugin.js b/lib/optimize/RemoveParentModulesPlugin.js index b92516978..917fd18bb 100644 --- a/lib/optimize/RemoveParentModulesPlugin.js +++ b/lib/optimize/RemoveParentModulesPlugin.js @@ -4,15 +4,15 @@ */ "use strict"; -function hasModule(chunk, module, checkedChunks) { +const hasModule = (chunk, module, checkedChunks) => { if(chunk.containsModule(module)) return [chunk]; if(chunk.getNumberOfParents() === 0) return false; return allHaveModule(chunk.getParents().filter((c) => { return !checkedChunks.has(c); }), module, checkedChunks); -} +}; -function allHaveModule(someChunks, module, checkedChunks) { +const allHaveModule = (someChunks, module, checkedChunks) => { if(!checkedChunks) checkedChunks = new Set(); var chunks = new Set(); for(var i = 0; i < someChunks.length; i++) { @@ -27,7 +27,7 @@ function allHaveModule(someChunks, module, checkedChunks) { } } return chunks; -} +}; class RemoveParentModulesPlugin { apply(compiler) { diff --git a/lib/performance/SizeLimitsPlugin.js b/lib/performance/SizeLimitsPlugin.js index 9cb4366f2..9c813d282 100644 --- a/lib/performance/SizeLimitsPlugin.js +++ b/lib/performance/SizeLimitsPlugin.js @@ -89,9 +89,9 @@ module.exports = class SizeLimitsPlugin { } if(hints === "error") { - Array.prototype.push.apply(compilation.errors, warnings); + compilation.errors.push(...warnings); } else { - Array.prototype.push.apply(compilation.warnings, warnings); + compilation.warnings.push(...warnings); } } } diff --git a/lib/prepareOptions.js b/lib/prepareOptions.js index d7cf1ada5..25686c016 100644 --- a/lib/prepareOptions.js +++ b/lib/prepareOptions.js @@ -1,6 +1,21 @@ "use strict"; -module.exports = function prepareOptions(options, argv) { +const handleExport = options => { + const isES6DefaultExported = ( + typeof options === "object" && options !== null && typeof options.default !== "undefined" + ); + options = isES6DefaultExported ? options.default : options; + return options; +}; + +const handleFunction = (options, argv) => { + if(typeof options === "function") { + options = options(argv.env, argv); + } + return options; +}; + +module.exports = (options, argv) => { argv = argv || {}; options = handleExport(options); @@ -12,18 +27,3 @@ module.exports = function prepareOptions(options, argv) { } return options; }; - -function handleExport(options) { - const isES6DefaultExported = ( - typeof options === "object" && options !== null && typeof options.default !== "undefined" - ); - options = isES6DefaultExported ? options.default : options; - return options; -} - -function handleFunction(options, argv) { - if(typeof options === "function") { - options = options(argv.env, argv); - } - return options; -} diff --git a/lib/removeAndDo.js b/lib/removeAndDo.js index c4c20d676..f7bc28807 100644 --- a/lib/removeAndDo.js +++ b/lib/removeAndDo.js @@ -4,7 +4,8 @@ */ "use strict"; -module.exports = function removeAndDo(collection, thing, action) { +// TODO can this be deleted? +module.exports = (collection, thing, action) => { const idx = this[collection].indexOf(thing); const hasThingInCollection = idx >= 0; if(hasThingInCollection) { diff --git a/lib/validateSchema.js b/lib/validateSchema.js index 7590c236b..0354aaeec 100644 --- a/lib/validateSchema.js +++ b/lib/validateSchema.js @@ -13,16 +13,17 @@ const ajv = new Ajv({ require("ajv-keywords")(ajv, ["instanceof"]); require("../schemas/ajv.absolutePath")(ajv); -function validateSchema(schema, options) { +const validateSchema = (schema, options) => { if(Array.isArray(options)) { const errors = options.map((options) => validateObject(schema, options)); errors.forEach((list, idx) => { - list.forEach(function applyPrefix(err) { + const applyPrefix = err => { err.dataPath = `[${idx}]${err.dataPath}`; if(err.children) { err.children.forEach(applyPrefix); } - }); + }; + list.forEach(applyPrefix); }); return errors.reduce((arr, items) => { return arr.concat(items); @@ -30,15 +31,15 @@ function validateSchema(schema, options) { } else { return validateObject(schema, options); } -} +}; -function validateObject(schema, options) { +const validateObject = (schema, options) => { const validate = ajv.compile(schema); const valid = validate(options); return valid ? [] : filterErrors(validate.errors); -} +}; -function filterErrors(errors) { +const filterErrors = errors => { let newErrors = []; errors.forEach((err) => { const dataPath = err.dataPath; @@ -61,6 +62,6 @@ function filterErrors(errors) { }); return newErrors; -} +}; module.exports = validateSchema; diff --git a/lib/webpack.js b/lib/webpack.js index b1ab7b96a..007a1a5ce 100644 --- a/lib/webpack.js +++ b/lib/webpack.js @@ -13,7 +13,7 @@ const validateSchema = require("./validateSchema"); const WebpackOptionsValidationError = require("./WebpackOptionsValidationError"); const webpackOptionsSchema = require("../schemas/webpackOptionsSchema.json"); -function webpack(options, callback) { +const webpack = (options, callback) => { const webpackOptionsValidationErrors = validateSchema(webpackOptionsSchema, options); if(webpackOptionsValidationErrors.length) { throw new WebpackOptionsValidationError(webpackOptionsValidationErrors); @@ -46,7 +46,8 @@ function webpack(options, callback) { compiler.run(callback); } return compiler; -} +}; + exports = module.exports = webpack; webpack.WebpackOptionsDefaulter = WebpackOptionsDefaulter; @@ -58,7 +59,7 @@ webpack.validate = validateSchema.bind(this, webpackOptionsSchema); webpack.validateSchema = validateSchema; webpack.WebpackOptionsValidationError = WebpackOptionsValidationError; -function exportPlugins(obj, mappings) { +const exportPlugins = (obj, mappings) => { Object.keys(mappings).forEach(name => { Object.defineProperty(obj, name, { configurable: false, @@ -66,7 +67,7 @@ function exportPlugins(obj, mappings) { get: mappings[name] }); }); -} +}; exportPlugins(exports, { "DefinePlugin": () => require("./DefinePlugin"), diff --git a/lib/webworker/WebWorkerChunkTemplatePlugin.js b/lib/webworker/WebWorkerChunkTemplatePlugin.js index 03b9374f7..4a28ec0a8 100644 --- a/lib/webworker/WebWorkerChunkTemplatePlugin.js +++ b/lib/webworker/WebWorkerChunkTemplatePlugin.js @@ -10,19 +10,19 @@ const Template = require("../Template"); class WebWorkerChunkTemplatePlugin { apply(chunkTemplate) { - chunkTemplate.plugin("render", function(modules, chunk) { - const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || "")); + chunkTemplate.plugin("render", (modules, chunk) => { + const chunkCallbackName = chunkTemplate.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (chunkTemplate.outputOptions.library || "")); const source = new ConcatSource(); source.add(`${chunkCallbackName}(${JSON.stringify(chunk.ids)},`); source.add(modules); source.add(")"); return source; }); - chunkTemplate.plugin("hash", function(hash) { + chunkTemplate.plugin("hash", hash => { hash.update("webworker"); hash.update("3"); - hash.update(`${this.outputOptions.chunkCallbackName}`); - hash.update(`${this.outputOptions.library}`); + hash.update(`${chunkTemplate.outputOptions.chunkCallbackName}`); + hash.update(`${chunkTemplate.outputOptions.library}`); }); } } diff --git a/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js b/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js index b3e90d26a..a877c1b2c 100644 --- a/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js +++ b/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js @@ -9,19 +9,19 @@ const Template = require("../Template"); class WebWorkerHotUpdateChunkTemplatePlugin { apply(hotUpdateChunkTemplate) { - hotUpdateChunkTemplate.plugin("render", function(modulesSource, modules, removedModules, hash, id) { - const chunkCallbackName = this.outputOptions.hotUpdateFunction || Template.toIdentifier("webpackHotUpdate" + (this.outputOptions.library || "")); + hotUpdateChunkTemplate.plugin("render", (modulesSource, modules, removedModules, hash, id) => { + const chunkCallbackName = hotUpdateChunkTemplate.outputOptions.hotUpdateFunction || Template.toIdentifier("webpackHotUpdate" + (hotUpdateChunkTemplate.outputOptions.library || "")); const source = new ConcatSource(); source.add(chunkCallbackName + "(" + JSON.stringify(id) + ","); source.add(modulesSource); source.add(")"); return source; }); - hotUpdateChunkTemplate.plugin("hash", function(hash) { + hotUpdateChunkTemplate.plugin("hash", hash => { hash.update("WebWorkerHotUpdateChunkTemplatePlugin"); hash.update("3"); - hash.update(this.outputOptions.hotUpdateFunction + ""); - hash.update(this.outputOptions.library + ""); + hash.update(hotUpdateChunkTemplate.outputOptions.hotUpdateFunction + ""); + hash.update(hotUpdateChunkTemplate.outputOptions.library + ""); }); } } diff --git a/lib/webworker/WebWorkerMainTemplatePlugin.js b/lib/webworker/WebWorkerMainTemplatePlugin.js index e48504eac..387e73d0b 100644 --- a/lib/webworker/WebWorkerMainTemplatePlugin.js +++ b/lib/webworker/WebWorkerMainTemplatePlugin.js @@ -8,15 +8,15 @@ const Template = require("../Template"); class WebWorkerMainTemplatePlugin { apply(mainTemplate) { - mainTemplate.plugin("local-vars", function(source, chunk) { + mainTemplate.plugin("local-vars", (source, chunk) => { if(chunk.getNumberOfChunks() > 0) { - return this.asString([ + return mainTemplate.asString([ source, "", "// object to store loaded chunks", "// \"1\" means \"already loaded\"", "var installedChunks = {", - this.indent( + mainTemplate.indent( chunk.ids.map((id) => `${id}: 1`).join(",\n") ), "};" @@ -24,18 +24,18 @@ class WebWorkerMainTemplatePlugin { } return source; }); - mainTemplate.plugin("require-ensure", function(_, chunk, hash) { - const chunkFilename = this.outputOptions.chunkFilename; - return this.asString([ + mainTemplate.plugin("require-ensure", (_, chunk, hash) => { + const chunkFilename = mainTemplate.outputOptions.chunkFilename; + return mainTemplate.asString([ "return new Promise(function(resolve) {", - this.indent([ + mainTemplate.indent([ "// \"1\" is the signal for \"already loaded\"", "if(!installedChunks[chunkId]) {", - this.indent([ + mainTemplate.indent([ "importScripts(" + - this.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), { - hash: `" + ${this.renderCurrentHashCode(hash)} + "`, - hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`, + mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: (length) => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`, chunk: { id: "\" + chunkId + \"" } @@ -47,38 +47,38 @@ class WebWorkerMainTemplatePlugin { "});" ]); }); - mainTemplate.plugin("bootstrap", function(source, chunk, hash) { + mainTemplate.plugin("bootstrap", (source, chunk, hash) => { if(chunk.getNumberOfChunks() > 0) { - const chunkCallbackName = this.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (this.outputOptions.library || "")); - return this.asString([ + const chunkCallbackName = mainTemplate.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (mainTemplate.outputOptions.library || "")); + return mainTemplate.asString([ source, - `this[${JSON.stringify(chunkCallbackName)}] = function webpackChunkCallback(chunkIds, moreModules) {`, - this.indent([ + `mainTemplate[${JSON.stringify(chunkCallbackName)}] = function webpackChunkCallback(chunkIds, moreModules) {`, + mainTemplate.indent([ "for(var moduleId in moreModules) {", - this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")), + mainTemplate.indent(mainTemplate.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")), "}", "while(chunkIds.length)", - this.indent("installedChunks[chunkIds.pop()] = 1;") + mainTemplate.indent("installedChunks[chunkIds.pop()] = 1;") ]), "};" ]); } return source; }); - mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) { - const hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename; - const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename; - const hotUpdateFunction = this.outputOptions.hotUpdateFunction || Template.toIdentifier("webpackHotUpdate" + (this.outputOptions.library || "")); - const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), { - hash: `" + ${this.renderCurrentHashCode(hash)} + "`, - hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`, + mainTemplate.plugin("hot-bootstrap", (source, chunk, hash) => { + const hotUpdateChunkFilename = mainTemplate.outputOptions.hotUpdateChunkFilename; + const hotUpdateMainFilename = mainTemplate.outputOptions.hotUpdateMainFilename; + const hotUpdateFunction = mainTemplate.outputOptions.hotUpdateFunction || Template.toIdentifier("webpackHotUpdate" + (mainTemplate.outputOptions.library || "")); + const currentHotUpdateChunkFilename = mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: (length) => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`, chunk: { id: "\" + chunkId + \"" } }); - const currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), { - hash: `" + ${this.renderCurrentHashCode(hash)} + "`, - hashWithLength: (length) => `" + ${this.renderCurrentHashCode(hash, length)} + "`, + const currentHotUpdateMainFilename = mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: (length) => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`, }); return source + "\n" + @@ -86,19 +86,19 @@ class WebWorkerMainTemplatePlugin { `this[${JSON.stringify(hotUpdateFunction)}] = ` + Template.getFunctionContent(require("./WebWorkerMainTemplate.runtime.js")) .replace(/\/\/\$semicolon/g, ";") - .replace(/\$require\$/g, this.requireFn) + .replace(/\$require\$/g, mainTemplate.requireFn) .replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename) .replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename) .replace(/\$hash\$/g, JSON.stringify(hash)); }); - mainTemplate.plugin("hash", function(hash) { + mainTemplate.plugin("hash", hash => { hash.update("webworker"); hash.update("3"); - hash.update(`${this.outputOptions.publicPath}`); - hash.update(`${this.outputOptions.filename}`); - hash.update(`${this.outputOptions.chunkFilename}`); - hash.update(`${this.outputOptions.chunkCallbackName}`); - hash.update(`${this.outputOptions.library}`); + hash.update(`${mainTemplate.outputOptions.publicPath}`); + hash.update(`${mainTemplate.outputOptions.filename}`); + hash.update(`${mainTemplate.outputOptions.chunkFilename}`); + hash.update(`${mainTemplate.outputOptions.chunkCallbackName}`); + hash.update(`${mainTemplate.outputOptions.library}`); }); } } From 594f639282c52c623c8a8a9144ece29048d295ab Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 8 Nov 2017 19:34:05 +0100 Subject: [PATCH 16/85] allow to pass functions to rules.use and return arrays --- lib/RuleSet.js | 35 +++++++------ .../rule-set/simple-use-array-fn/a.js | 1 + .../rule-set/simple-use-array-fn/ab.js | 1 + .../rule-set/simple-use-array-fn/b.js | 2 + .../rule-set/simple-use-array-fn/c.js | 1 + .../rule-set/simple-use-array-fn/index.js | 21 ++++++++ .../rule-set/simple-use-array-fn/loader.js | 8 +++ .../simple-use-array-fn/webpack.config.js | 50 +++++++++++++++++++ 8 files changed, 101 insertions(+), 18 deletions(-) create mode 100644 test/configCases/rule-set/simple-use-array-fn/a.js create mode 100644 test/configCases/rule-set/simple-use-array-fn/ab.js create mode 100644 test/configCases/rule-set/simple-use-array-fn/b.js create mode 100644 test/configCases/rule-set/simple-use-array-fn/c.js create mode 100644 test/configCases/rule-set/simple-use-array-fn/index.js create mode 100644 test/configCases/rule-set/simple-use-array-fn/loader.js create mode 100644 test/configCases/rule-set/simple-use-array-fn/webpack.config.js diff --git a/lib/RuleSet.js b/lib/RuleSet.js index 3c4a37451..2b4ec5956 100644 --- a/lib/RuleSet.js +++ b/lib/RuleSet.js @@ -228,6 +228,9 @@ module.exports = class RuleSet { } static normalizeUse(use, ident) { + if(typeof use === "function") { + return data => RuleSet.normalizeUse(use(data), ident); + } if(Array.isArray(use)) { return use .map((item, idx) => RuleSet.normalizeUse(item, `${ident}-${idx}`)) @@ -236,14 +239,6 @@ module.exports = class RuleSet { return [RuleSet.normalizeUseItem(use, ident)]; } - static normalizeUseItemFunction(use, data) { - const result = use(data); - if(typeof result === "string") { - return RuleSet.normalizeUseItem(result); - } - return result; - } - static normalizeUseItemString(useItemString) { const idx = useItemString.indexOf("?"); if(idx >= 0) { @@ -258,9 +253,6 @@ module.exports = class RuleSet { } static normalizeUseItem(item, ident) { - if(typeof item === "function") - return item; - if(typeof item === "string") { return RuleSet.normalizeUseItemString(item); } @@ -385,13 +377,20 @@ module.exports = class RuleSet { }); if(rule.use) { - rule.use.forEach((use) => { - result.push({ - type: "use", - value: typeof use === "function" ? RuleSet.normalizeUseItemFunction(use, data) : use, - enforce: rule.enforce - }); - }); + const process = use => { + if(typeof use === "function") { + process(use(data)); + } else if(Array.isArray(use)) { + use.forEach(process); + } else { + result.push({ + type: "use", + value: use, + enforce: rule.enforce + }); + } + }; + process(rule.use); } if(rule.rules) { diff --git a/test/configCases/rule-set/simple-use-array-fn/a.js b/test/configCases/rule-set/simple-use-array-fn/a.js new file mode 100644 index 000000000..505ce5468 --- /dev/null +++ b/test/configCases/rule-set/simple-use-array-fn/a.js @@ -0,0 +1 @@ +module.exports = ["a"]; diff --git a/test/configCases/rule-set/simple-use-array-fn/ab.js b/test/configCases/rule-set/simple-use-array-fn/ab.js new file mode 100644 index 000000000..21a71ba9d --- /dev/null +++ b/test/configCases/rule-set/simple-use-array-fn/ab.js @@ -0,0 +1 @@ +module.exports = ["ab"]; diff --git a/test/configCases/rule-set/simple-use-array-fn/b.js b/test/configCases/rule-set/simple-use-array-fn/b.js new file mode 100644 index 000000000..5af4d6fe9 --- /dev/null +++ b/test/configCases/rule-set/simple-use-array-fn/b.js @@ -0,0 +1,2 @@ +module.exports = [require("./a")]; + diff --git a/test/configCases/rule-set/simple-use-array-fn/c.js b/test/configCases/rule-set/simple-use-array-fn/c.js new file mode 100644 index 000000000..d24a6782a --- /dev/null +++ b/test/configCases/rule-set/simple-use-array-fn/c.js @@ -0,0 +1 @@ +// never used \ No newline at end of file diff --git a/test/configCases/rule-set/simple-use-array-fn/index.js b/test/configCases/rule-set/simple-use-array-fn/index.js new file mode 100644 index 000000000..5c0fb1255 --- /dev/null +++ b/test/configCases/rule-set/simple-use-array-fn/index.js @@ -0,0 +1,21 @@ +it("should match only one rule in a oneOf block", function() { + var ab = require("./ab"); + ab.should.be.eql([ + "ab", + "?first" + ]); +}); +it("should match with issuer and any option value", function() { + var a = require("./a"); + var b = require("./b"); + a.should.be.eql([ + "a", + "?third", + ]); + b.should.be.eql([[ + "a", + "second-3", + "?second-2", + "?second-1", + ]]); +}); diff --git a/test/configCases/rule-set/simple-use-array-fn/loader.js b/test/configCases/rule-set/simple-use-array-fn/loader.js new file mode 100644 index 000000000..f78d43c0b --- /dev/null +++ b/test/configCases/rule-set/simple-use-array-fn/loader.js @@ -0,0 +1,8 @@ +module.exports = function(source) { + var query = this.query; + if(typeof query === "object" && typeof query.get === "function") { + query = query.get(); + } + return source + "\nmodule.exports.push(" + JSON.stringify(query) + ");"; +}; + diff --git a/test/configCases/rule-set/simple-use-array-fn/webpack.config.js b/test/configCases/rule-set/simple-use-array-fn/webpack.config.js new file mode 100644 index 000000000..93e68fda3 --- /dev/null +++ b/test/configCases/rule-set/simple-use-array-fn/webpack.config.js @@ -0,0 +1,50 @@ +module.exports = { + module: { + rules: [ + { oneOf: [ + { + test: { + and: [ + /a.\.js$/, + /b\.js$/ + ] + }, + loader: "./loader?first" + }, + { + test: [ + require.resolve("./a"), + require.resolve("./c"), + ], + issuer: require.resolve("./b"), + use: data => ([ + "./loader?second-1", + { + loader: "./loader", + options: "second-2" + }, + { + loader: "./loader", + options: { + get: function() { + return "second-3"; + } + } + } + ]) + }, + { + test: { + or: [ + require.resolve("./a"), + require.resolve("./c"), + ] + }, + loader: "./loader", + options: "third" + } + ] } + ] + } +}; + From 1ff28f8961155f32eb95b0c4de1f766fc5703fe7 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 8 Nov 2017 11:59:38 +0100 Subject: [PATCH 17/85] remove unused code and broken unittests --- lib/removeAndDo.js | 16 - ...npHotUpdateChunkTemplatePlugin.unittest.js | 63 ---- ...deHotUpdateChunkTemplatePlugin.unittest.js | 64 ---- test/WebWorkerChunkTemplatePlugin.unittest.js | 91 ------ ...erHotUpdateChunkTemplatePlugin.unittest.js | 77 ----- test/WebWorkerMainTemplatePlugin.unittest.js | 284 ------------------ test/removeAndDo.unittest.js | 36 --- 7 files changed, 631 deletions(-) delete mode 100644 lib/removeAndDo.js delete mode 100644 test/JsonpHotUpdateChunkTemplatePlugin.unittest.js delete mode 100644 test/NodeHotUpdateChunkTemplatePlugin.unittest.js delete mode 100644 test/WebWorkerChunkTemplatePlugin.unittest.js delete mode 100644 test/WebWorkerHotUpdateChunkTemplatePlugin.unittest.js delete mode 100644 test/WebWorkerMainTemplatePlugin.unittest.js delete mode 100644 test/removeAndDo.unittest.js diff --git a/lib/removeAndDo.js b/lib/removeAndDo.js deleted file mode 100644 index f7bc28807..000000000 --- a/lib/removeAndDo.js +++ /dev/null @@ -1,16 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -// TODO can this be deleted? -module.exports = (collection, thing, action) => { - const idx = this[collection].indexOf(thing); - const hasThingInCollection = idx >= 0; - if(hasThingInCollection) { - this[collection].splice(idx, 1); - thing[action](this); - } - return hasThingInCollection; -}; diff --git a/test/JsonpHotUpdateChunkTemplatePlugin.unittest.js b/test/JsonpHotUpdateChunkTemplatePlugin.unittest.js deleted file mode 100644 index 01fac6993..000000000 --- a/test/JsonpHotUpdateChunkTemplatePlugin.unittest.js +++ /dev/null @@ -1,63 +0,0 @@ -"use strict"; - -const should = require("should"); -const sinon = require("sinon"); -const ConcatSource = require("webpack-sources").ConcatSource; -const JsonpHotUpdateChunkTemplatePlugin = require("../lib/JsonpHotUpdateChunkTemplatePlugin"); -const applyPluginWithOptions = require("./helpers/applyPluginWithOptions"); - -describe("JsonpHotUpdateChunkTemplatePlugin", () => { - let handlerContext; - - beforeEach(() => - handlerContext = { - outputOptions: { - hotUpdateFunction: "Foo", - library: "Bar" - } - }); - - it("has apply function", () => (new JsonpHotUpdateChunkTemplatePlugin()).apply.should.be.a.Function()); - - describe("when applied", () => { - let eventBindings, eventBinding; - - beforeEach(() => eventBindings = applyPluginWithOptions(JsonpHotUpdateChunkTemplatePlugin)); - - it("binds two event handlers", () => eventBindings.length.should.be.exactly(2)); - - describe("render handler", () => { - beforeEach(() => eventBinding = eventBindings[0]); - - it("binds to render event", () => eventBinding.name.should.be.exactly("render")); - - it("creates source wrapper with export", () => { - const source = eventBinding.handler.call(handlerContext, "moduleSource()", [], [], {}, 100); - source.should.be.instanceof(ConcatSource); - source.source().should.be.exactly("Foo(100,moduleSource())"); - }); - }); - - describe("hash handler", () => { - let hashMock; - - beforeEach(() => { - eventBinding = eventBindings[1]; - hashMock = { - update: sinon.spy() - }; - }); - - it("binds to hash event", () => eventBinding.name.should.be.exactly("hash")); - - it("updates hash object", () => { - eventBinding.handler.call(handlerContext, hashMock); - hashMock.update.callCount.should.be.exactly(4); - sinon.assert.calledWith(hashMock.update, "JsonpHotUpdateChunkTemplatePlugin"); - sinon.assert.calledWith(hashMock.update, "3"); - sinon.assert.calledWith(hashMock.update, "Foo"); - sinon.assert.calledWith(hashMock.update, "Bar"); - }); - }); - }); -}); diff --git a/test/NodeHotUpdateChunkTemplatePlugin.unittest.js b/test/NodeHotUpdateChunkTemplatePlugin.unittest.js deleted file mode 100644 index 2ebf62ae8..000000000 --- a/test/NodeHotUpdateChunkTemplatePlugin.unittest.js +++ /dev/null @@ -1,64 +0,0 @@ -"use strict"; - -const should = require("should"); -const sinon = require("sinon"); -const ConcatSource = require("webpack-sources").ConcatSource; -const NodeHotUpdateChunkTemplatePlugin = require("../lib/node/NodeHotUpdateChunkTemplatePlugin"); -const applyPluginWithOptions = require("./helpers/applyPluginWithOptions"); - -describe("NodeHotUpdateChunkTemplatePlugin", () => { - let handlerContext; - - beforeEach(() => { - handlerContext = { - outputOptions: { - hotUpdateFunction: "Foo", - library: "Bar" - } - }; - }); - - it("has apply function", () => (new NodeHotUpdateChunkTemplatePlugin()).apply.should.be.a.Function()); - - describe("when applied", () => { - let eventBindings, eventBinding; - - beforeEach(() => eventBindings = applyPluginWithOptions(NodeHotUpdateChunkTemplatePlugin)); - - it("binds two event handlers", () => eventBindings.length.should.be.exactly(2)); - - describe("render handler", () => { - beforeEach(() => eventBinding = eventBindings[0]); - - it("binds to render event", () => eventBinding.name.should.be.exactly("render")); - - it("creates source wrapper with export", () => { - const source = eventBinding.handler.call(handlerContext, "moduleSource()", [], [], {}, 100); - source.should.be.instanceof(ConcatSource); - source.source().should.be.exactly("exports.id = 100;\nexports.modules = moduleSource();"); - }); - }); - - describe("hash handler", () => { - let hashMock; - - beforeEach(() => { - eventBinding = eventBindings[1]; - hashMock = { - update: sinon.spy() - }; - }); - - it("binds to hash event", () => eventBinding.name.should.be.exactly("hash")); - - it("updates hash object", () => { - eventBinding.handler.call(handlerContext, hashMock); - hashMock.update.callCount.should.be.exactly(4); - sinon.assert.calledWith(hashMock.update, "NodeHotUpdateChunkTemplatePlugin"); - sinon.assert.calledWith(hashMock.update, "3"); - sinon.assert.calledWith(hashMock.update, "Foo"); - sinon.assert.calledWith(hashMock.update, "Bar"); - }); - }); - }); -}); diff --git a/test/WebWorkerChunkTemplatePlugin.unittest.js b/test/WebWorkerChunkTemplatePlugin.unittest.js deleted file mode 100644 index ee7d64d67..000000000 --- a/test/WebWorkerChunkTemplatePlugin.unittest.js +++ /dev/null @@ -1,91 +0,0 @@ -"use strict"; - -const should = require("should"); -const sinon = require("sinon"); -const ConcatSource = require("webpack-sources").ConcatSource; -const WebWorkerChunkTemplatePlugin = require("../lib/webworker/WebWorkerChunkTemplatePlugin"); -const applyPluginWithOptions = require("./helpers/applyPluginWithOptions"); - -describe("WebWorkerChunkTemplatePlugin", () => { - let handlerContext; - - beforeEach(() => { - handlerContext = { - outputOptions: { - chunkCallbackName: "Foo", - library: "Bar" - } - }; - }); - - it("has apply function", () => { - (new WebWorkerChunkTemplatePlugin()).apply.should.be.a.Function(); - }); - - describe("when applied", () => { - let eventBindings, eventBinding; - - beforeEach(() => { - eventBindings = applyPluginWithOptions(WebWorkerChunkTemplatePlugin); - }); - - it("binds two event handlers", () => { - eventBindings.length.should.be.exactly(2); - }); - - describe("render handler", () => { - beforeEach(() => { - eventBinding = eventBindings[0]; - }); - - it("binds to render event", () => { - eventBinding.name.should.be.exactly("render"); - }); - - describe("with chunk call back name set", () => { - it("creates source wrapper with function name", () => { - const source = eventBinding.handler.call(handlerContext, "modules()", { - ids: 100, - }); - source.should.be.instanceof(ConcatSource); - source.source().should.be.exactly("Foo(100,modules())"); - }); - }); - - describe("without chunk call back name set", () => { - it("creates source wrapper with library name", () => { - delete handlerContext.outputOptions.chunkCallbackName; - const source = eventBinding.handler.call(handlerContext, "modules()", { - ids: 100, - }); - source.should.be.instanceof(ConcatSource); - source.source().should.be.exactly("webpackChunkBar(100,modules())"); - }); - }); - }); - - describe("hash handler", () => { - var hashMock; - - beforeEach(() => { - eventBinding = eventBindings[1]; - hashMock = { - update: sinon.spy() - }; - }); - - it("binds to hash event", () => { - eventBinding.name.should.be.exactly("hash"); - }); - - it("updates hash object", () => { - eventBinding.handler.call(handlerContext, hashMock); - hashMock.update.callCount.should.be.exactly(4); - sinon.assert.calledWith(hashMock.update, "webworker"); - sinon.assert.calledWith(hashMock.update, "3"); - sinon.assert.calledWith(hashMock.update, "Foo"); - sinon.assert.calledWith(hashMock.update, "Bar"); - }); - }); - }); -}); diff --git a/test/WebWorkerHotUpdateChunkTemplatePlugin.unittest.js b/test/WebWorkerHotUpdateChunkTemplatePlugin.unittest.js deleted file mode 100644 index fcca8d2cc..000000000 --- a/test/WebWorkerHotUpdateChunkTemplatePlugin.unittest.js +++ /dev/null @@ -1,77 +0,0 @@ -"use strict"; - -const should = require("should"); -const sinon = require("sinon"); -const ConcatSource = require("webpack-sources").ConcatSource; -const WebWorkerHotUpdateChunkTemplatePlugin = require("../lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin"); -const applyPluginWithOptions = require("./helpers/applyPluginWithOptions"); - -describe("WebWorkerHotUpdateChunkTemplatePlugin", () => { - let handlerContext; - - beforeEach(() => { - handlerContext = { - outputOptions: { - hotUpdateFunction: "Foo", - library: "Bar" - } - }; - }); - - it("has apply function", () => (new WebWorkerHotUpdateChunkTemplatePlugin()).apply.should.be.a.Function()); - - describe("when applied", () => { - let eventBindings, eventBinding; - - beforeEach(() => eventBindings = applyPluginWithOptions(WebWorkerHotUpdateChunkTemplatePlugin)); - - it("binds two event handlers", () => eventBindings.length.should.be.exactly(2)); - - describe("render handler", () => { - beforeEach(() => eventBinding = eventBindings[0]); - - it("binds to render event", () => eventBinding.name.should.be.exactly("render")); - - describe("with hot update function name set", () => { - it("creates source wrapper with function name", () => { - const source = eventBinding.handler.call(handlerContext, "moduleSource()", [], [], {}, 100); - source.should.be.instanceof(ConcatSource); - source.source().should.be.exactly("Foo(100,moduleSource())"); - }); - }); - - describe("without hot update function name set", () => { - it("creates source wrapper with library name", () => { - delete handlerContext.outputOptions.hotUpdateFunction; - const source = eventBinding.handler.call(handlerContext, "moduleSource()", [], [], {}, 100); - source.should.be.instanceof(ConcatSource); - source.source().should.be.exactly("webpackHotUpdateBar(100,moduleSource())"); - }); - }); - }); - - describe("hash handler", () => { - let hashMock; - - beforeEach(() => { - eventBinding = eventBindings[1]; - hashMock = { - update: sinon.spy() - }; - }); - - it("binds to hash event", () => { - eventBinding.name.should.be.exactly("hash"); - }); - - it("updates hash object", () => { - eventBinding.handler.call(handlerContext, hashMock); - hashMock.update.callCount.should.be.exactly(4); - sinon.assert.calledWith(hashMock.update, "WebWorkerHotUpdateChunkTemplatePlugin"); - sinon.assert.calledWith(hashMock.update, "3"); - sinon.assert.calledWith(hashMock.update, "Foo"); - sinon.assert.calledWith(hashMock.update, "Bar"); - }); - }); - }); -}); diff --git a/test/WebWorkerMainTemplatePlugin.unittest.js b/test/WebWorkerMainTemplatePlugin.unittest.js deleted file mode 100644 index 886e7e8e1..000000000 --- a/test/WebWorkerMainTemplatePlugin.unittest.js +++ /dev/null @@ -1,284 +0,0 @@ -/* globals describe, beforeEach, it */ -"use strict"; - -require("should"); -const sinon = require("sinon"); -const WebWorkerMainTemplatePlugin = require("../lib/webworker/WebWorkerMainTemplatePlugin"); -const applyPluginWithOptions = require("./helpers/applyPluginWithOptions"); - -const createMockChunk = (ids, chunks) => { - return { - ids: ids, - _chunks: new Set(chunks), - getChunks() { - return Array.from(this._chunks); - }, - getNumberOfChunks() { - return this._chunks.size; - } - }; -}; - -describe("WebWorkerMainTemplatePlugin", function() { - let env; - - beforeEach(() => { - env = {}; - }); - - it("has apply function", function() { - (new WebWorkerMainTemplatePlugin()).apply.should.be.a.Function(); - }); - - describe("when applied", function() { - beforeEach(function() { - env.eventBindings = applyPluginWithOptions(WebWorkerMainTemplatePlugin); - env.handlerContext = { - requireFn: "requireFn", - indent: (value) => typeof value === "string" ? value : value.join("\n"), - asString: (values) => values.join("\n"), - renderCurrentHashCode: (value) => value, - outputOptions: { - chunkFilename: "chunkFilename" - }, - applyPluginsWaterfall: (moduleName, fileName, data) => { - return `"${moduleName}${data.hash}${data.hashWithLength()}${data.chunk && data.chunk.id || ""}"`; - }, - renderAddModule: () => "renderAddModuleSource();", - }; - }); - - it("binds five event handlers", function() { - env.eventBindings.length.should.be.exactly(5); - }); - - describe("local-vars handler", function() { - beforeEach(() => { - env.eventBinding = env.eventBindings[0]; - }); - - it("binds to local-vars event", () => { - env.eventBinding.name.should.be.exactly("local-vars"); - }); - - describe("when no chunks are provided", () => { - beforeEach(() => { - const chunk = createMockChunk(); - env.source = env.eventBinding.handler.call(env.handlerContext, "moduleSource()", chunk); - }); - - it("returns the original source", () => { - env.source.should.be.exactly("moduleSource()"); - }); - }); - - describe("when chunks are provided", () => { - beforeEach(() => { - const chunk = createMockChunk([1, 2, 3], [ - "foo", - "bar", - "baz" - ]); - env.source = env.eventBinding.handler.call(env.handlerContext, "moduleSource()", chunk, "abc123"); - }); - - it("returns the original source with installed mapping", () => { - env.source.should.be.exactly(` -moduleSource() - -// object to store loaded chunks -// "1" means "already loaded" -var installedChunks = { -1: 1, -2: 1, -3: 1 -}; -`.trim()); - }); - }); - }); - - describe("require-ensure handler", () => { - beforeEach(() => { - env.eventBinding = env.eventBindings[1]; - }); - - it("binds to require-ensure event", () => { - env.eventBinding.name.should.be.exactly("require-ensure"); - }); - - describe("when called", () => { - beforeEach(() => { - const chunk = createMockChunk(); - env.source = env.eventBinding.handler.call(env.handlerContext, "moduleSource()", chunk, "abc123"); - }); - - it("creates import scripts call and promise resolve", () => { - env.source.should.be.exactly(` -return new Promise(function(resolve) { -// "1" is the signal for "already loaded" -if(!installedChunks[chunkId]) { -importScripts("asset-path" + abc123 + "" + abc123 + "" + chunkId + ""); -} -resolve(); -}); -`.trim()); - }); - }); - }); - - describe("bootstrap handler", () => { - beforeEach(() => { - env.eventBinding = env.eventBindings[2]; - }); - - it("binds to bootstrap event", () => { - env.eventBinding.name.should.be.exactly("bootstrap"); - }); - - describe("when no chunks are provided", () => { - beforeEach(() => { - const chunk = createMockChunk(); - env.source = env.eventBinding.handler.call(env.handlerContext, "moduleSource()", chunk); - }); - - it("returns the original source", () => { - env.source.should.be.exactly("moduleSource()"); - }); - }); - - describe("when chunks are provided", () => { - beforeEach(() => { - const chunk = createMockChunk([1, 2, 3], [ - "foo", - "bar", - "baz" - ]); - env.source = env.eventBinding.handler.call(env.handlerContext, "moduleSource()", chunk); - }); - - it("returns the original source with chunk callback", () => { - env.source.should.be.exactly(` -moduleSource() -this["webpackChunk"] = function webpackChunkCallback(chunkIds, moreModules) { -for(var moduleId in moreModules) { -renderAddModuleSource(); -} -while(chunkIds.length) -installedChunks[chunkIds.pop()] = 1; -}; -`.trim()); - }); - }); - }); - - describe("hot-bootstrap handler", () => { - beforeEach(() => { - env.eventBinding = env.eventBindings[3]; - }); - - it("binds to hot-bootstrap event", () => { - env.eventBinding.name.should.be.exactly("hot-bootstrap"); - }); - - describe("when called", () => { - beforeEach(() => { - const chunk = createMockChunk(); - env.source = env.eventBinding.handler.call(env.handlerContext, "moduleSource()", chunk, "abc123"); - }); - - it("returns the original source with hot update callback", () => { - env.source.should.be.exactly(` -moduleSource() -var parentHotUpdateCallback = this["webpackHotUpdate"]; -this["webpackHotUpdate"] = function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars - hotAddUpdateChunk(chunkId, moreModules); - if(parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules); -} ; - -function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars - importScripts(requireFn.p + "asset-path" + abc123 + "" + abc123 + "" + chunkId + ""); -} - -function hotDownloadManifest(requestTimeout) { // eslint-disable-line no-unused-vars - requestTimeout = requestTimeout || 10000; - return new Promise(function(resolve, reject) { - if(typeof XMLHttpRequest === "undefined") - return reject(new Error("No browser support")); - try { - var request = new XMLHttpRequest(); - var requestPath = requireFn.p + "asset-path" + abc123 + "" + abc123 + ""; - request.open("GET", requestPath, true); - request.timeout = requestTimeout; - request.send(null); - } catch(err) { - return reject(err); - } - request.onreadystatechange = function() { - if(request.readyState !== 4) return; - if(request.status === 0) { - // timeout - reject(new Error("Manifest request to " + requestPath + " timed out.")); - } else if(request.status === 404) { - // no update available - resolve(); - } else if(request.status !== 200 && request.status !== 304) { - // other failure - reject(new Error("Manifest request to " + requestPath + " failed.")); - } else { - // success - try { - var update = JSON.parse(request.responseText); - } catch(e) { - reject(e); - return; - } - resolve(update); - } - }; - }); -} - -function hotDisposeChunk(chunkId) { //eslint-disable-line no-unused-vars - delete installedChunks[chunkId]; -} -`.trim()); - }); - }); - }); - - describe("hash handler", () => { - beforeEach(() => { - env.eventBinding = env.eventBindings[4]; - env.handlerContext = { - outputOptions: { - publicPath: "Alpha", - filename: "Bravo", - chunkFilename: "Charlie", - chunkCallbackName: "Delta", - library: "Echo" - } - }; - env.hashMock = { - update: sinon.spy() - }; - env.eventBinding.handler.call(env.handlerContext, env.hashMock); - }); - - it("binds to hash event", () => { - env.eventBinding.name.should.be.exactly("hash"); - }); - - it("updates hash object", () => { - env.hashMock.update.callCount.should.be.exactly(7); - sinon.assert.calledWith(env.hashMock.update, "webworker"); - sinon.assert.calledWith(env.hashMock.update, "3"); - sinon.assert.calledWith(env.hashMock.update, "Alpha"); - sinon.assert.calledWith(env.hashMock.update, "Bravo"); - sinon.assert.calledWith(env.hashMock.update, "Charlie"); - sinon.assert.calledWith(env.hashMock.update, "Delta"); - sinon.assert.calledWith(env.hashMock.update, "Echo"); - }); - }); - }); -}); diff --git a/test/removeAndDo.unittest.js b/test/removeAndDo.unittest.js deleted file mode 100644 index e929b15cb..000000000 --- a/test/removeAndDo.unittest.js +++ /dev/null @@ -1,36 +0,0 @@ -/* globals describe, it, beforeEach */ -"use strict"; - -const should = require("should"); -const sinon = require("sinon"); -const removeAndDo = require("../lib/removeAndDo"); - -describe("removeAndDo", () => { - let actionSpy; - let thingsMock; - let contextMock; - let anotherThingsMock; - - beforeEach(() => { - actionSpy = sinon.spy(); - thingsMock = { - action: actionSpy - }; - anotherThingsMock = { - action: actionSpy - }; - contextMock = { - context: [thingsMock] - }; - }); - - it("should return true", () => { - should(removeAndDo.bind(contextMock)('context', thingsMock, 'action')).be.eql(true); - actionSpy.callCount.should.be.exactly(1); - }); - - it("should return false", () => { - should(removeAndDo.bind(contextMock)('context', anotherThingsMock, 'anotherAction')).be.eql(false); - actionSpy.callCount.should.be.exactly(0); - }); -}); From 75f68a2635bcd7456771cd50269c10a3b176c104 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 8 Nov 2017 20:49:41 +0100 Subject: [PATCH 18/85] fixes linting, remove not needed context arguments --- lib/BasicEvaluatedExpression.js | 2 +- lib/Compilation.js | 4 ++-- lib/ContextReplacementPlugin.js | 3 ++- lib/MultiCompiler.js | 2 +- lib/MultiModule.js | 2 +- lib/Parser.js | 12 ++++++------ lib/ProgressPlugin.js | 1 - lib/RuleSet.js | 1 - lib/TemplatedPathPlugin.js | 6 ++++-- 9 files changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/BasicEvaluatedExpression.js b/lib/BasicEvaluatedExpression.js index defa45605..01915597e 100644 --- a/lib/BasicEvaluatedExpression.js +++ b/lib/BasicEvaluatedExpression.js @@ -189,7 +189,7 @@ class BasicEvaluatedExpression { if(!this.options) this.options = []; options.forEach(item => { this.options.push(item); - }, this); + }); return this; } diff --git a/lib/Compilation.js b/lib/Compilation.js index 87d9832fb..f7b472662 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -119,8 +119,8 @@ class Compilation extends Tapable { cacheModule.disconnect(); this._modules.set(identifier, cacheModule); this.modules.push(cacheModule); - cacheModule.errors.forEach(err => this.errors.push(err), this); - cacheModule.warnings.forEach(err => this.warnings.push(err), this); + cacheModule.errors.forEach(err => this.errors.push(err)); + cacheModule.warnings.forEach(err => this.warnings.push(err)); return cacheModule; } module.unbuild(); diff --git a/lib/ContextReplacementPlugin.js b/lib/ContextReplacementPlugin.js index 5a1acee7d..761dd4dbf 100644 --- a/lib/ContextReplacementPlugin.js +++ b/lib/ContextReplacementPlugin.js @@ -97,7 +97,7 @@ class ContextReplacementPlugin { } const createResolveDependenciesFromContextMap = (createContextMap) => { - return (fs, options, callback) => { + const resolveDependenciesFromContextMap = (fs, options, callback) => { createContextMap(fs, (err, map) => { if(err) return callback(err); const dependencies = Object.keys(map).map((key) => { @@ -106,6 +106,7 @@ const createResolveDependenciesFromContextMap = (createContextMap) => { callback(null, dependencies); }); }; + return resolveDependenciesFromContextMap; }; module.exports = ContextReplacementPlugin; diff --git a/lib/MultiCompiler.js b/lib/MultiCompiler.js index e63bdb6be..653b0be72 100644 --- a/lib/MultiCompiler.js +++ b/lib/MultiCompiler.js @@ -40,7 +40,7 @@ module.exports = class MultiCompiler extends Tapable { } this.applyPlugins("invalid"); }); - }, this); + }); } get outputPath() { diff --git a/lib/MultiModule.js b/lib/MultiModule.js index dde3477e9..30a704d92 100644 --- a/lib/MultiModule.js +++ b/lib/MultiModule.js @@ -64,7 +64,7 @@ class MultiModule extends Module { str.push("); }())"); } str.push(";\n"); - }, this); + }); return new RawSource(str.join("")); } } diff --git a/lib/Parser.js b/lib/Parser.js index f4196d729..dfc8f31e5 100644 --- a/lib/Parser.js +++ b/lib/Parser.js @@ -460,8 +460,8 @@ class Parser extends Tapable { }); this.plugin("evaluate ArrayExpression", expr => { const items = expr.elements.map(element => { - return element !== null && this.evaluateExpression(element); - }, this); + return element !== null && this.evaluateExpression(element); + }); if(!items.every(Boolean)) return; return new BasicEvaluatedExpression().setItems(items).setRange(expr.range); }); @@ -724,7 +724,7 @@ class Parser extends Tapable { this.applyPluginsBailResult4("import specifier", statement, source, null, name); break; } - }, this); + }); } prewalkExportNamedDeclaration(statement) { @@ -1121,7 +1121,7 @@ class Parser extends Tapable { }; const params = functionExpression.params; const renameThis = currentThis ? renameArgOrThis.call(this, currentThis) : null; - const args = options.map(renameArgOrThis, this); + const args = options.map(renameArgOrThis); this.inScope(params.filter((identifier, idx) => !args[idx]), () => { if(renameThis) { this.scope.renames.set("this", renameThis); @@ -1355,7 +1355,7 @@ class Parser extends Tapable { if(expression.elements) expression.elements.forEach(expr => { arr.push(this.parseString(expr)); - }, this); + }); return arr; } @@ -1368,7 +1368,7 @@ class Parser extends Tapable { if(expression.elements) expression.elements.forEach(expr => { arr.push(this.parseCalculatedString(expr)); - }, this); + }); return arr; } diff --git a/lib/ProgressPlugin.js b/lib/ProgressPlugin.js index 2a6bff265..ec65e3448 100644 --- a/lib/ProgressPlugin.js +++ b/lib/ProgressPlugin.js @@ -67,7 +67,6 @@ const createDefaultHandler = profile => { }; - class ProgressPlugin { constructor(options) { diff --git a/lib/RuleSet.js b/lib/RuleSet.js index 20f60310c..7138435ec 100644 --- a/lib/RuleSet.js +++ b/lib/RuleSet.js @@ -147,7 +147,6 @@ module.exports = class RuleSet { resourceSource = newSource; }; - if(rule.test || rule.include || rule.exclude) { checkResourceSource("test + include + exclude"); condition = { diff --git a/lib/TemplatedPathPlugin.js b/lib/TemplatedPathPlugin.js index 918563619..645f220f0 100644 --- a/lib/TemplatedPathPlugin.js +++ b/lib/TemplatedPathPlugin.js @@ -19,7 +19,7 @@ const REGEXP_HASH_FOR_TEST = new RegExp(REGEXP_HASH.source, "i"), REGEXP_NAME_FOR_TEST = new RegExp(REGEXP_NAME.source, "i"); const withHashLength = (replacer, handlerFn) => { - return (match, hashLength, ...args) => { + const fn = (match, hashLength, ...args) => { const length = hashLength && parseInt(hashLength, 10); if(length && handlerFn) { return handlerFn(length); @@ -27,10 +27,11 @@ const withHashLength = (replacer, handlerFn) => { const hash = replacer(match, hashLength, ...args); return length ? hash.slice(0, length) : hash; }; + return fn; }; const getReplacer = (value, allowEmpty) => { - return (match, ...args) => { + const fn = (match, ...args) => { // last argument in replacer is the entire input string const input = args[args.length - 1]; if(value === null || value === undefined) { @@ -40,6 +41,7 @@ const getReplacer = (value, allowEmpty) => { return `${value}`; } }; + return fn; }; const replacePathVariables = (path, data) => { From 41a1d602e1e406a3132bd176d5fb3876ea0e6ec3 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 30 Oct 2017 13:56:57 +0100 Subject: [PATCH 19/85] added WebAssembly Proof of Concept --- examples/wasm-simple/README.md | 507 ++++++++++++++++++++ examples/wasm-simple/add.wasm | Bin 0 -> 41 bytes examples/wasm-simple/build.js | 1 + examples/wasm-simple/example.js | 26 + examples/wasm-simple/factorial.wasm | Bin 0 -> 83 bytes examples/wasm-simple/fibonacci.wasm | Bin 0 -> 95 bytes examples/wasm-simple/index.html | 5 + examples/wasm-simple/math.js | 15 + examples/wasm-simple/template.md | 47 ++ examples/wasm-simple/webpack.config.js | 14 + lib/Chunk.js | 35 +- lib/ChunkTemplate.js | 53 +- lib/Compilation.js | 81 ++-- lib/ContextModule.js | 2 +- lib/DelegatedModule.js | 2 +- lib/DllModule.js | 2 +- lib/ExternalModule.js | 2 +- lib/FetchCompileWasmMainTemplatePlugin.js | 87 ++++ lib/FetchCompileWasmModuleTemplatePlugin.js | 37 ++ lib/FetchCompileWasmTemplatePlugin.js | 19 + lib/FunctionModuleTemplatePlugin.js | 3 +- lib/HotUpdateChunkTemplate.js | 2 +- lib/JsonpMainTemplatePlugin.js | 56 ++- lib/MainTemplate.js | 42 +- lib/Module.js | 3 +- lib/ModuleTemplate.js | 3 + lib/MultiModule.js | 2 +- lib/NormalModule.js | 53 +- lib/NormalModuleFactory.js | 38 +- lib/RawModule.js | 2 +- lib/Template.js | 11 +- lib/TemplatedPathPlugin.js | 8 + lib/WebAssemblyParser.js | 25 + lib/WebpackOptionsApply.js | 3 + lib/WebpackOptionsDefaulter.js | 1 + lib/optimize/ConcatenatedModule.js | 2 +- schemas/webpackOptionsSchema.json | 13 + 37 files changed, 1092 insertions(+), 110 deletions(-) create mode 100644 examples/wasm-simple/README.md create mode 100644 examples/wasm-simple/add.wasm create mode 100644 examples/wasm-simple/build.js create mode 100644 examples/wasm-simple/example.js create mode 100644 examples/wasm-simple/factorial.wasm create mode 100644 examples/wasm-simple/fibonacci.wasm create mode 100644 examples/wasm-simple/index.html create mode 100644 examples/wasm-simple/math.js create mode 100644 examples/wasm-simple/template.md create mode 100644 examples/wasm-simple/webpack.config.js create mode 100644 lib/FetchCompileWasmMainTemplatePlugin.js create mode 100644 lib/FetchCompileWasmModuleTemplatePlugin.js create mode 100644 lib/FetchCompileWasmTemplatePlugin.js create mode 100644 lib/WebAssemblyParser.js diff --git a/examples/wasm-simple/README.md b/examples/wasm-simple/README.md new file mode 100644 index 000000000..6ef8e2b17 --- /dev/null +++ b/examples/wasm-simple/README.md @@ -0,0 +1,507 @@ +This very simple example shows usage of WebAssembly. + +WebAssembly modules can be imported like other modules. Their download and compilation happens in parallel to the download and evaluation of the javascript chunk. + +# example.js + +``` javascript +import("./add.wasm").then(addModule => { + console.log(addModule.add(22, 2200)); + import("./math").then(math => { + console.log(math.add(10, 101)); + console.log(math.factorial(15)); + console.log(math.factorialJavascript(15)); + console.log(math.fibonacci(15)); + console.log(math.fibonacciJavascript(15)); + timed("wasm factorial", () => math.factorial(1500)); + timed("js factorial", () => math.factorialJavascript(1500)); + timed("wasm fibonacci", () => math.fibonacci(22)); + timed("js fibonacci", () => math.fibonacciJavascript(22)); + }); +}); + +function timed(name, fn) { + if(!console.time || !console.timeEnd) + return fn(); + // warmup + for(var i = 0; i < 10; i++) + fn(); + console.time(name) + for(var i = 0; i < 5000; i++) + fn(); + console.timeEnd(name) +} +``` + +# math.js + +``` javascript +import { add } from "./add.wasm"; +import { factorial } from "./factorial.wasm"; +import { fibonacci } from "./fibonacci.wasm"; + +export { add, factorial, fibonacci }; + +export function factorialJavascript(i) { + if(i < 1) return 1; + return i * factorialJavascript(i - 1); +} + +export function fibonacciJavascript(i) { + if(i < 2) return 1; + return fibonacciJavascript(i - 1) + fibonacciJavascript(i - 2); +} +``` + +# js/output.js + +
/******/ (function(modules) { /* webpackBootstrap */ }) + +``` javascript +/******/ (function(modules) { // webpackBootstrap +/******/ // install a JSONP callback for chunk loading +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0], moreModules = data[1], executeModules = data[2]; +/******/ // add "moreModules" to the modules object, +/******/ // then flag all "chunkIds" as loaded and fire callback +/******/ var moduleId, chunkId, i = 0, resolves = [], result; +/******/ for(;i < chunkIds.length; i++) { +/******/ chunkId = chunkIds[i]; +/******/ if(installedChunks[chunkId]) { +/******/ resolves.push(installedChunks[chunkId][0]); +/******/ } +/******/ installedChunks[chunkId] = 0; +/******/ } +/******/ for(moduleId in moreModules) { +/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) { +/******/ modules[moduleId] = moreModules[moduleId]; +/******/ } +/******/ } +/******/ if(parentJsonpFunction) parentJsonpFunction(data); +/******/ while(resolves.length) { +/******/ resolves.shift()(); +/******/ } +/******/ +/******/ }; +/******/ +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // object to store loaded and loading chunks +/******/ var installedChunks = { +/******/ 2: 0 +/******/ }; +/******/ +/******/ var scheduledModules = []; +/******/ +/******/ // object to store loaded and loading wasm modules +/******/ var installedWasmModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ // This file contains only the entry chunk. +/******/ // The chunk loading function for additional chunks +/******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // JSONP chunk loading for javascript +/******/ +/******/ var installedChunkData = installedChunks[chunkId]; +/******/ if(installedChunkData !== 0) { // 0 means "already installed". +/******/ +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ installedChunkData[2] = promise; +/******/ }); +/******/ +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120000; +/******/ +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); +/******/ } +/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ function onScriptComplete(event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ head.appendChild(script); +/******/ promises.push(promise); +/******/ } +/******/ } +/******/ +/******/ // Fetch + compile chunk loading for webassembly +/******/ +/******/ var wasmModules = {"0":[1,3,4],"1":[1]}[chunkId] || []; +/******/ +/******/ wasmModules.forEach(function(wasmModuleId) { +/******/ var installedWasmModuleData = installedWasmModules[wasmModuleId]; +/******/ +/******/ // a Promise means "currently loading" or "already loaded". +/******/ if(installedWasmModuleData) { +/******/ promises.push(installedWasmModuleData); +/******/ } else { +/******/ var promise = installedWasmModules[wasmModuleId] = fetch(__webpack_require__.p + "" + {"1":"80925f35a6f1cf550d38","3":"419044e1f2fdca0c3e4a","4":"353120d3a2f1efbb00e2"}[wasmModuleId] + ".wasm") +/******/ .then(function(response) { return response.arrayBuffer(); }) +/******/ .then(function(bytes) { return WebAssembly.compile(bytes); }) +/******/ .then(function(module) { __webpack_require__.w[wasmModuleId] = module; }) +/******/ promises.push(promise); +/******/ } +/******/ }); +/******/ return Promise.all(promises); +/******/ }; +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = "js/"; +/******/ +/******/ // on error function for async loading +/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; +/******/ +/******/ // object with all compiled WebAssmbly.Modules +/******/ __webpack_require__.w = {}; +/******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var parentJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 0); +/******/ }) +/************************************************************************/ +``` + +
+ +``` javascript +/******/ ([ +/* 0 */ +/*!********************!*\ + !*** ./example.js ***! + \********************/ +/*! no static exports found */ +/*! all exports used */ +/***/ (function(module, exports, __webpack_require__) { + +__webpack_require__.e/* import() */(1).then(__webpack_require__.bind(null, /*! ./add.wasm */1)).then(addModule => { + console.log(addModule.add(22, 2200)); + __webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! ./math */2)).then(math => { + console.log(math.add(10, 101)); + console.log(math.factorial(15)); + console.log(math.factorialJavascript(15)); + console.log(math.fibonacci(15)); + console.log(math.fibonacciJavascript(15)); + timed("wasm factorial", () => math.factorial(1500)); + timed("js factorial", () => math.factorialJavascript(1500)); + timed("wasm fibonacci", () => math.fibonacci(22)); + timed("js fibonacci", () => math.fibonacciJavascript(22)); + }); +}); + +function timed(name, fn) { + if(!console.time || !console.timeEnd) + return fn(); + // warmup + for(var i = 0; i < 10; i++) + fn(); + console.time(name) + for(var i = 0; i < 5000; i++) + fn(); + console.timeEnd(name) +} + + +/***/ }) +/******/ ]); +``` + +# js/0.output.js + +``` javascript +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0,1],[ +/* 0 */, +/* 1 */ +/*!******************!*\ + !*** ./add.wasm ***! + \******************/ +/*! no static exports found */ +/*! all exports used */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Instanciate WebAssembly module +var instance = new WebAssembly.Instance(__webpack_require__.w[module.i], {}); + +// export exports from WebAssmbly module +module.exports = instance.exports; + +/***/ }), +/* 2 */ +/*!*****************!*\ + !*** ./math.js ***! + \*****************/ +/*! exports provided: add, factorial, fibonacci, factorialJavascript, fibonacciJavascript */ +/*! all exports used */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "factorialJavascript", function() { return factorialJavascript; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fibonacciJavascript", function() { return fibonacciJavascript; }); +/* harmony import */ var _add_wasm__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./add.wasm */1); +/* harmony import */ var _add_wasm__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_add_wasm__WEBPACK_IMPORTED_MODULE_0__); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "add", function() { return _add_wasm__WEBPACK_IMPORTED_MODULE_0__["add"]; }); + +/* harmony import */ var _factorial_wasm__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./factorial.wasm */3); +/* harmony import */ var _factorial_wasm__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_factorial_wasm__WEBPACK_IMPORTED_MODULE_1__); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "factorial", function() { return _factorial_wasm__WEBPACK_IMPORTED_MODULE_1__["factorial"]; }); + +/* harmony import */ var _fibonacci_wasm__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fibonacci.wasm */4); +/* harmony import */ var _fibonacci_wasm__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_fibonacci_wasm__WEBPACK_IMPORTED_MODULE_2__); +/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "fibonacci", function() { return _fibonacci_wasm__WEBPACK_IMPORTED_MODULE_2__["fibonacci"]; }); + + + + + + + +function factorialJavascript(i) { + if(i < 1) return 1; + return i * factorialJavascript(i - 1); +} + +function fibonacciJavascript(i) { + if(i < 2) return 1; + return fibonacciJavascript(i - 1) + fibonacciJavascript(i - 2); +} + + +/***/ }), +/* 3 */ +/*!************************!*\ + !*** ./factorial.wasm ***! + \************************/ +/*! no static exports found */ +/*! exports used: factorial */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Instanciate WebAssembly module +var instance = new WebAssembly.Instance(__webpack_require__.w[module.i], {}); + +// export exports from WebAssmbly module +module.exports = instance.exports; + +/***/ }), +/* 4 */ +/*!************************!*\ + !*** ./fibonacci.wasm ***! + \************************/ +/*! no static exports found */ +/*! exports used: fibonacci */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Instanciate WebAssembly module +var instance = new WebAssembly.Instance(__webpack_require__.w[module.i], {}); + +// export exports from WebAssmbly module +module.exports = instance.exports; + +/***/ }) +]]); +``` + +# js/1.output.js + +``` javascript +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],[ +/* 0 */, +/* 1 */ +/*!******************!*\ + !*** ./add.wasm ***! + \******************/ +/*! no static exports found */ +/*! all exports used */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + +// Instanciate WebAssembly module +var instance = new WebAssembly.Instance(__webpack_require__.w[module.i], {}); + +// export exports from WebAssmbly module +module.exports = instance.exports; + +/***/ }) +]]); +``` + +# Info + +## Uncompressed + +``` +Hash: 0878b6979a580265faba +Version: webpack 3.8.1 + Asset Size Chunks Chunk Names + 0.output.js 3.55 kB 0, 1 [emitted] +80925f35a6f1cf550d38.wasm 41 bytes 0, 1, 1 [emitted] +419044e1f2fdca0c3e4a.wasm 83 bytes 0, 1 [emitted] +353120d3a2f1efbb00e2.wasm 95 bytes 0, 1 [emitted] + 1.output.js 486 bytes 1 [emitted] + output.js 8.9 kB 2 [emitted] main +Entrypoint main = output.js +chunk {0} 0.output.js, 80925f35a6f1cf550d38.wasm, 419044e1f2fdca0c3e4a.wasm, 353120d3a2f1efbb00e2.wasm 634 bytes {2} [rendered] + > [0] ./example.js 3:1-17 + [1] ./add.wasm 41 bytes {0} {1} [built] + import() ./add.wasm [0] ./example.js 1:0-20 + harmony side effect evaluation ./add.wasm [2] ./math.js 1:0-33 + harmony export imported specifier ./add.wasm [2] ./math.js 5:0-37 + [2] ./math.js 415 bytes {0} [built] + [exports: add, factorial, fibonacci, factorialJavascript, fibonacciJavascript] + import() ./math [0] ./example.js 3:1-17 + [3] ./factorial.wasm 83 bytes {0} [built] + [only some exports used: factorial] + harmony side effect evaluation ./factorial.wasm [2] ./math.js 2:0-45 + harmony export imported specifier ./factorial.wasm [2] ./math.js 5:0-37 + [4] ./fibonacci.wasm 95 bytes {0} [built] + [only some exports used: fibonacci] + harmony side effect evaluation ./fibonacci.wasm [2] ./math.js 3:0-45 + harmony export imported specifier ./fibonacci.wasm [2] ./math.js 5:0-37 +chunk {1} 1.output.js, 80925f35a6f1cf550d38.wasm 41 bytes {2} [rendered] + > [0] ./example.js 1:0-20 + [1] ./add.wasm 41 bytes {0} {1} [built] + import() ./add.wasm [0] ./example.js 1:0-20 + harmony side effect evaluation ./add.wasm [2] ./math.js 1:0-33 + harmony export imported specifier ./add.wasm [2] ./math.js 5:0-37 +chunk {2} output.js (main) 788 bytes [entry] [rendered] + > main [0] ./example.js + [0] ./example.js 788 bytes {2} [built] +``` + +## Minimized (uglify-js, no zip) + +``` +Hash: 0878b6979a580265faba +Version: webpack 3.8.1 + Asset Size Chunks Chunk Names + 0.output.js 772 bytes 0, 1 [emitted] +80925f35a6f1cf550d38.wasm 41 bytes 0, 1, 1 [emitted] +419044e1f2fdca0c3e4a.wasm 83 bytes 0, 1 [emitted] +353120d3a2f1efbb00e2.wasm 95 bytes 0, 1 [emitted] + 1.output.js 155 bytes 1 [emitted] + output.js 8.74 kB 2 [emitted] main +Entrypoint main = output.js +chunk {0} 0.output.js, 80925f35a6f1cf550d38.wasm, 419044e1f2fdca0c3e4a.wasm, 353120d3a2f1efbb00e2.wasm 634 bytes {2} [rendered] + > [0] ./example.js 3:1-17 + [1] ./add.wasm 41 bytes {0} {1} [built] + import() ./add.wasm [0] ./example.js 1:0-20 + harmony side effect evaluation ./add.wasm [2] ./math.js 1:0-33 + harmony export imported specifier ./add.wasm [2] ./math.js 5:0-37 + [2] ./math.js 415 bytes {0} [built] + [exports: add, factorial, fibonacci, factorialJavascript, fibonacciJavascript] + import() ./math [0] ./example.js 3:1-17 + [3] ./factorial.wasm 83 bytes {0} [built] + [only some exports used: factorial] + harmony side effect evaluation ./factorial.wasm [2] ./math.js 2:0-45 + harmony export imported specifier ./factorial.wasm [2] ./math.js 5:0-37 + [4] ./fibonacci.wasm 95 bytes {0} [built] + [only some exports used: fibonacci] + harmony side effect evaluation ./fibonacci.wasm [2] ./math.js 3:0-45 + harmony export imported specifier ./fibonacci.wasm [2] ./math.js 5:0-37 +chunk {1} 1.output.js, 80925f35a6f1cf550d38.wasm 41 bytes {2} [rendered] + > [0] ./example.js 1:0-20 + [1] ./add.wasm 41 bytes {0} {1} [built] + import() ./add.wasm [0] ./example.js 1:0-20 + harmony side effect evaluation ./add.wasm [2] ./math.js 1:0-33 + harmony export imported specifier ./add.wasm [2] ./math.js 5:0-37 +chunk {2} output.js (main) 788 bytes [entry] [rendered] + > main [0] ./example.js + [0] ./example.js 788 bytes {2} [built] + +ERROR in output.js from UglifyJs +Unexpected token: operator (>) [output.js:194,95] +``` diff --git a/examples/wasm-simple/add.wasm b/examples/wasm-simple/add.wasm new file mode 100644 index 0000000000000000000000000000000000000000..357f72da7a0db8add83699082fd51d46bf3352fb GIT binary patch literal 41 wcmZQbEY4+QU|?WmXG~zKuV<`hW@2PuXJ=$iOi5v2;NoOtXHZ~JV9eqM0DJxgJ^%m! literal 0 HcmV?d00001 diff --git a/examples/wasm-simple/build.js b/examples/wasm-simple/build.js new file mode 100644 index 000000000..41c29c9d1 --- /dev/null +++ b/examples/wasm-simple/build.js @@ -0,0 +1 @@ +require("../build-common"); \ No newline at end of file diff --git a/examples/wasm-simple/example.js b/examples/wasm-simple/example.js new file mode 100644 index 000000000..25c1fd165 --- /dev/null +++ b/examples/wasm-simple/example.js @@ -0,0 +1,26 @@ +import("./add.wasm").then(addModule => { + console.log(addModule.add(22, 2200)); + import("./math").then(math => { + console.log(math.add(10, 101)); + console.log(math.factorial(15)); + console.log(math.factorialJavascript(15)); + console.log(math.fibonacci(15)); + console.log(math.fibonacciJavascript(15)); + timed("wasm factorial", () => math.factorial(1500)); + timed("js factorial", () => math.factorialJavascript(1500)); + timed("wasm fibonacci", () => math.fibonacci(22)); + timed("js fibonacci", () => math.fibonacciJavascript(22)); + }); +}); + +function timed(name, fn) { + if(!console.time || !console.timeEnd) + return fn(); + // warmup + for(var i = 0; i < 10; i++) + fn(); + console.time(name) + for(var i = 0; i < 5000; i++) + fn(); + console.timeEnd(name) +} diff --git a/examples/wasm-simple/factorial.wasm b/examples/wasm-simple/factorial.wasm new file mode 100644 index 0000000000000000000000000000000000000000..d5287c967a635d239e9e9124a2d68e204190e444 GIT binary patch literal 83 zcmZQbEY4+QU|?WmV@zPIVXR?hVq{?FW#mjtOfJbU%1q2*VBpeY)L~FyZ~>|Uf)Dn| SEH!X8s{*pjLIH+F+}r>=7!BZVBoT1v|vzRZ~>|U0f%Ik X8YugNJu6)NgZ)AQWK}@k0&Z>qy3`Ib literal 0 HcmV?d00001 diff --git a/examples/wasm-simple/index.html b/examples/wasm-simple/index.html new file mode 100644 index 000000000..22a4cefe0 --- /dev/null +++ b/examples/wasm-simple/index.html @@ -0,0 +1,5 @@ + + + + + diff --git a/examples/wasm-simple/math.js b/examples/wasm-simple/math.js new file mode 100644 index 000000000..761a57a47 --- /dev/null +++ b/examples/wasm-simple/math.js @@ -0,0 +1,15 @@ +import { add } from "./add.wasm"; +import { factorial } from "./factorial.wasm"; +import { fibonacci } from "./fibonacci.wasm"; + +export { add, factorial, fibonacci }; + +export function factorialJavascript(i) { + if(i < 1) return 1; + return i * factorialJavascript(i - 1); +} + +export function fibonacciJavascript(i) { + if(i < 2) return 1; + return fibonacciJavascript(i - 1) + fibonacciJavascript(i - 2); +} diff --git a/examples/wasm-simple/template.md b/examples/wasm-simple/template.md new file mode 100644 index 000000000..8fa9296c5 --- /dev/null +++ b/examples/wasm-simple/template.md @@ -0,0 +1,47 @@ +This very simple example shows usage of WebAssembly. + +WebAssembly modules can be imported like other modules. Their download and compilation happens in parallel to the download and evaluation of the javascript chunk. + +# example.js + +``` javascript +{{example.js}} +``` + +# math.js + +``` javascript +{{math.js}} +``` + +# js/output.js + +``` javascript +{{js/output.js}} +``` + +# js/0.output.js + +``` javascript +{{js/0.output.js}} +``` + +# js/1.output.js + +``` javascript +{{js/1.output.js}} +``` + +# Info + +## Uncompressed + +``` +{{stdout}} +``` + +## Minimized (uglify-js, no zip) + +``` +{{min:stdout}} +``` diff --git a/examples/wasm-simple/webpack.config.js b/examples/wasm-simple/webpack.config.js new file mode 100644 index 000000000..d2df12225 --- /dev/null +++ b/examples/wasm-simple/webpack.config.js @@ -0,0 +1,14 @@ +module.exports = { + output: { + webassemblyModuleFilename: "[modulehash].wasm", + publicPath: "js/" + }, + module: { + rules: [ + { + test: /\.wasm$/, + type: "webassembly/experimental" + } + ] + } +}; diff --git a/lib/Chunk.js b/lib/Chunk.js index 587bcb593..fdff57a65 100644 --- a/lib/Chunk.js +++ b/lib/Chunk.js @@ -490,7 +490,7 @@ class Chunk { hash.update(`${this.id} `); hash.update(this.ids ? this.ids.join(",") : ""); hash.update(`${this.name || ""} `); - this._modules.forEach(m => m.updateHash(hash)); + this._modules.forEach(m => hash.update(m.hash)); } canBeIntegrated(otherChunk) { @@ -538,12 +538,12 @@ class Chunk { } getChunkMaps(includeEntries, realHash) { - const chunksProcessed = []; - const chunkHashMap = {}; - const chunkNameMap = {}; + const chunksProcessed = new Set(); + const chunkHashMap = Object.create(null); + const chunkNameMap = Object.create(null); const addChunk = chunk => { - if(chunksProcessed.indexOf(chunk) >= 0) return; - chunksProcessed.push(chunk); + if(chunksProcessed.has(chunk)) return; + chunksProcessed.add(chunk); if(!chunk.hasRuntime() || includeEntries) { chunkHashMap[chunk.id] = realHash ? chunk.hash : chunk.renderedHash; if(chunk.name) @@ -558,6 +558,29 @@ class Chunk { }; } + getChunkModuleMaps(includeEntries, filterFn) { + const chunksProcessed = new Set(); + const chunkModuleIdMap = Object.create(null); + const chunkModuleHashMap = Object.create(null); + (function addChunk(chunk) { + if(chunksProcessed.has(chunk)) return; + chunksProcessed.add(chunk); + if(!chunk.hasRuntime() || includeEntries) { + const array = chunk.getModules().filter(filterFn); + if(array.length > 0) + chunkModuleIdMap[chunk.id] = array.map(m => m.id).sort(); + for(const m of array) { + chunkModuleHashMap[m.id] = m.renderedHash; + } + } + chunk._chunks.forEach(addChunk); + }(this)); + return { + id: chunkModuleIdMap, + hash: chunkModuleHashMap + }; + } + sortModules(sortByFn) { this._modules.sortWith(sortByFn || sortById); } diff --git a/lib/ChunkTemplate.js b/lib/ChunkTemplate.js index 319bd3db5..199eb46ff 100644 --- a/lib/ChunkTemplate.js +++ b/lib/ChunkTemplate.js @@ -12,8 +12,53 @@ module.exports = class ChunkTemplate extends Template { super(outputOptions); } - render(chunk, moduleTemplate, dependencyTemplates) { - const moduleSources = this.renderChunkModules(chunk, moduleTemplate, dependencyTemplates); + getRenderManifest(options) { + const chunk = options.chunk; + const outputOptions = options.outputOptions; + const moduleTemplates = options.moduleTemplates; + const dependencyTemplates = options.dependencyTemplates; + + const result = []; + + let filenameTemplate; + if(chunk.isInitial()) { + if(chunk.filenameTemplate) + filenameTemplate = chunk.filenameTemplate; + else + filenameTemplate = outputOptions.filename; + } else { + filenameTemplate = outputOptions.chunkFilename; + } + + result.push({ + render: () => this.renderJavascript(chunk, moduleTemplates.javascript, dependencyTemplates), + filenameTemplate, + pathOptions: { + chunk + }, + identifier: `chunk${chunk.id}`, + hash: chunk.hash + }); + + for(const module of chunk.modules.filter(m => m.type && m.type.startsWith("webassembly"))) { + const filenameTemplate = outputOptions.webassemblyModuleFilename; + + result.push({ + render: () => this.renderWebAssembly(module, moduleTemplates.webassembly, dependencyTemplates), + filenameTemplate, + pathOptions: { + module + }, + identifier: `webassemblyModule${module.id}`, + hash: module.hash + }); + } + + return result; + } + + renderJavascript(chunk, moduleTemplate, dependencyTemplates) { + const moduleSources = this.renderChunkModules(chunk, m => true, moduleTemplate, dependencyTemplates); const core = this.applyPluginsWaterfall("modules", moduleSources, chunk, moduleTemplate, dependencyTemplates); let source = this.applyPluginsWaterfall("render", core, chunk, moduleTemplate, dependencyTemplates); if(chunk.hasEntryModule()) { @@ -23,6 +68,10 @@ module.exports = class ChunkTemplate extends Template { return new ConcatSource(source, ";"); } + renderWebAssembly(module, moduleTemplate, dependencyTemplates) { + return moduleTemplate.render(module, dependencyTemplates); + } + updateHash(hash) { hash.update("ChunkTemplate"); hash.update("2"); diff --git a/lib/Compilation.js b/lib/Compilation.js index c487b4b73..c93789afb 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -70,7 +70,10 @@ class Compilation extends Tapable { this.mainTemplate = new MainTemplate(this.outputOptions); this.chunkTemplate = new ChunkTemplate(this.outputOptions); this.hotUpdateChunkTemplate = new HotUpdateChunkTemplate(this.outputOptions); - this.moduleTemplate = new ModuleTemplate(this.outputOptions); + this.moduleTemplates = { + javascript: new ModuleTemplate(this.outputOptions), + webassembly: new ModuleTemplate(this.outputOptions) + }; this.semaphore = new Semaphore(options.parallelism || 100); @@ -99,6 +102,15 @@ class Compilation extends Tapable { this._rebuildingModules = new Map(); } + // TODO add deprecation getter/setters + get moduleTemplate() { + return this.moduleTemplates.javascript; + } + + set moduleTemplate(value) { + this.moduleTemplate.javascript = value; + } + getStats() { return new Stats(this); } @@ -1346,6 +1358,14 @@ class Compilation extends Tapable { this.children.forEach(child => hash.update(child.hash)); this.warnings.forEach(warning => hash.update(`${warning.message}`)); this.errors.forEach(error => hash.update(`${error.message}`)); + const modules = this.modules; + for(let i = 0; i < modules.length; i++) { + const module = modules[i]; + const moduleHash = crypto.createHash(hashFunction); + module.updateHash(moduleHash); + module.hash = moduleHash.digest(hashDigest); + module.renderedHash = module.hash.substr(0, hashDigestLength); + } // clone needed as sort below is inplace mutation const chunks = this.chunks.slice(); /** @@ -1407,45 +1427,44 @@ class Compilation extends Tapable { createChunkAssets() { const outputOptions = this.outputOptions; - const filename = outputOptions.filename; - const chunkFilename = outputOptions.chunkFilename; for(let i = 0; i < this.chunks.length; i++) { const chunk = this.chunks[i]; chunk.files = []; - const chunkHash = chunk.hash; let source; let file; - const filenameTemplate = chunk.filenameTemplate ? chunk.filenameTemplate : - chunk.isInitial() ? filename : - chunkFilename; + let filenameTemplate; try { - const useChunkHash = !chunk.hasRuntime() || (this.mainTemplate.useChunkHash && this.mainTemplate.useChunkHash(chunk)); - const usedHash = useChunkHash ? chunkHash : this.fullHash; - const cacheName = "c" + chunk.id; - if(this.cache && this.cache[cacheName] && this.cache[cacheName].hash === usedHash) { - source = this.cache[cacheName].source; - } else { - if(chunk.hasRuntime()) { - source = this.mainTemplate.render(this.hash, chunk, this.moduleTemplate, this.dependencyTemplates); + const template = chunk.hasRuntime() ? this.mainTemplate : this.chunkTemplate; + const manifest = template.getRenderManifest({ + chunk, + hash: this.hash, + fullHash: this.fullHash, + outputOptions, + moduleTemplates: this.moduleTemplates, + dependencyTemplates: this.dependencyTemplates + }); // [{ render(), filenameTemplate, pathOptions, identifier, hash }] + for(const fileManifest of manifest) { + const cacheName = fileManifest.identifier; + const usedHash = fileManifest.hash; + filenameTemplate = fileManifest.filenameTemplate; + if(this.cache && this.cache[cacheName] && this.cache[cacheName].hash === usedHash) { + source = this.cache[cacheName].source; } else { - source = this.chunkTemplate.render(chunk, this.moduleTemplate, this.dependencyTemplates); - } - if(this.cache) { - this.cache[cacheName] = { - hash: usedHash, - source: source = (source instanceof CachedSource ? source : new CachedSource(source)) - }; + source = fileManifest.render(); + if(this.cache) { + this.cache[cacheName] = { + hash: usedHash, + source: source = (source instanceof CachedSource ? source : new CachedSource(source)) + }; + } } + file = this.getPath(filenameTemplate, fileManifest.pathOptions); + if(this.assets[file] && this.assets[file] !== source) + throw new Error(`Conflict: Multiple assets emit to the same filename ${file}`); + this.assets[file] = source; + chunk.files.push(file); + this.applyPlugins2("chunk-asset", chunk, file); } - file = this.getPath(filenameTemplate, { - noChunkHash: !useChunkHash, - chunk - }); - if(this.assets[file]) - throw new Error(`Conflict: Multiple assets emit to the same filename ${file}`); - this.assets[file] = source; - chunk.files.push(file); - this.applyPlugins2("chunk-asset", chunk, file); } catch(err) { this.errors.push(new ChunkRenderError(chunk, file || filenameTemplate, err)); } diff --git a/lib/ContextModule.js b/lib/ContextModule.js index d9e1d945d..52d05dfce 100644 --- a/lib/ContextModule.js +++ b/lib/ContextModule.js @@ -18,7 +18,7 @@ class ContextModule extends Module { // resolveDependencies: (fs: FS, options: ContextOptions, (err: Error?, dependencies: Dependency[]) => void) => void // options: ContextOptions constructor(resolveDependencies, options) { - super(); + super("javascript/dynamic"); // Info from Factory this.resolveDependencies = resolveDependencies; diff --git a/lib/DelegatedModule.js b/lib/DelegatedModule.js index 5490118e2..9c2753d8b 100644 --- a/lib/DelegatedModule.js +++ b/lib/DelegatedModule.js @@ -13,7 +13,7 @@ const DelegatedExportsDependency = require("./dependencies/DelegatedExportsDepen class DelegatedModule extends Module { constructor(sourceRequest, data, type, userRequest, originalRequest) { - super(); + super("javascript/dynamic"); // Info from Factory this.sourceRequest = sourceRequest; diff --git a/lib/DllModule.js b/lib/DllModule.js index 7c47ed057..835a6a6cd 100644 --- a/lib/DllModule.js +++ b/lib/DllModule.js @@ -9,7 +9,7 @@ const RawSource = require("webpack-sources").RawSource; class DllModule extends Module { constructor(context, dependencies, name, type) { - super(); + super("javascript/dynamic"); // Info from Factory this.context = context; diff --git a/lib/ExternalModule.js b/lib/ExternalModule.js index 6f85cdfee..480c18ac0 100644 --- a/lib/ExternalModule.js +++ b/lib/ExternalModule.js @@ -11,7 +11,7 @@ const Template = require("./Template"); class ExternalModule extends Module { constructor(request, type, userRequest) { - super(); + super("javascript/dynamic"); // Info from Factory this.request = request; diff --git a/lib/FetchCompileWasmMainTemplatePlugin.js b/lib/FetchCompileWasmMainTemplatePlugin.js new file mode 100644 index 000000000..504985192 --- /dev/null +++ b/lib/FetchCompileWasmMainTemplatePlugin.js @@ -0,0 +1,87 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +class FetchCompileWasmMainTemplatePlugin { + + apply(mainTemplate) { + mainTemplate.plugin("local-vars", function(source, chunk) { + return this.asString([ + source, + "", + "// object to store loaded and loading wasm modules", + "var installedWasmModules = {};", + ]); + }); + mainTemplate.plugin("require-ensure", function(source, chunk, hash) { + const webassemblyModuleFilename = this.outputOptions.webassemblyModuleFilename; + const chunkModuleMaps = chunk.getChunkModuleMaps(false, m => m.type.startsWith("webassembly")); + if(Object.keys(chunkModuleMaps.id).length === 0) return source; + const wasmModuleSrcPath = this.applyPluginsWaterfall("asset-path", JSON.stringify(webassemblyModuleFilename), { + hash: `" + ${this.renderCurrentHashCode(hash)} + "`, + hashWithLength: length => `" + ${this.renderCurrentHashCode(hash, length)} + "`, + module: { + id: "\" + wasmModuleId + \"", + hash: `" + ${JSON.stringify(chunkModuleMaps.hash)}[wasmModuleId] + "`, + hashWithLength(length) { + const shortChunkHashMap = Object.create(null); + Object.keys(chunkModuleMaps.hash).forEach(wasmModuleId => { + if(typeof chunkModuleMaps.hash[wasmModuleId] === "string") + shortChunkHashMap[wasmModuleId] = chunkModuleMaps.hash[wasmModuleId].substr(0, length); + }); + return `" + ${JSON.stringify(shortChunkHashMap)}[wasmModuleId] + "`; + } + } + }); + return this.asString([ + source, + "", + "// Fetch + compile chunk loading for webassembly", + "", + `var wasmModules = ${JSON.stringify(chunkModuleMaps.id)}[chunkId] || [];`, + "", + "wasmModules.forEach(function(wasmModuleId) {", + this.indent([ + "var installedWasmModuleData = installedWasmModules[wasmModuleId];", + "", + "// a Promise means \"currently loading\" or \"already loaded\".", + "if(installedWasmModuleData) {", + this.indent([ + "promises.push(installedWasmModuleData);" + ]), + "} else {", + this.indent([ + `var promise = installedWasmModules[wasmModuleId] = fetch(${this.requireFn}.p + ${wasmModuleSrcPath})`, + this.indent([ + ".then(function(response) { return response.arrayBuffer(); })", + ".then(function(bytes) { return WebAssembly.compile(bytes); })", + `.then(function(module) { ${this.requireFn}.w[wasmModuleId] = module; })` + ]), + "promises.push(promise);" + ]), + "}", + ]), + "});", + ]); + }); + mainTemplate.plugin("require-extensions", function(source, chunk) { + return this.asString([ + source, + "", + "// object with all compiled WebAssmbly.Modules", + `${this.requireFn}.w = {};` + ]); + }); + mainTemplate.plugin("hash", function(hash) { + hash.update("jsonp"); + hash.update("5"); + hash.update(`${this.outputOptions.filename}`); + hash.update(`${this.outputOptions.chunkFilename}`); + hash.update(`${this.outputOptions.jsonpFunction}`); + hash.update(`${this.outputOptions.hotUpdateFunction}`); + }); + } +} +module.exports = FetchCompileWasmMainTemplatePlugin; diff --git a/lib/FetchCompileWasmModuleTemplatePlugin.js b/lib/FetchCompileWasmModuleTemplatePlugin.js new file mode 100644 index 000000000..117e28e91 --- /dev/null +++ b/lib/FetchCompileWasmModuleTemplatePlugin.js @@ -0,0 +1,37 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const RawSource = require("webpack-sources").RawSource; + +class FetchCompileWasmModuleTemplatePlugin { + apply(moduleTemplate) { + moduleTemplate.plugin("module", function(moduleSource, module, chunk) { + if(module.type && module.type.startsWith("webassembly")) { + if(chunk.isInitial()) + throw new Error("Sync WebAsssmbly compilation is not yet implemented"); + const source = new RawSource([ + "\"use strict\";", + "", + "// Instanciate WebAssembly module", + "var instance = new WebAssembly.Instance(__webpack_require__.w[module.i], {});", + "", + "// export exports from WebAssmbly module", + // TODO rewrite this to getters depending on exports to support circular dependencies + "module.exports = instance.exports;" + ].join("\n")); + return source; + } else { + return moduleSource; + } + }); + + moduleTemplate.plugin("hash", function(hash) { + hash.update("FetchCompileWasmModuleTemplatePlugin"); + hash.update("1"); + }); + } +} +module.exports = FetchCompileWasmModuleTemplatePlugin; diff --git a/lib/FetchCompileWasmTemplatePlugin.js b/lib/FetchCompileWasmTemplatePlugin.js new file mode 100644 index 000000000..f01b7f13e --- /dev/null +++ b/lib/FetchCompileWasmTemplatePlugin.js @@ -0,0 +1,19 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const FetchCompileWasmMainTemplatePlugin = require("./FetchCompileWasmMainTemplatePlugin"); +const FetchCompileWasmModuleTemplatePlugin = require("./FetchCompileWasmModuleTemplatePlugin"); + +class FetchCompileWasmTemplatePlugin { + apply(compiler) { + compiler.plugin("this-compilation", (compilation) => { + compilation.mainTemplate.apply(new FetchCompileWasmMainTemplatePlugin()); + compilation.moduleTemplates.javascript.apply(new FetchCompileWasmModuleTemplatePlugin()); + }); + } +} + +module.exports = FetchCompileWasmTemplatePlugin; diff --git a/lib/FunctionModuleTemplatePlugin.js b/lib/FunctionModuleTemplatePlugin.js index b7f8949cd..a83be52e8 100644 --- a/lib/FunctionModuleTemplatePlugin.js +++ b/lib/FunctionModuleTemplatePlugin.js @@ -12,7 +12,8 @@ class FunctionModuleTemplatePlugin { moduleTemplate.plugin("render", (moduleSource, module) => { const source = new ConcatSource(); const defaultArguments = [module.moduleArgument || "module", module.exportsArgument || "exports"]; - if((module.arguments && module.arguments.length !== 0) || module.hasDependencies(d => d.requireWebpackRequire !== false)) { + // TODO remove HACK checking type for javascript + if(!module.type || !module.type.startsWith("javascript") || (module.arguments && module.arguments.length !== 0) || module.hasDependencies(d => d.requireWebpackRequire !== false)) { defaultArguments.push("__webpack_require__"); } source.add("/***/ (function(" + defaultArguments.concat(module.arguments || []).join(", ") + ") {\n\n"); diff --git a/lib/HotUpdateChunkTemplate.js b/lib/HotUpdateChunkTemplate.js index 84b366a08..e5af4b255 100644 --- a/lib/HotUpdateChunkTemplate.js +++ b/lib/HotUpdateChunkTemplate.js @@ -17,7 +17,7 @@ module.exports = class HotUpdateChunkTemplate extends Template { hotUpdateChunk.id = id; hotUpdateChunk.setModules(modules); hotUpdateChunk.removedModules = removedModules; - const modulesSource = this.renderChunkModules(hotUpdateChunk, moduleTemplate, dependencyTemplates); + const modulesSource = this.renderChunkModules(hotUpdateChunk, () => true, moduleTemplate, dependencyTemplates); const core = this.applyPluginsWaterfall("modules", modulesSource, modules, removedModules, moduleTemplate, dependencyTemplates); const source = this.applyPluginsWaterfall("render", core, modules, removedModules, hash, id, moduleTemplate, dependencyTemplates); return source; diff --git a/lib/JsonpMainTemplatePlugin.js b/lib/JsonpMainTemplatePlugin.js index e459d02b6..fdd77f4fe 100644 --- a/lib/JsonpMainTemplatePlugin.js +++ b/lib/JsonpMainTemplatePlugin.js @@ -19,7 +19,7 @@ class JsonpMainTemplatePlugin { return mainTemplate.asString([ source, "", - "// objects to store loaded and loading chunks", + "// object to store loaded and loading chunks", "var installedChunks = {", mainTemplate.indent( chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(",\n") @@ -93,36 +93,40 @@ class JsonpMainTemplatePlugin { "};", ]); }); - mainTemplate.plugin("require-ensure", (_, chunk, hash) => { + mainTemplate.plugin("require-ensure", (source, chunk, hash) => { return mainTemplate.asString([ + source, + "", + "// JSONP chunk loading for javascript", + "", "var installedChunkData = installedChunks[chunkId];", - "if(installedChunkData === 0) {", + "if(installedChunkData !== 0) { // 0 means \"already installed\".", mainTemplate.indent([ - "return new Promise(function(resolve) { resolve(); });" + "", + "// a Promise means \"currently loading\".", + "if(installedChunkData) {", + mainTemplate.indent([ + "promises.push(installedChunkData[2]);" + ]), + "} else {", + mainTemplate.indent([ + "// setup Promise in chunk cache", + "var promise = new Promise(function(resolve, reject) {", + mainTemplate.indent([ + "installedChunkData = installedChunks[chunkId] = [resolve, reject];" + ]), + "installedChunkData[2] = promise;", + "});", + "", + "// start chunk loading", + "var head = document.getElementsByTagName('head')[0];", + mainTemplate.applyPluginsWaterfall("jsonp-script", "", chunk, hash), + "head.appendChild(script);", + "promises.push(promise);" + ]), + "}", ]), "}", - "", - "// a Promise means \"currently loading\".", - "if(installedChunkData) {", - mainTemplate.indent([ - "return installedChunkData[2];" - ]), - "}", - "", - "// setup Promise in chunk cache", - "var promise = new Promise(function(resolve, reject) {", - mainTemplate.indent([ - "installedChunkData = installedChunks[chunkId] = [resolve, reject];" - ]), - "});", - "installedChunkData[2] = promise;", - "", - "// start chunk loading", - "var head = document.getElementsByTagName('head')[0];", - mainTemplate.applyPluginsWaterfall("jsonp-script", "", chunk, hash), - "head.appendChild(script);", - "", - "return promise;" ]); }); mainTemplate.plugin("require-extensions", (source, chunk) => { diff --git a/lib/MainTemplate.js b/lib/MainTemplate.js index c93422c50..534a972b3 100644 --- a/lib/MainTemplate.js +++ b/lib/MainTemplate.js @@ -20,6 +20,7 @@ const Template = require("./Template"); // __webpack_require__.o = Object.prototype.hasOwnProperty.call // __webpack_require__.n = compatibility get default export // __webpack_require__.h = the webpack hash +// __webpack_require__.w = an object containing all installed WebAssembly.Modules keys by module id // __webpack_require__.oe = the uncatched error handler for the webpack runtime // __webpack_require__.nc = the script nonce @@ -41,7 +42,7 @@ module.exports = class MainTemplate extends Template { source.add("/******/ })\n"); source.add("/************************************************************************/\n"); source.add("/******/ ("); - const modules = this.renderChunkModules(chunk, moduleTemplate, dependencyTemplates, "/******/ "); + const modules = this.renderChunkModules(chunk, () => true, moduleTemplate, dependencyTemplates, "/******/ "); source.add(this.applyPluginsWaterfall("modules", modules, chunk, hash, moduleTemplate, dependencyTemplates)); source.add(")"); return source; @@ -103,7 +104,9 @@ module.exports = class MainTemplate extends Template { buf.push("// This file contains only the entry chunk."); buf.push("// The chunk loading function for additional chunks"); buf.push(`${this.requireFn}.e = function requireEnsure(chunkId) {`); - buf.push(this.indent(this.applyPluginsWaterfall("require-ensure", "throw new Error('Not chunk loading available');", chunk, hash, "chunkId"))); + buf.push(this.indent("var promises = [];")); + buf.push(this.indent(this.applyPluginsWaterfall("require-ensure", "", chunk, hash, "chunkId"))); + buf.push(this.indent("return Promise.all(promises);")); buf.push("};"); } buf.push(""); @@ -162,6 +165,41 @@ module.exports = class MainTemplate extends Template { this.requireFn = "__webpack_require__"; } + getRenderManifest(options) { + const chunk = options.chunk; + const hash = options.hash; + const fullHash = options.fullHash; + const outputOptions = options.outputOptions; + const moduleTemplates = options.moduleTemplates; + const dependencyTemplates = options.dependencyTemplates; + + const result = []; + + let filenameTemplate; + if(chunk.filenameTemplate) + filenameTemplate = chunk.filenameTemplate; + else if(chunk.isInitial()) + filenameTemplate = outputOptions.filename; + else { + filenameTemplate = outputOptions.chunkFilename; + } + + const useChunkHash = this.useChunkHash(chunk); + + result.push({ + render: () => this.render(hash, chunk, moduleTemplates.javascript, dependencyTemplates), + filenameTemplate, + pathOptions: { + noChunkHash: !useChunkHash, + chunk + }, + identifier: `chunk${chunk.id}`, + hash: useChunkHash ? chunk.hash : fullHash + }); + + return result; + } + render(hash, chunk, moduleTemplate, dependencyTemplates) { const buf = []; buf.push(this.applyPluginsWaterfall("bootstrap", "", chunk, hash, moduleTemplate, dependencyTemplates)); diff --git a/lib/Module.js b/lib/Module.js index 55ac364ab..ccb8dd5b4 100644 --- a/lib/Module.js +++ b/lib/Module.js @@ -42,8 +42,9 @@ const getDebugIdent = set => { class Module extends DependenciesBlock { - constructor() { + constructor(type) { super(); + this.type = type; // Unique Id this.debugId = debugId++; diff --git a/lib/ModuleTemplate.js b/lib/ModuleTemplate.js index 2ac21d078..633bbd5f1 100644 --- a/lib/ModuleTemplate.js +++ b/lib/ModuleTemplate.js @@ -10,12 +10,15 @@ module.exports = class ModuleTemplate extends Template { constructor(outputOptions) { super(outputOptions); } + + // TODO move chunk into extra options object, it's not available i. e. in wasm modules render(module, dependencyTemplates, chunk) { const moduleSource = module.source(dependencyTemplates, this.outputOptions, this.requestShortener); const moduleSourcePostModule = this.applyPluginsWaterfall("module", moduleSource, module, chunk, dependencyTemplates); const moduleSourcePostRender = this.applyPluginsWaterfall("render", moduleSourcePostModule, module, chunk, dependencyTemplates); return this.applyPluginsWaterfall("package", moduleSourcePostRender, module, chunk, dependencyTemplates); } + updateHash(hash) { hash.update("1"); this.applyPlugins("hash", hash); diff --git a/lib/MultiModule.js b/lib/MultiModule.js index 30a704d92..e2dd7455d 100644 --- a/lib/MultiModule.js +++ b/lib/MultiModule.js @@ -11,7 +11,7 @@ const RawSource = require("webpack-sources").RawSource; class MultiModule extends Module { constructor(context, dependencies, name) { - super(); + super("javascript/dynamic"); // Info from Factory this.context = context; diff --git a/lib/NormalModule.js b/lib/NormalModule.js index e0f9a2001..092169d55 100644 --- a/lib/NormalModule.js +++ b/lib/NormalModule.js @@ -32,6 +32,13 @@ const asString = (buf) => { return buf; }; +const asBuffer = str => { + if(!Buffer.isBuffer(str)) { + return new Buffer(str, "utf-8"); // eslint-disable-line + } + return str; +}; + const contextify = (context, request) => { return request.split("!").map(r => { const splitPath = r.split("?"); @@ -59,13 +66,14 @@ const dependencyTemplatesHashMap = new WeakMap(); class NormalModule extends Module { - constructor(request, userRequest, rawRequest, loaders, resource, parser) { - super(); + constructor(type, request, userRequest, rawRequest, loaders, resource, parser) { + super(type); // Info from Factory this.request = request; this.userRequest = userRequest; this.rawRequest = rawRequest; + this.binary = type.startsWith("webassembly"); this.parser = parser; this.resource = resource; this.context = getContext(resource); @@ -177,6 +185,10 @@ class NormalModule extends Module { return new SourceMapSource(source, identifier, sourceMap); } + if(Buffer.isBuffer(source)) { + return new RawSource(source); + } + return new OriginalSource(source, identifier); } @@ -211,7 +223,7 @@ class NormalModule extends Module { return callback(error); } - this._source = this.createSource(asString(source), resourceBuffer, sourceMap); + this._source = this.createSource(this.binary ? asBuffer(source) : asString(source), resourceBuffer, sourceMap); this._ast = typeof extraInfo === "object" && extraInfo !== null && extraInfo.webpackAST !== undefined ? extraInfo.webpackAST : null; return callback(); }); @@ -473,23 +485,26 @@ class NormalModule extends Module { } source(dependencyTemplates, outputOptions, requestShortener) { - const hashDigest = this.getHashDigest(dependencyTemplates); - if(this._cachedSource && this._cachedSource.hash === hashDigest) { - return this._cachedSource.source; + if(this.type.startsWith("javascript")) { + const hashDigest = this.getHashDigest(dependencyTemplates); + if(this._cachedSource && this._cachedSource.hash === hashDigest) { + return this._cachedSource.source; + } + + if(!this._source) { + return new RawSource("throw new Error('No source available');"); + } + + const source = new ReplaceSource(this._source); + this._cachedSource = { + source: source, + hash: hashDigest + }; + + this.sourceBlock(this, [], dependencyTemplates, source, outputOptions, requestShortener); + return new CachedSource(source); } - - if(!this._source) { - return new RawSource("throw new Error('No source available');"); - } - - const source = new ReplaceSource(this._source); - this._cachedSource = { - source: source, - hash: hashDigest - }; - - this.sourceBlock(this, [], dependencyTemplates, source, outputOptions, requestShortener); - return new CachedSource(source); + return this._source; } originalSource() { diff --git a/lib/NormalModuleFactory.js b/lib/NormalModuleFactory.js index dab9c8b01..9b3941c00 100644 --- a/lib/NormalModuleFactory.js +++ b/lib/NormalModuleFactory.js @@ -9,6 +9,7 @@ const Tapable = require("tapable"); const NormalModule = require("./NormalModule"); const RawModule = require("./RawModule"); const Parser = require("./Parser"); +const WebAssemblyParser = require("./WebAssemblyParser"); const RuleSet = require("./RuleSet"); const loaderToIdent = data => { @@ -80,6 +81,7 @@ class NormalModuleFactory extends Tapable { } createdModule = new NormalModule( + result.type, result.request, result.userRequest, result.rawRequest, @@ -191,6 +193,7 @@ class NormalModuleFactory extends Tapable { if(err) return callback(err); loaders = results[0].concat(loaders, results[1], results[2]); process.nextTick(() => { + const type = settings.type || "javascript/auto"; callback(null, { context: context, request: loaders.map(loaderToIdent).concat([resource]).join("!"), @@ -200,7 +203,8 @@ class NormalModuleFactory extends Tapable { loaders, resource, resourceResolveData, - parser: this.getParser(settings.parser) + type, + parser: this.getParser(type, settings.parser) }); }); }); @@ -268,23 +272,39 @@ class NormalModuleFactory extends Tapable { }, callback); } - getParser(parserOptions) { - let ident = "null"; + getParser(type, parserOptions) { + let ident = type; if(parserOptions) { if(parserOptions.ident) - ident = parserOptions.ident; + ident = `${type}|${parserOptions.ident}`; else - ident = JSON.stringify(parserOptions); + ident = JSON.stringify([type, parserOptions]); } const parser = this.parserCache[ident]; if(parser) return parser; - return this.parserCache[ident] = this.createParser(parserOptions); + return this.parserCache[ident] = this.createParser(type, parserOptions); } - createParser(parserOptions) { - const parser = new Parser(); - this.applyPlugins2("parser", parser, parserOptions || {}); + createParser(type, parserOptions) { + // TODO move to plugin + // const parser = this.applyPluginsBailResult1(`create-parser ${type}`); + let parser; + switch(type) { + case "javascript/auto": + parser = new Parser(); + break; + case "webassembly/experimental": + parser = new WebAssemblyParser(); + break; + default: + throw new Error("Unknown module type"); + } + if(type === "javascript/auto") { + // TODO: remove backward compat in webpack 5 + this.applyPlugins2("parser", parser, parserOptions || {}); + } + this.applyPlugins2(`parser ${type}`, parser, parserOptions || {}); return parser; } } diff --git a/lib/RawModule.js b/lib/RawModule.js index 5e78aebc7..0eceaca70 100644 --- a/lib/RawModule.js +++ b/lib/RawModule.js @@ -11,7 +11,7 @@ const RawSource = require("webpack-sources").RawSource; module.exports = class RawModule extends Module { constructor(source, identifier, readableIdentifier) { - super(); + super("javascript/dynamic"); this.sourceStr = source; this.identifierStr = identifier || this.sourceStr; this.readableIdentifierStr = readableIdentifier || this.identifierStr; diff --git a/lib/Template.js b/lib/Template.js index 78a85543f..759530882 100644 --- a/lib/Template.js +++ b/lib/Template.js @@ -126,15 +126,16 @@ module.exports = class Template extends Tapable { return arrayOverhead < objectOverhead ? [minId, maxId] : false; } - renderChunkModules(chunk, moduleTemplate, dependencyTemplates, prefix) { + renderChunkModules(chunk, filterFn, moduleTemplate, dependencyTemplates, prefix) { if(!prefix) prefix = ""; var source = new ConcatSource(); - if(chunk.getNumberOfModules() === 0) { + const modules = chunk.getModules().filter(filterFn); + var removedModules = chunk.removedModules; + if(modules.length === 0 && removedModules.length === 0) { source.add("[]"); return source; } - var removedModules = chunk.removedModules; - var allModules = chunk.mapModules(module => { + var allModules = modules.map(module => { return { id: module.id, source: moduleTemplate.render(module, dependencyTemplates, chunk) @@ -156,7 +157,7 @@ module.exports = class Template extends Tapable { var maxId = bounds[1]; if(minId !== 0) source.add("Array(" + minId + ").concat("); source.add("[\n"); - var modules = {}; + const modules = {}; allModules.forEach(module => { modules[module.id] = module; }); diff --git a/lib/TemplatedPathPlugin.js b/lib/TemplatedPathPlugin.js index 645f220f0..ab4e196d7 100644 --- a/lib/TemplatedPathPlugin.js +++ b/lib/TemplatedPathPlugin.js @@ -6,8 +6,10 @@ const REGEXP_HASH = /\[hash(?::(\d+))?\]/gi, REGEXP_CHUNKHASH = /\[chunkhash(?::(\d+))?\]/gi, + REGEXP_MODULEHASH = /\[modulehash(?::(\d+))?\]/gi, REGEXP_NAME = /\[name\]/gi, REGEXP_ID = /\[id\]/gi, + REGEXP_MODULEID = /\[moduleid\]/gi, REGEXP_FILE = /\[file\]/gi, REGEXP_QUERY = /\[query\]/gi, REGEXP_FILEBASE = /\[filebase\]/gi; @@ -50,6 +52,10 @@ const replacePathVariables = (path, data) => { const chunkName = chunk && (chunk.name || chunk.id); const chunkHash = chunk && (chunk.renderedHash || chunk.hash); const chunkHashWithLength = chunk && chunk.hashWithLength; + const module = data.module; + const moduleId = module && module.id; + const moduleHash = module && (module.renderedHash || module.hash); + const moduleHashWithLength = module && module.hashWithLength; if(data.noChunkHash && REGEXP_CHUNKHASH_FOR_TEST.test(path)) { throw new Error(`Cannot use [chunkhash] for chunk in '${path}' (use [hash] instead)`); @@ -58,7 +64,9 @@ const replacePathVariables = (path, data) => { return path .replace(REGEXP_HASH, withHashLength(getReplacer(data.hash), data.hashWithLength)) .replace(REGEXP_CHUNKHASH, withHashLength(getReplacer(chunkHash), chunkHashWithLength)) + .replace(REGEXP_MODULEHASH, withHashLength(getReplacer(moduleHash), moduleHashWithLength)) .replace(REGEXP_ID, getReplacer(chunkId)) + .replace(REGEXP_MODULEID, getReplacer(moduleId)) .replace(REGEXP_NAME, getReplacer(chunkName)) .replace(REGEXP_FILE, getReplacer(data.filename)) .replace(REGEXP_FILEBASE, getReplacer(data.basename)) diff --git a/lib/WebAssemblyParser.js b/lib/WebAssemblyParser.js new file mode 100644 index 000000000..b4aafa291 --- /dev/null +++ b/lib/WebAssemblyParser.js @@ -0,0 +1,25 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +// Syntax: https://developer.mozilla.org/en/SpiderMonkey/Parser_API + +const Tapable = require("tapable"); + +class WebAssemblyParser extends Tapable { + constructor(options) { + super(); + this.options = options; + } + + parse(source, initialState) { + // Does nothing current + // TODO parse WASM AST and walk it + // extract exports, imports + return initialState; + } +} + +module.exports = WebAssemblyParser; diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js index a4487fdce..955a6cd96 100644 --- a/lib/WebpackOptionsApply.js +++ b/lib/WebpackOptionsApply.js @@ -62,6 +62,7 @@ class WebpackOptionsApply extends OptionsApply { compiler.dependencies = options.dependencies; if(typeof options.target === "string") { let JsonpTemplatePlugin; + let FetchCompileWasmTemplatePlugin; let NodeSourcePlugin; let NodeTargetPlugin; let NodeTemplatePlugin; @@ -69,9 +70,11 @@ class WebpackOptionsApply extends OptionsApply { switch(options.target) { case "web": JsonpTemplatePlugin = require("./JsonpTemplatePlugin"); + FetchCompileWasmTemplatePlugin = require("./FetchCompileWasmTemplatePlugin"); NodeSourcePlugin = require("./node/NodeSourcePlugin"); compiler.apply( new JsonpTemplatePlugin(options.output), + new FetchCompileWasmTemplatePlugin(options.output), new FunctionModulePlugin(options.output), new NodeSourcePlugin(options.node), new LoaderTargetPlugin(options.target) diff --git a/lib/WebpackOptionsDefaulter.js b/lib/WebpackOptionsDefaulter.js index ff0cc8072..eb03e859a 100644 --- a/lib/WebpackOptionsDefaulter.js +++ b/lib/WebpackOptionsDefaulter.js @@ -48,6 +48,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter { const filename = options.output.filename; return filename.indexOf("[name]") >= 0 ? filename.replace("[name]", "[id]") : "[id]." + filename; }); + this.set("output.webassemblyModuleFilename", "[modulehash].module.wasm"); this.set("output.library", ""); this.set("output.hotUpdateFunction", "make", (options) => { return Template.toIdentifier("webpackHotUpdate" + options.output.library); diff --git a/lib/optimize/ConcatenatedModule.js b/lib/optimize/ConcatenatedModule.js index 4780c94f4..9a0dc0111 100644 --- a/lib/optimize/ConcatenatedModule.js +++ b/lib/optimize/ConcatenatedModule.js @@ -159,7 +159,7 @@ const getPathInAst = (ast, node) => { class ConcatenatedModule extends Module { constructor(rootModule, modules) { - super(); + super("javascript/esm"); super.setChunks(rootModule._chunks); // Info from Factory diff --git a/schemas/webpackOptionsSchema.json b/schemas/webpackOptionsSchema.json index 3529d15d3..9c5b855c7 100644 --- a/schemas/webpackOptionsSchema.json +++ b/schemas/webpackOptionsSchema.json @@ -260,6 +260,11 @@ "type": "string", "absolutePath": false }, + "webassemblyModuleFilename": { + "description": "The filename of WebAssembly modules as relative path inside the `output.path` directory.", + "type": "string", + "absolutePath": false + }, "crossOriginLoading": { "description": "This option enables cross-origin loading of chunks.", "enum": [ @@ -653,6 +658,14 @@ "query": { "$ref": "#/definitions/ruleSet-query" }, + "type": { + "enum": [ + "javascript/auto", + "javascript/dynamic", + "javascript/esm", + "webassembly/experimental" + ] + }, "resource": { "allOf": [ { From cce42f51cf4939fa4715c56251befd632b64c139 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 30 Oct 2017 14:25:51 +0100 Subject: [PATCH 20/85] use i32 instead of f64 in wasm code --- examples/wasm-simple/README.md | 26 +++++++++++++------------- examples/wasm-simple/factorial.wasm | Bin 83 -> 62 bytes examples/wasm-simple/fibonacci.wasm | Bin 95 -> 67 bytes 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/examples/wasm-simple/README.md b/examples/wasm-simple/README.md index 6ef8e2b17..2d29c76b5 100644 --- a/examples/wasm-simple/README.md +++ b/examples/wasm-simple/README.md @@ -189,7 +189,7 @@ export function fibonacciJavascript(i) { /******/ if(installedWasmModuleData) { /******/ promises.push(installedWasmModuleData); /******/ } else { -/******/ var promise = installedWasmModules[wasmModuleId] = fetch(__webpack_require__.p + "" + {"1":"80925f35a6f1cf550d38","3":"419044e1f2fdca0c3e4a","4":"353120d3a2f1efbb00e2"}[wasmModuleId] + ".wasm") +/******/ var promise = installedWasmModules[wasmModuleId] = fetch(__webpack_require__.p + "" + {"1":"80925f35a6f1cf550d38","3":"3d28950d91bc7246f5af","4":"1d2268b99656e9575a63"}[wasmModuleId] + ".wasm") /******/ .then(function(response) { return response.arrayBuffer(); }) /******/ .then(function(bytes) { return WebAssembly.compile(bytes); }) /******/ .then(function(module) { __webpack_require__.w[wasmModuleId] = module; }) @@ -424,17 +424,17 @@ module.exports = instance.exports; ## Uncompressed ``` -Hash: 0878b6979a580265faba +Hash: efc3a9f7c544870296dd Version: webpack 3.8.1 Asset Size Chunks Chunk Names 0.output.js 3.55 kB 0, 1 [emitted] 80925f35a6f1cf550d38.wasm 41 bytes 0, 1, 1 [emitted] -419044e1f2fdca0c3e4a.wasm 83 bytes 0, 1 [emitted] -353120d3a2f1efbb00e2.wasm 95 bytes 0, 1 [emitted] +3d28950d91bc7246f5af.wasm 62 bytes 0, 1 [emitted] +1d2268b99656e9575a63.wasm 67 bytes 0, 1 [emitted] 1.output.js 486 bytes 1 [emitted] output.js 8.9 kB 2 [emitted] main Entrypoint main = output.js -chunk {0} 0.output.js, 80925f35a6f1cf550d38.wasm, 419044e1f2fdca0c3e4a.wasm, 353120d3a2f1efbb00e2.wasm 634 bytes {2} [rendered] +chunk {0} 0.output.js, 80925f35a6f1cf550d38.wasm, 3d28950d91bc7246f5af.wasm, 1d2268b99656e9575a63.wasm 585 bytes {2} [rendered] > [0] ./example.js 3:1-17 [1] ./add.wasm 41 bytes {0} {1} [built] import() ./add.wasm [0] ./example.js 1:0-20 @@ -443,11 +443,11 @@ chunk {0} 0.output.js, 80925f35a6f1cf550d38.wasm, 419044e1f2fdca0c3e4a.wasm, [2] ./math.js 415 bytes {0} [built] [exports: add, factorial, fibonacci, factorialJavascript, fibonacciJavascript] import() ./math [0] ./example.js 3:1-17 - [3] ./factorial.wasm 83 bytes {0} [built] + [3] ./factorial.wasm 62 bytes {0} [built] [only some exports used: factorial] harmony side effect evaluation ./factorial.wasm [2] ./math.js 2:0-45 harmony export imported specifier ./factorial.wasm [2] ./math.js 5:0-37 - [4] ./fibonacci.wasm 95 bytes {0} [built] + [4] ./fibonacci.wasm 67 bytes {0} [built] [only some exports used: fibonacci] harmony side effect evaluation ./fibonacci.wasm [2] ./math.js 3:0-45 harmony export imported specifier ./fibonacci.wasm [2] ./math.js 5:0-37 @@ -465,17 +465,17 @@ chunk {2} output.js (main) 788 bytes [entry] [rendered] ## Minimized (uglify-js, no zip) ``` -Hash: 0878b6979a580265faba +Hash: efc3a9f7c544870296dd Version: webpack 3.8.1 Asset Size Chunks Chunk Names 0.output.js 772 bytes 0, 1 [emitted] 80925f35a6f1cf550d38.wasm 41 bytes 0, 1, 1 [emitted] -419044e1f2fdca0c3e4a.wasm 83 bytes 0, 1 [emitted] -353120d3a2f1efbb00e2.wasm 95 bytes 0, 1 [emitted] +3d28950d91bc7246f5af.wasm 62 bytes 0, 1 [emitted] +1d2268b99656e9575a63.wasm 67 bytes 0, 1 [emitted] 1.output.js 155 bytes 1 [emitted] output.js 8.74 kB 2 [emitted] main Entrypoint main = output.js -chunk {0} 0.output.js, 80925f35a6f1cf550d38.wasm, 419044e1f2fdca0c3e4a.wasm, 353120d3a2f1efbb00e2.wasm 634 bytes {2} [rendered] +chunk {0} 0.output.js, 80925f35a6f1cf550d38.wasm, 3d28950d91bc7246f5af.wasm, 1d2268b99656e9575a63.wasm 585 bytes {2} [rendered] > [0] ./example.js 3:1-17 [1] ./add.wasm 41 bytes {0} {1} [built] import() ./add.wasm [0] ./example.js 1:0-20 @@ -484,11 +484,11 @@ chunk {0} 0.output.js, 80925f35a6f1cf550d38.wasm, 419044e1f2fdca0c3e4a.wasm, [2] ./math.js 415 bytes {0} [built] [exports: add, factorial, fibonacci, factorialJavascript, fibonacciJavascript] import() ./math [0] ./example.js 3:1-17 - [3] ./factorial.wasm 83 bytes {0} [built] + [3] ./factorial.wasm 62 bytes {0} [built] [only some exports used: factorial] harmony side effect evaluation ./factorial.wasm [2] ./math.js 2:0-45 harmony export imported specifier ./factorial.wasm [2] ./math.js 5:0-37 - [4] ./fibonacci.wasm 95 bytes {0} [built] + [4] ./fibonacci.wasm 67 bytes {0} [built] [only some exports used: fibonacci] harmony side effect evaluation ./fibonacci.wasm [2] ./math.js 3:0-45 harmony export imported specifier ./fibonacci.wasm [2] ./math.js 5:0-37 diff --git a/examples/wasm-simple/factorial.wasm b/examples/wasm-simple/factorial.wasm index d5287c967a635d239e9e9124a2d68e204190e444..0e0d759df538e2bcaa8f8f5e9c382243782ab098 100644 GIT binary patch delta 49 zcmWHx6JSUz&Shj^U|?ipOkk{Mte+?#A|=Tv&Y-~H$mqdR@5soi0A^ZVBoT1v|vzRZ~>|U0f%Ik X8YugNJu6)NgZ)AQWK}@k0&Z>qy3`Ib From 9c7f53e63cf1698a9cb1b20dd75237326bc7111e Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 3 Nov 2017 09:44:43 +0100 Subject: [PATCH 21/85] add support for compileStreaming --- examples/wasm-simple/README.md | 24 ++++++++++++----------- lib/FetchCompileWasmMainTemplatePlugin.js | 24 ++++++++++++----------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/examples/wasm-simple/README.md b/examples/wasm-simple/README.md index 2d29c76b5..8721303d1 100644 --- a/examples/wasm-simple/README.md +++ b/examples/wasm-simple/README.md @@ -186,15 +186,15 @@ export function fibonacciJavascript(i) { /******/ var installedWasmModuleData = installedWasmModules[wasmModuleId]; /******/ /******/ // a Promise means "currently loading" or "already loaded". -/******/ if(installedWasmModuleData) { -/******/ promises.push(installedWasmModuleData); -/******/ } else { -/******/ var promise = installedWasmModules[wasmModuleId] = fetch(__webpack_require__.p + "" + {"1":"80925f35a6f1cf550d38","3":"3d28950d91bc7246f5af","4":"1d2268b99656e9575a63"}[wasmModuleId] + ".wasm") -/******/ .then(function(response) { return response.arrayBuffer(); }) -/******/ .then(function(bytes) { return WebAssembly.compile(bytes); }) -/******/ .then(function(module) { __webpack_require__.w[wasmModuleId] = module; }) -/******/ promises.push(promise); -/******/ } +/******/ promises.push(installedWasmModuleData || +/******/ promises.push(installedWasmModules[wasmModuleId] = fetch(__webpack_require__.p + "" + {"1":"80925f35a6f1cf550d38","3":"3d28950d91bc7246f5af","4":"1d2268b99656e9575a63"}[wasmModuleId] + ".wasm").then(function(response) { +/******/ if(WebAssembly.compileStreaming) { +/******/ return WebAssembly.compileStreaming(response); +/******/ } else { +/******/ return response.arrayBuffer().then(function(bytes) { return WebAssembly.compile(bytes); }); +/******/ } +/******/ }).then(function(module) { __webpack_require__.w[wasmModuleId] = module; })) +/******/ ); /******/ }); /******/ return Promise.all(promises); /******/ }; @@ -432,7 +432,7 @@ Version: webpack 3.8.1 3d28950d91bc7246f5af.wasm 62 bytes 0, 1 [emitted] 1d2268b99656e9575a63.wasm 67 bytes 0, 1 [emitted] 1.output.js 486 bytes 1 [emitted] - output.js 8.9 kB 2 [emitted] main + output.js 8.94 kB 2 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js, 80925f35a6f1cf550d38.wasm, 3d28950d91bc7246f5af.wasm, 1d2268b99656e9575a63.wasm 585 bytes {2} [rendered] > [0] ./example.js 3:1-17 @@ -460,6 +460,7 @@ chunk {1} 1.output.js, 80925f35a6f1cf550d38.wasm 41 bytes {2} [rendered] chunk {2} output.js (main) 788 bytes [entry] [rendered] > main [0] ./example.js [0] ./example.js 788 bytes {2} [built] + single entry .\example.js main ``` ## Minimized (uglify-js, no zip) @@ -473,7 +474,7 @@ Version: webpack 3.8.1 3d28950d91bc7246f5af.wasm 62 bytes 0, 1 [emitted] 1d2268b99656e9575a63.wasm 67 bytes 0, 1 [emitted] 1.output.js 155 bytes 1 [emitted] - output.js 8.74 kB 2 [emitted] main + output.js 8.78 kB 2 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js, 80925f35a6f1cf550d38.wasm, 3d28950d91bc7246f5af.wasm, 1d2268b99656e9575a63.wasm 585 bytes {2} [rendered] > [0] ./example.js 3:1-17 @@ -501,6 +502,7 @@ chunk {1} 1.output.js, 80925f35a6f1cf550d38.wasm 41 bytes {2} [rendered] chunk {2} output.js (main) 788 bytes [entry] [rendered] > main [0] ./example.js [0] ./example.js 788 bytes {2} [built] + single entry .\example.js main ERROR in output.js from UglifyJs Unexpected token: operator (>) [output.js:194,95] diff --git a/lib/FetchCompileWasmMainTemplatePlugin.js b/lib/FetchCompileWasmMainTemplatePlugin.js index 504985192..8219d9708 100644 --- a/lib/FetchCompileWasmMainTemplatePlugin.js +++ b/lib/FetchCompileWasmMainTemplatePlugin.js @@ -47,21 +47,23 @@ class FetchCompileWasmMainTemplatePlugin { "var installedWasmModuleData = installedWasmModules[wasmModuleId];", "", "// a Promise means \"currently loading\" or \"already loaded\".", - "if(installedWasmModuleData) {", + "promises.push(installedWasmModuleData ||", this.indent([ - "promises.push(installedWasmModuleData);" - ]), - "} else {", - this.indent([ - `var promise = installedWasmModules[wasmModuleId] = fetch(${this.requireFn}.p + ${wasmModuleSrcPath})`, + `promises.push(installedWasmModules[wasmModuleId] = fetch(${this.requireFn}.p + ${wasmModuleSrcPath}).then(function(response) {`, this.indent([ - ".then(function(response) { return response.arrayBuffer(); })", - ".then(function(bytes) { return WebAssembly.compile(bytes); })", - `.then(function(module) { ${this.requireFn}.w[wasmModuleId] = module; })` + "if(WebAssembly.compileStreaming) {", + this.indent([ + "return WebAssembly.compileStreaming(response);" + ]), + "} else {", + this.indent([ + "return response.arrayBuffer().then(function(bytes) { return WebAssembly.compile(bytes); });", + ]), + "}" ]), - "promises.push(promise);" + `}).then(function(module) { ${this.requireFn}.w[wasmModuleId] = module; }))` ]), - "}", + ");", ]), "});", ]); From f13109108266e8ec43778a1ea5ead658bea704e9 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 10 Nov 2017 11:01:51 +0100 Subject: [PATCH 22/85] change ModuleTemplate.render argument to options object --- lib/ChunkTemplate.js | 2 +- lib/FetchCompileWasmModuleTemplatePlugin.js | 2 +- lib/ModuleTemplate.js | 9 ++++----- lib/Template.js | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/ChunkTemplate.js b/lib/ChunkTemplate.js index 199eb46ff..5c93d82a3 100644 --- a/lib/ChunkTemplate.js +++ b/lib/ChunkTemplate.js @@ -69,7 +69,7 @@ module.exports = class ChunkTemplate extends Template { } renderWebAssembly(module, moduleTemplate, dependencyTemplates) { - return moduleTemplate.render(module, dependencyTemplates); + return moduleTemplate.render(module, dependencyTemplates, {}); } updateHash(hash) { diff --git a/lib/FetchCompileWasmModuleTemplatePlugin.js b/lib/FetchCompileWasmModuleTemplatePlugin.js index 117e28e91..10d2436b9 100644 --- a/lib/FetchCompileWasmModuleTemplatePlugin.js +++ b/lib/FetchCompileWasmModuleTemplatePlugin.js @@ -8,7 +8,7 @@ const RawSource = require("webpack-sources").RawSource; class FetchCompileWasmModuleTemplatePlugin { apply(moduleTemplate) { - moduleTemplate.plugin("module", function(moduleSource, module, chunk) { + moduleTemplate.plugin("module", function(moduleSource, module, { chunk }) { if(module.type && module.type.startsWith("webassembly")) { if(chunk.isInitial()) throw new Error("Sync WebAsssmbly compilation is not yet implemented"); diff --git a/lib/ModuleTemplate.js b/lib/ModuleTemplate.js index 633bbd5f1..63370d856 100644 --- a/lib/ModuleTemplate.js +++ b/lib/ModuleTemplate.js @@ -11,12 +11,11 @@ module.exports = class ModuleTemplate extends Template { super(outputOptions); } - // TODO move chunk into extra options object, it's not available i. e. in wasm modules - render(module, dependencyTemplates, chunk) { + render(module, dependencyTemplates, options) { const moduleSource = module.source(dependencyTemplates, this.outputOptions, this.requestShortener); - const moduleSourcePostModule = this.applyPluginsWaterfall("module", moduleSource, module, chunk, dependencyTemplates); - const moduleSourcePostRender = this.applyPluginsWaterfall("render", moduleSourcePostModule, module, chunk, dependencyTemplates); - return this.applyPluginsWaterfall("package", moduleSourcePostRender, module, chunk, dependencyTemplates); + const moduleSourcePostModule = this.applyPluginsWaterfall("module", moduleSource, module, options, dependencyTemplates); + const moduleSourcePostRender = this.applyPluginsWaterfall("render", moduleSourcePostModule, module, options, dependencyTemplates); + return this.applyPluginsWaterfall("package", moduleSourcePostRender, module, options, dependencyTemplates); } updateHash(hash) { diff --git a/lib/Template.js b/lib/Template.js index 759530882..27a696920 100644 --- a/lib/Template.js +++ b/lib/Template.js @@ -138,7 +138,7 @@ module.exports = class Template extends Tapable { var allModules = modules.map(module => { return { id: module.id, - source: moduleTemplate.render(module, dependencyTemplates, chunk) + source: moduleTemplate.render(module, dependencyTemplates, { chunk }) }; }); if(removedModules && removedModules.length > 0) { From 0ae5fede3dc0175356b659189e348a80ea261c82 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 10 Nov 2017 11:02:24 +0100 Subject: [PATCH 23/85] move parser creation into separate plugins --- lib/JavascriptModulesPlugin.js | 19 +++++++++++++++++++ lib/NormalModuleFactory.js | 22 ++++++---------------- lib/WebAssemblyModulesPlugin.js | 19 +++++++++++++++++++ lib/WebpackOptionsApply.js | 7 +++++++ 4 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 lib/JavascriptModulesPlugin.js create mode 100644 lib/WebAssemblyModulesPlugin.js diff --git a/lib/JavascriptModulesPlugin.js b/lib/JavascriptModulesPlugin.js new file mode 100644 index 000000000..992c5d71a --- /dev/null +++ b/lib/JavascriptModulesPlugin.js @@ -0,0 +1,19 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const Parser = require("./Parser"); + +class JavascriptModulesPlugin { + apply(compiler) { + compiler.plugin("compilation", (compilation, { normalModuleFactory }) => { + normalModuleFactory.plugin(["create-parser javascript/auto", "create-parser javascript/esm"], () => { + return new Parser(); + }); + }); + } +} + +module.exports = JavascriptModulesPlugin; diff --git a/lib/NormalModuleFactory.js b/lib/NormalModuleFactory.js index 9b3941c00..ceead2f65 100644 --- a/lib/NormalModuleFactory.js +++ b/lib/NormalModuleFactory.js @@ -8,8 +8,6 @@ const asyncLib = require("async"); const Tapable = require("tapable"); const NormalModule = require("./NormalModule"); const RawModule = require("./RawModule"); -const Parser = require("./Parser"); -const WebAssemblyParser = require("./WebAssemblyParser"); const RuleSet = require("./RuleSet"); const loaderToIdent = data => { @@ -287,24 +285,16 @@ class NormalModuleFactory extends Tapable { } createParser(type, parserOptions) { - // TODO move to plugin - // const parser = this.applyPluginsBailResult1(`create-parser ${type}`); - let parser; - switch(type) { - case "javascript/auto": - parser = new Parser(); - break; - case "webassembly/experimental": - parser = new WebAssemblyParser(); - break; - default: - throw new Error("Unknown module type"); + parserOptions = parserOptions || {}; + const parser = this.applyPluginsBailResult1(`create-parser ${type}`, parserOptions); + if(!parser) { + throw new Error(`No parser registered for ${type}`); } if(type === "javascript/auto") { // TODO: remove backward compat in webpack 5 - this.applyPlugins2("parser", parser, parserOptions || {}); + this.applyPlugins2("parser", parser, parserOptions); } - this.applyPlugins2(`parser ${type}`, parser, parserOptions || {}); + this.applyPlugins2(`parser ${type}`, parser, parserOptions); return parser; } } diff --git a/lib/WebAssemblyModulesPlugin.js b/lib/WebAssemblyModulesPlugin.js new file mode 100644 index 000000000..131819ace --- /dev/null +++ b/lib/WebAssemblyModulesPlugin.js @@ -0,0 +1,19 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const WebAssemblyParser = require("./WebAssemblyParser"); + +class WebAssemblyModulesPlugin { + apply(compiler) { + compiler.plugin("compilation", (compilation, { normalModuleFactory }) => { + normalModuleFactory.plugin("create-parser webassembly/experimental", () => { + return new WebAssemblyParser(); + }); + }); + } +} + +module.exports = WebAssemblyModulesPlugin; diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js index 955a6cd96..1eedf112c 100644 --- a/lib/WebpackOptionsApply.js +++ b/lib/WebpackOptionsApply.js @@ -6,6 +6,9 @@ const OptionsApply = require("./OptionsApply"); +const JavascriptModulesPlugin = require("./JavascriptModulesPlugin"); +const WebAssemblyModulesPlugin = require("./WebAssemblyModulesPlugin"); + const LoaderTargetPlugin = require("./LoaderTargetPlugin"); const FunctionModulePlugin = require("./FunctionModulePlugin"); const EvalDevToolModulePlugin = require("./EvalDevToolModulePlugin"); @@ -234,6 +237,10 @@ class WebpackOptionsApply extends OptionsApply { null; compiler.apply(new EvalDevToolModulePlugin(comment, options.output.devtoolModuleFilenameTemplate)); } + compiler.apply( + new JavascriptModulesPlugin(), + new WebAssemblyModulesPlugin() + ); compiler.apply(new EntryOptionPlugin()); compiler.applyPluginsBailResult("entry-option", options.context, options.entry); From 9b9b6eafe0acdbaea26fdf81cd03c8a197372bdd Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 10 Nov 2017 11:02:45 +0100 Subject: [PATCH 24/85] add deprecation message to Compilation.moduleTemplate --- lib/Compilation.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/Compilation.js b/lib/Compilation.js index c93789afb..03c16803b 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -6,6 +6,7 @@ const asyncLib = require("async"); const crypto = require("crypto"); +const util = require("util"); const Tapable = require("tapable"); const EntryModuleNotFoundError = require("./EntryModuleNotFoundError"); const ModuleNotFoundError = require("./ModuleNotFoundError"); @@ -102,15 +103,6 @@ class Compilation extends Tapable { this._rebuildingModules = new Map(); } - // TODO add deprecation getter/setters - get moduleTemplate() { - return this.moduleTemplates.javascript; - } - - set moduleTemplate(value) { - this.moduleTemplate.javascript = value; - } - getStats() { return new Stats(this); } @@ -1505,4 +1497,14 @@ class Compilation extends Tapable { } } +Object.defineProperty(Compilation.prototype, "moduleTemplate", { + configurable: false, + get: util.deprecate(function() { + return this.moduleTemplates.javascript; + }, "Compilation.moduleTemplate: Use Compilation.moduleTemplates.javascript instead"), + set: util.deprecate(function(value) { + this.moduleTemplate.javascript = value; + }, "Compilation.moduleTemplate: Use Compilation.moduleTemplates.javascript instead.") +}); + module.exports = Compilation; From d67e5b00f2d0c2a9c339efcce18ec01f9e4771bd Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 10 Nov 2017 11:33:36 +0100 Subject: [PATCH 25/85] check of no removedModules --- lib/Template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Template.js b/lib/Template.js index 27a696920..43b1a59b9 100644 --- a/lib/Template.js +++ b/lib/Template.js @@ -131,7 +131,7 @@ module.exports = class Template extends Tapable { var source = new ConcatSource(); const modules = chunk.getModules().filter(filterFn); var removedModules = chunk.removedModules; - if(modules.length === 0 && removedModules.length === 0) { + if(modules.length === 0 && (!removedModules || removedModules.length === 0)) { source.add("[]"); return source; } From 77bd911b2d2de57201af3bfe509dd67273bb046f Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 10 Nov 2017 11:51:29 +0100 Subject: [PATCH 26/85] fix conflict with type in ExternalModule --- lib/ExternalModule.js | 10 +++++----- lib/UmdMainTemplatePlugin.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/ExternalModule.js b/lib/ExternalModule.js index 480c18ac0..24d102ea8 100644 --- a/lib/ExternalModule.js +++ b/lib/ExternalModule.js @@ -15,7 +15,7 @@ class ExternalModule extends Module { // Info from Factory this.request = request; - this.type = type; + this.externalType = type; this.userRequest = userRequest; this.external = true; } @@ -82,12 +82,12 @@ class ExternalModule extends Module { } getSourceString() { - const request = typeof this.request === "object" ? this.request[this.type] : this.request; - switch(this.type) { + const request = typeof this.request === "object" ? this.request[this.externalType] : this.request; + switch(this.externalType) { case "this": case "window": case "global": - return this.getSourceForGlobalVariableExternal(request, this.type); + return this.getSourceForGlobalVariableExternal(request, this.externalType); case "commonjs": case "commonjs2": return this.getSourceForCommonJsExternal(request); @@ -119,7 +119,7 @@ class ExternalModule extends Module { } updateHash(hash) { - hash.update(this.type); + hash.update(this.externalType); hash.update(JSON.stringify(this.request)); hash.update(JSON.stringify(Boolean(this.optional))); super.updateHash(hash); diff --git a/lib/UmdMainTemplatePlugin.js b/lib/UmdMainTemplatePlugin.js index b108a5467..2e634a956 100644 --- a/lib/UmdMainTemplatePlugin.js +++ b/lib/UmdMainTemplatePlugin.js @@ -42,7 +42,7 @@ class UmdMainTemplatePlugin { apply(compilation) { const mainTemplate = compilation.mainTemplate; compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => { - let externals = chunk.getModules().filter(m => m.external && (m.type === "umd" || m.type === "umd2")); + let externals = chunk.getModules().filter(m => m.external && (m.externalType === "umd" || m.externalType === "umd2")); const optionalExternals = []; let requiredExternals = []; if(this.optionalAmdExternalAsGlobal) { From c34d627fb76cb110f1c5668c210ddcdfd45e1819 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 10 Nov 2017 11:55:01 +0100 Subject: [PATCH 27/85] update stats for changed sizes --- .../aggressive-splitting-entry/expected.txt | 72 +++++++-------- .../expected.txt | 57 ++++++------ test/statsCases/chunks/expected.txt | 4 +- test/statsCases/color-disabled/expected.txt | 4 +- .../color-enabled-custom/expected.txt | 4 +- test/statsCases/color-enabled/expected.txt | 4 +- .../commons-chunk-min-size-0/expected.txt | 4 +- .../expected.txt | 6 +- .../expected.txt | 10 +-- .../commons-plugin-issue-4980/expected.txt | 14 +-- test/statsCases/define-plugin/expected.txt | 10 +-- .../exclude-with-loader/expected.txt | 4 +- test/statsCases/external/expected.txt | 4 +- test/statsCases/filter-warnings/expected.txt | 87 ++++++++++--------- .../import-context-filter/expected.txt | 4 +- test/statsCases/import-weak/expected.txt | 4 +- .../limit-chunk-count-plugin/expected.txt | 20 ++--- .../max-modules-default/expected.txt | 6 +- test/statsCases/max-modules/expected.txt | 6 +- .../module-deduplication-named/expected.txt | 6 +- .../module-deduplication/expected.txt | 6 +- .../expected.txt | 2 +- .../expected.txt | 2 +- .../named-chunks-plugin-async/expected.txt | 4 +- .../named-chunks-plugin/expected.txt | 4 +- test/statsCases/optimize-chunks/expected.txt | 4 +- test/statsCases/parse-error/expected.txt | 2 +- .../expected.txt | 2 +- test/statsCases/preset-detailed/expected.txt | 4 +- test/statsCases/preset-normal/expected.txt | 4 +- test/statsCases/preset-verbose/expected.txt | 4 +- .../resolve-plugin-context/expected.txt | 6 +- .../reverse-sort-modules/expected.txt | 6 +- .../scope-hoisting-multi/expected.txt | 6 +- .../separate-css-bundle/expected.txt | 10 +-- test/statsCases/simple-more-info/expected.txt | 4 +- test/statsCases/simple/expected.txt | 4 +- test/statsCases/tree-shaking/expected.txt | 4 +- .../statsCases/warnings-uglifyjs/expected.txt | 6 +- 39 files changed, 209 insertions(+), 205 deletions(-) diff --git a/test/statsCases/aggressive-splitting-entry/expected.txt b/test/statsCases/aggressive-splitting-entry/expected.txt index 0bebbc828..c6ba28e26 100644 --- a/test/statsCases/aggressive-splitting-entry/expected.txt +++ b/test/statsCases/aggressive-splitting-entry/expected.txt @@ -1,51 +1,51 @@ -Hash: c55fcf171c46cbd1e5a1939ef65085fe14a681ab +Hash: 33cef25044998703062e33cef25044998703062e Child fitting: - Hash: c55fcf171c46cbd1e5a1 + Hash: 33cef25044998703062e Time: Xms Asset Size Chunks Chunk Names - 9748a8a04a5102209105.js 2.29 kB 1 [emitted] - 79e8b67b4f31cdb0299f.js 1.99 kB 2 [emitted] - 628e75ea29b4a779b369.js 1.03 kB 3 [emitted] - dd43a4ed55c20668ec9b.js 5.72 kB 444 [emitted] - Entrypoint main = dd43a4ed55c20668ec9b.js 79e8b67b4f31cdb0299f.js 628e75ea29b4a779b369.js 9748a8a04a5102209105.js - chunk {1} 9748a8a04a5102209105.js 1.91 kB [initial] [rendered] - > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js - [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js 112 bytes {1} [built] - [6] (webpack)/test/statsCases/aggressive-splitting-entry/f.js 899 bytes {1} [built] - [7] (webpack)/test/statsCases/aggressive-splitting-entry/g.js 899 bytes {1} [built] - chunk {2} 79e8b67b4f31cdb0299f.js 1.8 kB [initial] [rendered] [recorded] - > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js - [2] (webpack)/test/statsCases/aggressive-splitting-entry/d.js 899 bytes {2} [built] - [5] (webpack)/test/statsCases/aggressive-splitting-entry/a.js 899 bytes {2} [built] - chunk {3} 628e75ea29b4a779b369.js 899 bytes [initial] [rendered] - > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js - [3] (webpack)/test/statsCases/aggressive-splitting-entry/e.js 899 bytes {3} [built] - chunk {444} dd43a4ed55c20668ec9b.js 1.8 kB [entry] [rendered] - > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js - [0] (webpack)/test/statsCases/aggressive-splitting-entry/b.js 899 bytes {444} [built] - [1] (webpack)/test/statsCases/aggressive-splitting-entry/c.js 899 bytes {444} [built] -Child content-change: - Hash: 939ef65085fe14a681ab - Time: Xms - Asset Size Chunks Chunk Names - 20c5ea99991f201dd831.js 2.29 kB 0 [emitted] - f4d1e8f97994a643b1c9.js 1.98 kB 4 [emitted] - 8cd5c0e735c517a0371e.js 5.72 kB 5 [emitted] - ec77f695b8be7fca93f2.js 1.03 kB 6 [emitted] - Entrypoint main = 8cd5c0e735c517a0371e.js ec77f695b8be7fca93f2.js f4d1e8f97994a643b1c9.js 20c5ea99991f201dd831.js - chunk {0} 20c5ea99991f201dd831.js 1.91 kB [initial] [rendered] + 3b0abf784cffee9cdb84.js 2.29 kB 0 [emitted] + fd43aeccca69e5179cb6.js 1.98 kB 4 [emitted] + 37a2e572a7162ac860f9.js 5.94 kB 5 [emitted] + e1f8db72211be4caf41d.js 1.03 kB 6 [emitted] + Entrypoint main = 37a2e572a7162ac860f9.js e1f8db72211be4caf41d.js fd43aeccca69e5179cb6.js 3b0abf784cffee9cdb84.js + chunk {0} 3b0abf784cffee9cdb84.js 1.91 kB [initial] [rendered] > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js 112 bytes {0} [built] [6] (webpack)/test/statsCases/aggressive-splitting-entry/f.js 899 bytes {0} [built] [7] (webpack)/test/statsCases/aggressive-splitting-entry/g.js 899 bytes {0} [built] - chunk {4} f4d1e8f97994a643b1c9.js 1.8 kB [initial] [rendered] [recorded] + chunk {4} fd43aeccca69e5179cb6.js 1.8 kB [initial] [rendered] [recorded] > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [0] (webpack)/test/statsCases/aggressive-splitting-entry/b.js 899 bytes {4} [built] [1] (webpack)/test/statsCases/aggressive-splitting-entry/c.js 899 bytes {4} [built] - chunk {5} 8cd5c0e735c517a0371e.js 1.8 kB [entry] [rendered] [recorded] + chunk {5} 37a2e572a7162ac860f9.js 1.8 kB [entry] [rendered] [recorded] > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [2] (webpack)/test/statsCases/aggressive-splitting-entry/d.js 899 bytes {5} [built] [5] (webpack)/test/statsCases/aggressive-splitting-entry/a.js 899 bytes {5} [built] - chunk {6} ec77f695b8be7fca93f2.js 899 bytes [initial] [rendered] + chunk {6} e1f8db72211be4caf41d.js 899 bytes [initial] [rendered] + > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js + [3] (webpack)/test/statsCases/aggressive-splitting-entry/e.js 899 bytes {6} [built] +Child content-change: + Hash: 33cef25044998703062e + Time: Xms + Asset Size Chunks Chunk Names + 3b0abf784cffee9cdb84.js 2.29 kB 0 [emitted] + fd43aeccca69e5179cb6.js 1.98 kB 4 [emitted] + 37a2e572a7162ac860f9.js 5.94 kB 5 [emitted] + e1f8db72211be4caf41d.js 1.03 kB 6 [emitted] + Entrypoint main = 37a2e572a7162ac860f9.js e1f8db72211be4caf41d.js fd43aeccca69e5179cb6.js 3b0abf784cffee9cdb84.js + chunk {0} 3b0abf784cffee9cdb84.js 1.91 kB [initial] [rendered] + > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js + [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js 112 bytes {0} [built] + [6] (webpack)/test/statsCases/aggressive-splitting-entry/f.js 899 bytes {0} [built] + [7] (webpack)/test/statsCases/aggressive-splitting-entry/g.js 899 bytes {0} [built] + chunk {4} fd43aeccca69e5179cb6.js 1.8 kB [initial] [rendered] [recorded] + > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js + [0] (webpack)/test/statsCases/aggressive-splitting-entry/b.js 899 bytes {4} [built] + [1] (webpack)/test/statsCases/aggressive-splitting-entry/c.js 899 bytes {4} [built] + chunk {5} 37a2e572a7162ac860f9.js 1.8 kB [entry] [rendered] [recorded] + > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js + [2] (webpack)/test/statsCases/aggressive-splitting-entry/d.js 899 bytes {5} [built] + [5] (webpack)/test/statsCases/aggressive-splitting-entry/a.js 899 bytes {5} [built] + chunk {6} e1f8db72211be4caf41d.js 899 bytes [initial] [rendered] > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [3] (webpack)/test/statsCases/aggressive-splitting-entry/e.js 899 bytes {6} [built] \ No newline at end of file diff --git a/test/statsCases/aggressive-splitting-on-demand/expected.txt b/test/statsCases/aggressive-splitting-on-demand/expected.txt index 3f1f9166e..a9f9ce5d4 100644 --- a/test/statsCases/aggressive-splitting-on-demand/expected.txt +++ b/test/statsCases/aggressive-splitting-on-demand/expected.txt @@ -1,52 +1,49 @@ -Hash: e5b1b675c694b995a779 +Hash: d325d091bb03d9d0af86 Time: Xms - Asset Size Chunks Chunk Names -c659704b2f31cae80013.js 2.01 kB 0 [emitted] -a0bf69daa522fbf8540c.js 1.03 kB 0 [emitted] -9799e4f21dc14d39e2fe.js 1.99 kB 1 [emitted] -7067a3cecd9faa0aea36.js 1.99 kB 3 [emitted] -ffed75a7125f4bffaa65.js 1.99 kB 4 [emitted] -1eb486d42a31b58c16de.js 1.03 kB 5 [emitted] -c0be493fc1372241e789.js 1.03 kB 6 [emitted] -b377816b50b5f53bb16f.js 8.06 kB 7 [emitted] main -abfb187b6140d9d3505a.js 1.99 kB 8, 0, 5 [emitted] -Entrypoint main = b377816b50b5f53bb16f.js -chunk {0} c659704b2f31cae80013.js 1.8 kB {7} [rendered] + Asset Size Chunks Chunk Names +1744d4ad4296f5fa250c.js 2.01 kB 0 [emitted] +fcea9401f4f21cf79d39.js 1.99 kB 1 [emitted] +522bb8ca666406617ab6.js 1.03 kB 2 [emitted] +20b6ca975e28ea5b7a3d.js 1.99 kB 3 [emitted] +c1e3d74e221cc503e2e1.js 1.99 kB 4 [emitted] +3d41758100f56aac517e.js 1.03 kB 5 [emitted] +c64eeda8f0bfba682f9d.js 1.03 kB 6 [emitted] +9410b3c3e392a3a95fec.js 8.52 kB 7 [emitted] main +Entrypoint main = 9410b3c3e392a3a95fec.js +chunk {0} 1744d4ad4296f5fa250c.js 1.8 kB {7} [recorded] > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 4:0-51 > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 5:0-44 > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72 [3] (webpack)/test/statsCases/aggressive-splitting-on-demand/f.js 899 bytes {0} [built] [4] (webpack)/test/statsCases/aggressive-splitting-on-demand/g.js 901 bytes {0} [built] -chunk {0} a0bf69daa522fbf8540c.js 899 bytes {7} [rendered] - > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 5:0-44 - > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72 - [0] (webpack)/test/statsCases/aggressive-splitting-on-demand/b.js 899 bytes {0} {8} [built] -chunk {1} 9799e4f21dc14d39e2fe.js 1.8 kB {7} [rendered] +chunk {1} fcea9401f4f21cf79d39.js 1.8 kB {7} [recorded] > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 3:0-30 > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 5:0-44 > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72 [1] (webpack)/test/statsCases/aggressive-splitting-on-demand/d.js 899 bytes {1} [built] [2] (webpack)/test/statsCases/aggressive-splitting-on-demand/e.js 899 bytes {1} [built] -chunk {3} 7067a3cecd9faa0aea36.js 1.8 kB {7} [rendered] +chunk {2} 522bb8ca666406617ab6.js 899 bytes {7} + > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 2:0-23 + > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 3:0-30 + [5] (webpack)/test/statsCases/aggressive-splitting-on-demand/c.js 899 bytes {2} [built] +chunk {3} 20b6ca975e28ea5b7a3d.js 1.8 kB {7} [recorded] > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 4:0-51 > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72 [8] (webpack)/test/statsCases/aggressive-splitting-on-demand/j.js 901 bytes {3} [built] [9] (webpack)/test/statsCases/aggressive-splitting-on-demand/k.js 899 bytes {3} [built] -chunk {4} ffed75a7125f4bffaa65.js 1.8 kB {7} [rendered] +chunk {4} c1e3d74e221cc503e2e1.js 1.8 kB {7} [recorded] > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 4:0-51 > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72 [6] (webpack)/test/statsCases/aggressive-splitting-on-demand/h.js 899 bytes {4} [built] [7] (webpack)/test/statsCases/aggressive-splitting-on-demand/i.js 899 bytes {4} [built] -chunk {5} 1eb486d42a31b58c16de.js 899 bytes {7} [rendered] - > aggressive-splitted [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 3:0-30 - [5] (webpack)/test/statsCases/aggressive-splitting-on-demand/c.js 899 bytes {5} {8} [built] -chunk {6} c0be493fc1372241e789.js 899 bytes {7} [rendered] +chunk {5} 3d41758100f56aac517e.js 899 bytes {7} + > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 2:0-23 + > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 5:0-44 + > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 6:0-72 + [0] (webpack)/test/statsCases/aggressive-splitting-on-demand/b.js 899 bytes {5} [built] +chunk {6} c64eeda8f0bfba682f9d.js 899 bytes {7} > [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 1:0-16 [10] (webpack)/test/statsCases/aggressive-splitting-on-demand/a.js 899 bytes {6} [built] -chunk {7} b377816b50b5f53bb16f.js (main) 248 bytes [entry] [rendered] +chunk {7} 9410b3c3e392a3a95fec.js (main) 248 bytes [entry] > main [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js - [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 248 bytes {7} [built] -chunk {8} abfb187b6140d9d3505a.js 1.8 kB {7} [rendered] [recorded] - > [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 2:0-23 - [0] (webpack)/test/statsCases/aggressive-splitting-on-demand/b.js 899 bytes {0} {8} [built] - [5] (webpack)/test/statsCases/aggressive-splitting-on-demand/c.js 899 bytes {5} {8} [built] \ No newline at end of file + [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 248 bytes {7} [built] \ No newline at end of file diff --git a/test/statsCases/chunks/expected.txt b/test/statsCases/chunks/expected.txt index 08c6642e5..616effcc3 100644 --- a/test/statsCases/chunks/expected.txt +++ b/test/statsCases/chunks/expected.txt @@ -1,10 +1,10 @@ -Hash: ec7c8a9a312ffc028d3e +Hash: 5d4f33a3de57af10c4da Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 288 bytes 0 [emitted] 1.bundle.js 152 bytes 1 [emitted] 2.bundle.js 232 bytes 2 [emitted] - bundle.js 6.74 kB 3 [emitted] main + bundle.js 7.16 kB 3 [emitted] main chunk {0} 0.bundle.js 54 bytes {3} [rendered] > [0] (webpack)/test/statsCases/chunks/index.js 3:0-16 [3] (webpack)/test/statsCases/chunks/c.js 54 bytes {0} [built] diff --git a/test/statsCases/color-disabled/expected.txt b/test/statsCases/color-disabled/expected.txt index 6a593f13e..cce608d6e 100644 --- a/test/statsCases/color-disabled/expected.txt +++ b/test/statsCases/color-disabled/expected.txt @@ -1,5 +1,5 @@ -Hash: 24aac88a5fb0e1ef1a69 +Hash: 89eab1616a5ad143a5a2 Time: Xms Asset Size Chunks Chunk Names -main.js 2.47 kB 0 [emitted] main +main.js 2.69 kB 0 [emitted] main [0] (webpack)/test/statsCases/color-disabled/index.js 0 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/color-enabled-custom/expected.txt b/test/statsCases/color-enabled-custom/expected.txt index 106da54f4..cc33d795c 100644 --- a/test/statsCases/color-enabled-custom/expected.txt +++ b/test/statsCases/color-enabled-custom/expected.txt @@ -1,5 +1,5 @@ -Hash: 24aac88a5fb0e1ef1a69 +Hash: 89eab1616a5ad143a5a2 Time: Xms Asset Size Chunks Chunk Names -main.js 2.47 kB 0 [emitted] main +main.js 2.69 kB 0 [emitted] main [0] (webpack)/test/statsCases/color-enabled-custom/index.js 0 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/color-enabled/expected.txt b/test/statsCases/color-enabled/expected.txt index db808e119..8ada6e728 100644 --- a/test/statsCases/color-enabled/expected.txt +++ b/test/statsCases/color-enabled/expected.txt @@ -1,5 +1,5 @@ -Hash: 24aac88a5fb0e1ef1a69 +Hash: 89eab1616a5ad143a5a2 Time: Xms Asset Size Chunks Chunk Names -main.js 2.47 kB 0 [emitted] main +main.js 2.69 kB 0 [emitted] main [0] (webpack)/test/statsCases/color-enabled/index.js 0 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/commons-chunk-min-size-0/expected.txt b/test/statsCases/commons-chunk-min-size-0/expected.txt index e6a5804a0..d0748d001 100644 --- a/test/statsCases/commons-chunk-min-size-0/expected.txt +++ b/test/statsCases/commons-chunk-min-size-0/expected.txt @@ -1,8 +1,8 @@ -Hash: e2982ecf41bd0a7eda73 +Hash: 39988cfdd8d15a084058 Time: Xms Asset Size Chunks Chunk Names entry-1.js 81 bytes 0 [emitted] entry-1 -vendor-1.js 7.81 kB 1 [emitted] vendor-1 +vendor-1.js 8.24 kB 1 [emitted] vendor-1 [0] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/a.js 22 bytes {1} [built] [1] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/b.js 22 bytes {1} [built] [2] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/c.js 22 bytes {1} [built] diff --git a/test/statsCases/commons-chunk-min-size-Infinity/expected.txt b/test/statsCases/commons-chunk-min-size-Infinity/expected.txt index 8b7f87dfe..d19f0fca5 100644 --- a/test/statsCases/commons-chunk-min-size-Infinity/expected.txt +++ b/test/statsCases/commons-chunk-min-size-Infinity/expected.txt @@ -1,8 +1,8 @@ -Hash: ff75deffb3bf6cded619 +Hash: 6478d38b6030870e0766 Time: Xms Asset Size Chunks Chunk Names - entry-1.js 3.11 kB 0 [emitted] entry-1 -vendor-1.js 2.85 kB 1 [emitted] vendor-1 + entry-1.js 3.32 kB 0 [emitted] entry-1 +vendor-1.js 3.07 kB 1 [emitted] vendor-1 [0] (webpack)/test/statsCases/commons-chunk-min-size-Infinity/modules/a.js 22 bytes {0} {1} [built] [1] (webpack)/test/statsCases/commons-chunk-min-size-Infinity/modules/b.js 22 bytes {0} {1} [built] [2] (webpack)/test/statsCases/commons-chunk-min-size-Infinity/modules/c.js 22 bytes {0} {1} [built] diff --git a/test/statsCases/commons-chunk-plugin-children/expected.txt b/test/statsCases/commons-chunk-plugin-children/expected.txt index c1a3ce0e9..87db05bb1 100644 --- a/test/statsCases/commons-chunk-plugin-children/expected.txt +++ b/test/statsCases/commons-chunk-plugin-children/expected.txt @@ -6,7 +6,7 @@ Child normal: 3.bundle.js 837 bytes 3 [emitted] x2 4.bundle.js 530 bytes 4 [emitted] x1 5.bundle.js 1.15 kB 5 [emitted] xx5 - bundle.js 6.81 kB 6 [emitted] main + bundle.js 7.24 kB 6 [emitted] main chunk {0} 0.bundle.js (x4) 56 bytes {6} [rendered] > x4 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 4:0-42 [0] (webpack)/test/statsCases/commons-chunk-plugin-children/a.js 0 bytes {0} {1} {2} {3} {4} [built] @@ -51,7 +51,7 @@ Child children: 3.bundle.js 692 bytes 3 [emitted] x2 4.bundle.js 472 bytes 4 [emitted] x1 5.bundle.js 1.15 kB 5 [emitted] xx5 - bundle.js 6.94 kB 6 [emitted] main + bundle.js 7.36 kB 6 [emitted] main chunk {0} 0.bundle.js (x4) 56 bytes {6} [rendered] > x4 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 4:0-42 [1] (webpack)/test/statsCases/commons-chunk-plugin-children/c.js 0 bytes {0} {1} {5} [built] @@ -90,7 +90,7 @@ Child async: 4.bundle.js 692 bytes 4 [emitted] x2 5.bundle.js 472 bytes 5 [emitted] x1 6.bundle.js 1.15 kB 6 [emitted] xx5 - bundle.js 7.02 kB 7 [emitted] main + bundle.js 7.44 kB 7 [emitted] main chunk {0} 0.bundle.js 0 bytes {7} [rendered] > async commons x1 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 1:0-42 > async commons x2 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 2:0-42 @@ -134,7 +134,7 @@ Child deep-children: 3.bundle.js 912 bytes 3 [emitted] x3 4.bundle.js 692 bytes 4 [emitted] x2 5.bundle.js 472 bytes 5 [emitted] x1 - bundle.js 6.99 kB 6 [emitted] main + bundle.js 7.41 kB 6 [emitted] main chunk {0} 0.bundle.js (xx5) 42 bytes {6} [rendered] > xx5 [9] (webpack)/test/statsCases/commons-chunk-plugin-children/x5.js 3:0-44 [3] (webpack)/test/statsCases/commons-chunk-plugin-children/d.js 0 bytes {0} {1} [built] @@ -171,7 +171,7 @@ Child deep-async: 4.bundle.js 692 bytes 4 [emitted] x2 5.bundle.js 472 bytes 5 [emitted] x1 6.bundle.js 1.03 kB 6 [emitted] xx5 - bundle.js 7.02 kB 7 [emitted] main + bundle.js 7.44 kB 7 [emitted] main chunk {0} 0.bundle.js 0 bytes {7} [rendered] > async commons x1 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 1:0-42 > async commons x2 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 2:0-42 diff --git a/test/statsCases/commons-plugin-issue-4980/expected.txt b/test/statsCases/commons-plugin-issue-4980/expected.txt index 5d899bf8b..1bb9886db 100644 --- a/test/statsCases/commons-plugin-issue-4980/expected.txt +++ b/test/statsCases/commons-plugin-issue-4980/expected.txt @@ -1,22 +1,22 @@ -Hash: bc31f1e4fd9de92176f32226864c44372499fe96 +Hash: acd1f75abe608dba57c70b1ed992624bd4ceefaa Child - Hash: bc31f1e4fd9de92176f3 + Hash: acd1f75abe608dba57c7 Time: Xms Asset Size Chunks Chunk Names app.js 1.32 kB 0 [emitted] app - vendor.76e65ef421e93d510398.js 619 bytes 1 [emitted] vendor - runtime.js 6.82 kB 2 [emitted] runtime + vendor.3210cd7580ff3ec8d7c1.js 619 bytes 1 [emitted] vendor + runtime.js 7.25 kB 2 [emitted] runtime [./constants.js] (webpack)/test/statsCases/commons-plugin-issue-4980/constants.js 87 bytes {1} [built] [./entry-1.js] (webpack)/test/statsCases/commons-plugin-issue-4980/entry-1.js 67 bytes {0} [built] [./submodule-a.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-a.js 59 bytes {0} [built] [./submodule-b.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-b.js 59 bytes {0} [built] Child - Hash: 2226864c44372499fe96 + Hash: 0b1ed992624bd4ceefaa Time: Xms Asset Size Chunks Chunk Names app.js 1.37 kB 0 [emitted] app - vendor.76e65ef421e93d510398.js 619 bytes 1 [emitted] vendor - runtime.js 6.82 kB 2 [emitted] runtime + vendor.3210cd7580ff3ec8d7c1.js 619 bytes 1 [emitted] vendor + runtime.js 7.25 kB 2 [emitted] runtime [./constants.js] (webpack)/test/statsCases/commons-plugin-issue-4980/constants.js 87 bytes {1} [built] [./entry-2.js] (webpack)/test/statsCases/commons-plugin-issue-4980/entry-2.js 67 bytes {0} [built] [./submodule-a.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-a.js 59 bytes {0} [built] diff --git a/test/statsCases/define-plugin/expected.txt b/test/statsCases/define-plugin/expected.txt index 332adc95c..66bf59863 100644 --- a/test/statsCases/define-plugin/expected.txt +++ b/test/statsCases/define-plugin/expected.txt @@ -1,13 +1,13 @@ -Hash: 6add27cebf4b26789967542792bed75071de6d48 +Hash: 8bb1a50077aee68e988a597c54a008106ce8b531 Child - Hash: 6add27cebf4b26789967 + Hash: 8bb1a50077aee68e988a Time: Xms Asset Size Chunks Chunk Names - main.js 2.52 kB 0 [emitted] main + main.js 2.73 kB 0 [emitted] main [0] (webpack)/test/statsCases/define-plugin/index.js 24 bytes {0} [built] Child - Hash: 542792bed75071de6d48 + Hash: 597c54a008106ce8b531 Time: Xms Asset Size Chunks Chunk Names - main.js 2.52 kB 0 [emitted] main + main.js 2.73 kB 0 [emitted] main [0] (webpack)/test/statsCases/define-plugin/index.js 24 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/exclude-with-loader/expected.txt b/test/statsCases/exclude-with-loader/expected.txt index 937beae4e..fba1315ac 100644 --- a/test/statsCases/exclude-with-loader/expected.txt +++ b/test/statsCases/exclude-with-loader/expected.txt @@ -1,7 +1,7 @@ -Hash: e901212ba1092de427e5 +Hash: 8c02b98c18c91aa84690 Time: Xms Asset Size Chunks Chunk Names -bundle.js 2.92 kB 0 [emitted] main +bundle.js 3.14 kB 0 [emitted] main + 1 hidden asset [0] (webpack)/test/statsCases/exclude-with-loader/index.js 77 bytes {0} [built] [1] (webpack)/test/statsCases/exclude-with-loader/a.txt 43 bytes {0} [built] diff --git a/test/statsCases/external/expected.txt b/test/statsCases/external/expected.txt index 3738161b7..2e8ee8ea0 100644 --- a/test/statsCases/external/expected.txt +++ b/test/statsCases/external/expected.txt @@ -1,6 +1,6 @@ -Hash: 13748bc330152117fafc +Hash: 36483aa6c04f6ef13570 Time: Xms Asset Size Chunks Chunk Names -main.js 2.61 kB 0 [emitted] main +main.js 2.82 kB 0 [emitted] main [0] (webpack)/test/statsCases/external/index.js 17 bytes {0} [built] [1] external "test" 42 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/filter-warnings/expected.txt b/test/statsCases/filter-warnings/expected.txt index a5d8381e6..fe3f5b5fe 100644 --- a/test/statsCases/filter-warnings/expected.txt +++ b/test/statsCases/filter-warnings/expected.txt @@ -1,11 +1,12 @@ -Hash: e743b7134905e5d0c58ae743b7134905e5d0c58ae743b7134905e5d0c58ae743b7134905e5d0c58ae743b7134905e5d0c58ae743b7134905e5d0c58ae743b7134905e5d0c58ae743b7134905e5d0c58ae743b7134905e5d0c58ae743b7134905e5d0c58ae743b7134905e5d0c58ae743b7134905e5d0c58ae743b7134905e5d0c58a +Hash: 0f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a00 Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs + Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -18,42 +19,43 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs + Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -66,12 +68,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs + Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -84,12 +87,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs + Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -102,12 +106,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs + Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -120,12 +125,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs + Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -138,12 +144,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: e743b7134905e5d0c58a + Hash: 0f94f7deae4c04d56a00 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs + Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] diff --git a/test/statsCases/import-context-filter/expected.txt b/test/statsCases/import-context-filter/expected.txt index 9aed9ac65..96817f3ab 100644 --- a/test/statsCases/import-context-filter/expected.txt +++ b/test/statsCases/import-context-filter/expected.txt @@ -1,10 +1,10 @@ -Hash: 308701a2a24de7c80900 +Hash: 7e892e0fb490714c0a3a Time: Xms Asset Size Chunks Chunk Names 0.js 339 bytes 0 [emitted] 1.js 345 bytes 1 [emitted] 2.js 336 bytes 2 [emitted] -entry.js 7.45 kB 3 [emitted] entry +entry.js 7.88 kB 3 [emitted] entry [0] (webpack)/test/statsCases/import-context-filter/templates/bar.js 38 bytes {2} [optional] [built] [1] (webpack)/test/statsCases/import-context-filter/templates/baz.js 38 bytes {1} [optional] [built] [2] (webpack)/test/statsCases/import-context-filter/templates/foo.js 38 bytes {0} [optional] [built] diff --git a/test/statsCases/import-weak/expected.txt b/test/statsCases/import-weak/expected.txt index 6968b5437..e094ffedf 100644 --- a/test/statsCases/import-weak/expected.txt +++ b/test/statsCases/import-weak/expected.txt @@ -1,8 +1,8 @@ -Hash: 00bdc9e68dab6471776c +Hash: 8ac1d37f7cee7ab1016d Time: Xms Asset Size Chunks Chunk Names 0.js 149 bytes 0 [emitted] -entry.js 6.86 kB 1 [emitted] entry +entry.js 7.28 kB 1 [emitted] entry [0] (webpack)/test/statsCases/import-weak/modules/b.js 22 bytes {0} [built] [1] (webpack)/test/statsCases/import-weak/entry.js 120 bytes {1} [built] [2] (webpack)/test/statsCases/import-weak/modules/a.js 37 bytes [built] \ No newline at end of file diff --git a/test/statsCases/limit-chunk-count-plugin/expected.txt b/test/statsCases/limit-chunk-count-plugin/expected.txt index 2fc825071..ea26f54c4 100644 --- a/test/statsCases/limit-chunk-count-plugin/expected.txt +++ b/test/statsCases/limit-chunk-count-plugin/expected.txt @@ -1,9 +1,9 @@ -Hash: 46a7a39ec383c6479bea3e8c58141126afe0bf8ff50878d3027cf0a3fce6ee5a7f05473b5f3a79b9 +Hash: d3b4d57e725fbf0c40c40384242efaa60e350cb2a8afa85f69ff21e19fb4d9c7396cbd5b5cf16e63 Child - Hash: 46a7a39ec383c6479bea + Hash: d3b4d57e725fbf0c40c4 Time: Xms - Asset Size Chunks Chunk Names - bundle.js 3.4 kB 0 [emitted] main + Asset Size Chunks Chunk Names + bundle.js 3.61 kB 0 [emitted] main chunk {0} bundle.js (main) 191 bytes [entry] [rendered] [0] (webpack)/test/statsCases/limit-chunk-count-plugin/index.js 73 bytes {0} [built] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] @@ -12,11 +12,11 @@ Child [4] (webpack)/test/statsCases/limit-chunk-count-plugin/d.js 22 bytes {0} [built] [5] (webpack)/test/statsCases/limit-chunk-count-plugin/e.js 22 bytes {0} [built] Child - Hash: 3e8c58141126afe0bf8f + Hash: 0384242efaa60e350cb2 Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 651 bytes 0 [emitted] - bundle.js 6.77 kB 1 [emitted] main + bundle.js 7.19 kB 1 [emitted] main chunk {0} 0.bundle.js 118 bytes {1} [rendered] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] [2] (webpack)/test/statsCases/limit-chunk-count-plugin/b.js 22 bytes {0} [built] @@ -26,12 +26,12 @@ Child chunk {1} bundle.js (main) 73 bytes [entry] [rendered] [0] (webpack)/test/statsCases/limit-chunk-count-plugin/index.js 73 bytes {1} [built] Child - Hash: f50878d3027cf0a3fce6 + Hash: a8afa85f69ff21e19fb4 Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 504 bytes 0 [emitted] 1.bundle.js 232 bytes 1 [emitted] - bundle.js 6.77 kB 2 [emitted] main + bundle.js 7.19 kB 2 [emitted] main chunk {0} 0.bundle.js 74 bytes {2} [rendered] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] [3] (webpack)/test/statsCases/limit-chunk-count-plugin/c.js 30 bytes {0} [built] @@ -42,13 +42,13 @@ Child chunk {2} bundle.js (main) 73 bytes [entry] [rendered] [0] (webpack)/test/statsCases/limit-chunk-count-plugin/index.js 73 bytes {2} [built] Child - Hash: ee5a7f05473b5f3a79b9 + Hash: d9c7396cbd5b5cf16e63 Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 232 bytes 0 [emitted] 1.bundle.js 254 bytes 1 [emitted] 2.bundle.js 333 bytes 2 [emitted] - bundle.js 6.76 kB 3 [emitted] main + bundle.js 7.18 kB 3 [emitted] main chunk {0} 0.bundle.js 44 bytes {2} {3} [rendered] [2] (webpack)/test/statsCases/limit-chunk-count-plugin/b.js 22 bytes {0} [built] [5] (webpack)/test/statsCases/limit-chunk-count-plugin/e.js 22 bytes {0} [built] diff --git a/test/statsCases/max-modules-default/expected.txt b/test/statsCases/max-modules-default/expected.txt index c3a5d3d55..3dce37f8e 100644 --- a/test/statsCases/max-modules-default/expected.txt +++ b/test/statsCases/max-modules-default/expected.txt @@ -1,7 +1,7 @@ -Hash: 510b13d517c125d60c88 +Hash: 7a772243f1745ecb230f Time: Xms - Asset Size Chunks Chunk Names -main.js 5.79 kB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 6 kB 0 [emitted] main [0] (webpack)/test/statsCases/max-modules-default/a.js?1 33 bytes {0} [built] [1] (webpack)/test/statsCases/max-modules-default/a.js?2 33 bytes {0} [built] [2] (webpack)/test/statsCases/max-modules-default/a.js?3 33 bytes {0} [built] diff --git a/test/statsCases/max-modules/expected.txt b/test/statsCases/max-modules/expected.txt index 48ef0139b..81ec06aff 100644 --- a/test/statsCases/max-modules/expected.txt +++ b/test/statsCases/max-modules/expected.txt @@ -1,7 +1,7 @@ -Hash: 510b13d517c125d60c88 +Hash: 7a772243f1745ecb230f Time: Xms - Asset Size Chunks Chunk Names -main.js 5.79 kB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 6 kB 0 [emitted] main [0] (webpack)/test/statsCases/max-modules/a.js?1 33 bytes {0} [built] [1] (webpack)/test/statsCases/max-modules/a.js?2 33 bytes {0} [built] [2] (webpack)/test/statsCases/max-modules/a.js?3 33 bytes {0} [built] diff --git a/test/statsCases/module-deduplication-named/expected.txt b/test/statsCases/module-deduplication-named/expected.txt index d67a6bbc4..cba3a9d98 100644 --- a/test/statsCases/module-deduplication-named/expected.txt +++ b/test/statsCases/module-deduplication-named/expected.txt @@ -2,9 +2,9 @@ Asset Size Chunks Chunk Names 0.js 839 bytes 0 [emitted] async3 1.js 839 bytes 1 [emitted] async2 2.js 839 bytes 2 [emitted] async1 -e3.js 7.81 kB 3 [emitted] e3 -e2.js 7.79 kB 4 [emitted] e2 -e1.js 7.77 kB 5 [emitted] e1 +e3.js 8.23 kB 3 [emitted] e3 +e2.js 8.21 kB 4 [emitted] e2 +e1.js 8.19 kB 5 [emitted] e1 chunk {0} 0.js (async3) 89 bytes {1} {3} [rendered] [4] (webpack)/test/statsCases/module-deduplication-named/h.js 9 bytes {0} {3} [built] [7] (webpack)/test/statsCases/module-deduplication-named/async3.js 80 bytes {0} [built] diff --git a/test/statsCases/module-deduplication/expected.txt b/test/statsCases/module-deduplication/expected.txt index 0103086e0..ef8125bc7 100644 --- a/test/statsCases/module-deduplication/expected.txt +++ b/test/statsCases/module-deduplication/expected.txt @@ -5,9 +5,9 @@ Asset Size Chunks Chunk Names 3.js 692 bytes 3 [emitted] 4.js 692 bytes 4 [emitted] 5.js 692 bytes 5 [emitted] -e3.js 8 kB 6 [emitted] e3 -e2.js 7.98 kB 7 [emitted] e2 -e1.js 7.96 kB 8 [emitted] e1 +e3.js 8.43 kB 6 [emitted] e3 +e2.js 8.4 kB 7 [emitted] e2 +e1.js 8.38 kB 8 [emitted] e1 chunk {0} 0.js 37 bytes {7} {8} [rendered] [6] (webpack)/test/statsCases/module-deduplication/async3.js 28 bytes {0} {3} [built] [7] (webpack)/test/statsCases/module-deduplication/h.js 9 bytes {0} {6} [built] diff --git a/test/statsCases/module-trace-disabled-in-error/expected.txt b/test/statsCases/module-trace-disabled-in-error/expected.txt index 0058796ae..22f9a4d42 100644 --- a/test/statsCases/module-trace-disabled-in-error/expected.txt +++ b/test/statsCases/module-trace-disabled-in-error/expected.txt @@ -1,6 +1,6 @@ Time: Xms Asset Size Chunks Chunk Names -main.js 2.65 kB 0 [emitted] main +main.js 2.87 kB 0 [emitted] main [0] (webpack)/test/statsCases/module-trace-disabled-in-error/index.js 25 bytes {0} [built] ERROR in (webpack)/test/statsCases/module-trace-disabled-in-error/index.js diff --git a/test/statsCases/module-trace-enabled-in-error/expected.txt b/test/statsCases/module-trace-enabled-in-error/expected.txt index de33078eb..1ca583b44 100644 --- a/test/statsCases/module-trace-enabled-in-error/expected.txt +++ b/test/statsCases/module-trace-enabled-in-error/expected.txt @@ -1,6 +1,6 @@ Time: Xms Asset Size Chunks Chunk Names -main.js 2.65 kB 0 [emitted] main +main.js 2.87 kB 0 [emitted] main [0] (webpack)/test/statsCases/module-trace-enabled-in-error/index.js 25 bytes {0} [built] ERROR in (webpack)/test/statsCases/module-trace-enabled-in-error/index.js diff --git a/test/statsCases/named-chunks-plugin-async/expected.txt b/test/statsCases/named-chunks-plugin-async/expected.txt index a4499a71e..dd5e26394 100644 --- a/test/statsCases/named-chunks-plugin-async/expected.txt +++ b/test/statsCases/named-chunks-plugin-async/expected.txt @@ -1,9 +1,9 @@ -Hash: 668d0eb74d7650731352 +Hash: cd277029f12cdb352584 Time: Xms Asset Size Chunks Chunk Names chunk-containing-__a_js.js 316 bytes chunk-containing-__a_js [emitted] chunk-containing-__b_js.js 173 bytes chunk-containing-__b_js [emitted] - entry.js 6.64 kB entry [emitted] entry + entry.js 7.07 kB entry [emitted] entry [0] (webpack)/test/statsCases/named-chunks-plugin-async/modules/b.js 22 bytes {chunk-containing-__b_js} [built] [1] (webpack)/test/statsCases/named-chunks-plugin-async/entry.js 47 bytes {entry} [built] [2] (webpack)/test/statsCases/named-chunks-plugin-async/modules/a.js 37 bytes {chunk-containing-__a_js} [built] \ No newline at end of file diff --git a/test/statsCases/named-chunks-plugin/expected.txt b/test/statsCases/named-chunks-plugin/expected.txt index 65efcd41b..1e410da72 100644 --- a/test/statsCases/named-chunks-plugin/expected.txt +++ b/test/statsCases/named-chunks-plugin/expected.txt @@ -1,8 +1,8 @@ -Hash: e2a3a4f76d4a30adbf3e +Hash: b3622b84af67b4db881c Time: Xms Asset Size Chunks Chunk Names entry.js 615 bytes entry [emitted] entry -manifest.js 6.83 kB manifest [emitted] manifest +manifest.js 7.26 kB manifest [emitted] manifest vendor.js 469 bytes vendor [emitted] vendor [0] multi ./modules/a ./modules/b 40 bytes {vendor} [built] [./entry.js] (webpack)/test/statsCases/named-chunks-plugin/entry.js 72 bytes {entry} [built] diff --git a/test/statsCases/optimize-chunks/expected.txt b/test/statsCases/optimize-chunks/expected.txt index e70c4348d..1f4df5d10 100644 --- a/test/statsCases/optimize-chunks/expected.txt +++ b/test/statsCases/optimize-chunks/expected.txt @@ -1,4 +1,4 @@ -Hash: 284de8edb2496f0ce72d +Hash: bfbf50a57f37361544f4 Time: Xms Asset Size Chunks Chunk Names 0.js 281 bytes 0 [emitted] cir1 @@ -8,7 +8,7 @@ Time: Xms 4.js 212 bytes 4, 6 [emitted] chunk 5.js 356 bytes 5, 3 [emitted] cir2 from cir1 6.js 130 bytes 6 [emitted] ac in ab -main.js 7.43 kB 7 [emitted] main +main.js 7.85 kB 7 [emitted] main chunk {0} 0.js (cir1) 81 bytes {3} {7} [rendered] > duplicate cir1 from cir2 [6] (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/parse-error/expected.txt b/test/statsCases/parse-error/expected.txt index 8a868a134..6a389bf14 100644 --- a/test/statsCases/parse-error/expected.txt +++ b/test/statsCases/parse-error/expected.txt @@ -1,5 +1,5 @@ Asset Size Chunks Chunk Names -main.js 3.23 kB 0 [emitted] main +main.js 3.44 kB 0 [emitted] main [0] (webpack)/test/statsCases/parse-error/index.js 15 bytes {0} [built] [1] (webpack)/test/statsCases/parse-error/a.js 15 bytes {0} [built] [2] (webpack)/test/statsCases/parse-error/b.js 169 bytes {0} [built] [failed] [1 error] diff --git a/test/statsCases/performance-no-async-chunks-shown/expected.txt b/test/statsCases/performance-no-async-chunks-shown/expected.txt index 8ed34c516..68c6ce8bb 100644 --- a/test/statsCases/performance-no-async-chunks-shown/expected.txt +++ b/test/statsCases/performance-no-async-chunks-shown/expected.txt @@ -1,6 +1,6 @@ Time: Xms Asset Size Chunks Chunk Names - sec.js 2.82 kB 0 [emitted] sec + sec.js 3.03 kB 0 [emitted] sec main.js 303 kB 1 [emitted] [big] main Entrypoint main [big] = main.js Entrypoint sec = sec.js diff --git a/test/statsCases/preset-detailed/expected.txt b/test/statsCases/preset-detailed/expected.txt index 2c170249e..fe4b0c16d 100644 --- a/test/statsCases/preset-detailed/expected.txt +++ b/test/statsCases/preset-detailed/expected.txt @@ -1,10 +1,10 @@ -Hash: 0556d5e48c7f2a7728b3 +Hash: ed693a88a68d2e3a365a Time: Xms Asset Size Chunks Chunk Names 0.js 288 bytes 0 [emitted] 1.js 152 bytes 1 [emitted] 2.js 232 bytes 2 [emitted] -main.js 6.73 kB 3 [emitted] main +main.js 7.16 kB 3 [emitted] main Entrypoint main = main.js chunk {0} 0.js 54 bytes {3} [rendered] > [0] (webpack)/test/statsCases/preset-detailed/index.js 3:0-16 diff --git a/test/statsCases/preset-normal/expected.txt b/test/statsCases/preset-normal/expected.txt index 4927ec536..eb8be625f 100644 --- a/test/statsCases/preset-normal/expected.txt +++ b/test/statsCases/preset-normal/expected.txt @@ -1,10 +1,10 @@ -Hash: 0556d5e48c7f2a7728b3 +Hash: ed693a88a68d2e3a365a Time: Xms Asset Size Chunks Chunk Names 0.js 288 bytes 0 [emitted] 1.js 152 bytes 1 [emitted] 2.js 232 bytes 2 [emitted] -main.js 6.73 kB 3 [emitted] main +main.js 7.16 kB 3 [emitted] main [0] (webpack)/test/statsCases/preset-normal/index.js 51 bytes {3} [built] [1] (webpack)/test/statsCases/preset-normal/a.js 22 bytes {3} [built] [2] (webpack)/test/statsCases/preset-normal/b.js 22 bytes {1} [built] diff --git a/test/statsCases/preset-verbose/expected.txt b/test/statsCases/preset-verbose/expected.txt index 462ae436a..df6a6124a 100644 --- a/test/statsCases/preset-verbose/expected.txt +++ b/test/statsCases/preset-verbose/expected.txt @@ -1,10 +1,10 @@ -Hash: 0556d5e48c7f2a7728b3 +Hash: ed693a88a68d2e3a365a Time: Xms Asset Size Chunks Chunk Names 0.js 288 bytes 0 [emitted] 1.js 152 bytes 1 [emitted] 2.js 232 bytes 2 [emitted] -main.js 6.73 kB 3 [emitted] main +main.js 7.16 kB 3 [emitted] main Entrypoint main = main.js chunk {0} 0.js 54 bytes {3} [rendered] > [0] (webpack)/test/statsCases/preset-verbose/index.js 3:0-16 diff --git a/test/statsCases/resolve-plugin-context/expected.txt b/test/statsCases/resolve-plugin-context/expected.txt index 055464467..074eaf443 100644 --- a/test/statsCases/resolve-plugin-context/expected.txt +++ b/test/statsCases/resolve-plugin-context/expected.txt @@ -1,7 +1,7 @@ -Hash: 4ffa8a63eba9a73bd83a +Hash: 77d7803a0e5cab4bf94e Time: Xms - Asset Size Chunks Chunk Names -bundle.js 2.88 kB 0 [emitted] main + Asset Size Chunks Chunk Names +bundle.js 3.1 kB 0 [emitted] main [0] (webpack)/test/statsCases/resolve-plugin-context/node_modules/xyz/index.js 0 bytes {0} [built] [1] (webpack)/test/statsCases/resolve-plugin-context/index.js 48 bytes {0} [built] [2] (webpack)/test/statsCases/resolve-plugin-context/node_modules/abc/index.js 16 bytes {0} [built] diff --git a/test/statsCases/reverse-sort-modules/expected.txt b/test/statsCases/reverse-sort-modules/expected.txt index 26e2c0bce..41e2ce736 100644 --- a/test/statsCases/reverse-sort-modules/expected.txt +++ b/test/statsCases/reverse-sort-modules/expected.txt @@ -1,7 +1,7 @@ -Hash: 510b13d517c125d60c88 +Hash: 7a772243f1745ecb230f Time: Xms - Asset Size Chunks Chunk Names -main.js 5.79 kB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 6 kB 0 [emitted] main [29] (webpack)/test/statsCases/reverse-sort-modules/c.js?10 33 bytes {0} [built] [27] (webpack)/test/statsCases/reverse-sort-modules/c.js?9 33 bytes {0} [built] [25] (webpack)/test/statsCases/reverse-sort-modules/c.js?8 33 bytes {0} [built] diff --git a/test/statsCases/scope-hoisting-multi/expected.txt b/test/statsCases/scope-hoisting-multi/expected.txt index bcd506e10..31c65585f 100644 --- a/test/statsCases/scope-hoisting-multi/expected.txt +++ b/test/statsCases/scope-hoisting-multi/expected.txt @@ -1,6 +1,6 @@ -Hash: 0758b2e4b34e9e2299b4cf1121d95bbe7721c1f3 +Hash: 25da10e7d3d4121b1f85d6f6aa5f20b982e1aff9 Child - Hash: 0758b2e4b34e9e2299b4 + Hash: 25da10e7d3d4121b1f85 Time: Xms [0] (webpack)/test/statsCases/scope-hoisting-multi/common2.js 25 bytes {3} {4} [built] [1] (webpack)/test/statsCases/scope-hoisting-multi/common_lazy_shared.js 25 bytes {0} {1} {2} [built] @@ -14,7 +14,7 @@ Child [9] (webpack)/test/statsCases/scope-hoisting-multi/second.js 177 bytes {4} [built] [10] (webpack)/test/statsCases/scope-hoisting-multi/lazy_second.js 55 bytes {1} [built] Child - Hash: cf1121d95bbe7721c1f3 + Hash: d6f6aa5f20b982e1aff9 Time: Xms [0] (webpack)/test/statsCases/scope-hoisting-multi/common_lazy_shared.js 25 bytes {0} {1} {2} [built] [1] (webpack)/test/statsCases/scope-hoisting-multi/vendor.js 25 bytes {5} [built] diff --git a/test/statsCases/separate-css-bundle/expected.txt b/test/statsCases/separate-css-bundle/expected.txt index 79667332d..8fabce7be 100644 --- a/test/statsCases/separate-css-bundle/expected.txt +++ b/test/statsCases/separate-css-bundle/expected.txt @@ -1,9 +1,9 @@ -Hash: da212ebe137c4652925fee9f676067a60342413c +Hash: da16790d5db6d9935b08cf1165d0e30fbaab2ce7 Child - Hash: da212ebe137c4652925f + Hash: da16790d5db6d9935b08 Time: Xms Asset Size Chunks Chunk Names - fd9bad62ebd7cda4d760.js 2.62 kB 0 [emitted] main + fd4c2ca1440010a55587.js 2.83 kB 0 [emitted] main c815cf440254d4f3bba4e7041db00a28.css 26 bytes 0 [emitted] main [0] (webpack)/test/statsCases/separate-css-bundle/a/index.js 23 bytes {0} [built] [1] (webpack)/test/statsCases/separate-css-bundle/a/file.css 41 bytes {0} [built] @@ -15,10 +15,10 @@ Child [0] (webpack)/node_modules/css-loader!(webpack)/test/statsCases/separate-css-bundle/a/file.css 199 bytes {0} [built] [1] (webpack)/node_modules/css-loader/lib/css-base.js 2.26 kB {0} [built] Child - Hash: ee9f676067a60342413c + Hash: cf1165d0e30fbaab2ce7 Time: Xms Asset Size Chunks Chunk Names - fd9bad62ebd7cda4d760.js 2.62 kB 0 [emitted] main + fd4c2ca1440010a55587.js 2.83 kB 0 [emitted] main a3f385680aef7a9bb2a517699532cc34.css 28 bytes 0 [emitted] main [0] (webpack)/test/statsCases/separate-css-bundle/b/index.js 23 bytes {0} [built] [1] (webpack)/test/statsCases/separate-css-bundle/b/file.css 41 bytes {0} [built] diff --git a/test/statsCases/simple-more-info/expected.txt b/test/statsCases/simple-more-info/expected.txt index 08fe85f1b..ca953f934 100644 --- a/test/statsCases/simple-more-info/expected.txt +++ b/test/statsCases/simple-more-info/expected.txt @@ -1,7 +1,7 @@ -Hash: 4df41ff8ebd516be0a28 +Hash: df82344a911f69966ecc Time: Xms Asset Size Chunks Chunk Names -bundle.js 2.47 kB 0 [emitted] main +bundle.js 2.69 kB 0 [emitted] main [0] (webpack)/test/statsCases/simple-more-info/index.js 0 bytes {0} [built] single entry ./index main factory:Xms building:Xms = Xms \ No newline at end of file diff --git a/test/statsCases/simple/expected.txt b/test/statsCases/simple/expected.txt index 451f301b4..d00173ca2 100644 --- a/test/statsCases/simple/expected.txt +++ b/test/statsCases/simple/expected.txt @@ -1,5 +1,5 @@ -Hash: 4df41ff8ebd516be0a28 +Hash: df82344a911f69966ecc Time: Xms Asset Size Chunks Chunk Names -bundle.js 2.47 kB 0 [emitted] main +bundle.js 2.69 kB 0 [emitted] main [0] (webpack)/test/statsCases/simple/index.js 0 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/tree-shaking/expected.txt b/test/statsCases/tree-shaking/expected.txt index 9d14de3d2..a25f7374a 100644 --- a/test/statsCases/tree-shaking/expected.txt +++ b/test/statsCases/tree-shaking/expected.txt @@ -1,7 +1,7 @@ -Hash: cf1d612901672c349b41 +Hash: 762e00600c7e7e1ad161 Time: Xms Asset Size Chunks Chunk Names -bundle.js 7.04 kB 0 [emitted] main +bundle.js 7.25 kB 0 [emitted] main [0] (webpack)/test/statsCases/tree-shaking/a.js 13 bytes {0} [built] [exports: a] [only some exports used: a] diff --git a/test/statsCases/warnings-uglifyjs/expected.txt b/test/statsCases/warnings-uglifyjs/expected.txt index 86baf9aed..06b64ce3c 100644 --- a/test/statsCases/warnings-uglifyjs/expected.txt +++ b/test/statsCases/warnings-uglifyjs/expected.txt @@ -1,7 +1,7 @@ -Hash: cf63b6ddede66b99c822 +Hash: 54b9e9a2850ab55d7e8f Time: Xms - Asset Size Chunks Chunk Names -bundle.js 2.1 kB 0 [emitted] main + Asset Size Chunks Chunk Names +bundle.js 2.13 kB 0 [emitted] main [0] (webpack)/test/statsCases/warnings-uglifyjs/index.js 299 bytes {0} [built] [1] (webpack)/test/statsCases/warnings-uglifyjs/a.js 249 bytes {0} [built] [2] (webpack)/buildin/module.js 495 bytes {0} [built] From 9cb10574a41c3ae010c837bd4a930b1b9ea57067 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 9 Oct 2017 15:44:42 +0200 Subject: [PATCH 28/85] generate shorter export names when using many exports --- lib/Template.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/Template.js b/lib/Template.js index 78a85543f..dc971b868 100644 --- a/lib/Template.js +++ b/lib/Template.js @@ -70,9 +70,8 @@ module.exports = class Template extends Tapable { n -= DELTA_A_TO_Z; if(n < DELTA_A_TO_Z) return String.fromCharCode(START_UPPERCASE_ALPHABET_CODE + n); - // fall back to _ + number - n -= DELTA_A_TO_Z; - return "_" + n; + // use multiple letters + return Template.numberToIdentifer(n % (2 * DELTA_A_TO_Z)) + Template.numberToIdentifer(Math.floor(n / (2 * DELTA_A_TO_Z))); } indent(str) { From 65e855c636422866dc434f5deb86fc3363a468ab Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sat, 11 Nov 2017 11:27:02 +0100 Subject: [PATCH 29/85] fix deprecations --- lib/Chunk.js | 10 ++--- lib/ChunkTemplate.js | 2 +- lib/Compilation.js | 4 +- lib/EvalDevToolModulePlugin.js | 2 +- lib/EvalSourceMapDevToolPlugin.js | 2 +- lib/FunctionModulePlugin.js | 4 +- lib/HotModuleReplacementPlugin.js | 2 +- test/Validation.test.js | 2 +- .../aggressive-splitting-entry/expected.txt | 6 +-- .../expected.txt | 2 +- test/statsCases/chunks/expected.txt | 2 +- test/statsCases/color-disabled/expected.txt | 2 +- .../color-enabled-custom/expected.txt | 2 +- test/statsCases/color-enabled/expected.txt | 2 +- .../commons-chunk-min-size-0/expected.txt | 2 +- .../expected.txt | 2 +- .../commons-plugin-issue-4980/expected.txt | 6 +-- test/statsCases/define-plugin/expected.txt | 6 +-- .../exclude-with-loader/expected.txt | 2 +- test/statsCases/external/expected.txt | 2 +- test/statsCases/filter-warnings/expected.txt | 42 +++++++++---------- .../import-context-filter/expected.txt | 2 +- test/statsCases/import-weak/expected.txt | 2 +- .../limit-chunk-count-plugin/expected.txt | 10 ++--- .../max-modules-default/expected.txt | 2 +- test/statsCases/max-modules/expected.txt | 2 +- .../named-chunks-plugin-async/expected.txt | 2 +- .../named-chunks-plugin/expected.txt | 2 +- test/statsCases/optimize-chunks/expected.txt | 2 +- test/statsCases/preset-detailed/expected.txt | 2 +- test/statsCases/preset-normal/expected.txt | 2 +- test/statsCases/preset-verbose/expected.txt | 2 +- .../resolve-plugin-context/expected.txt | 2 +- .../reverse-sort-modules/expected.txt | 2 +- .../scope-hoisting-multi/expected.txt | 6 +-- .../separate-css-bundle/expected.txt | 6 +-- test/statsCases/simple-more-info/expected.txt | 2 +- test/statsCases/simple/expected.txt | 2 +- test/statsCases/tree-shaking/expected.txt | 2 +- .../statsCases/warnings-uglifyjs/expected.txt | 2 +- 40 files changed, 79 insertions(+), 81 deletions(-) diff --git a/lib/Chunk.js b/lib/Chunk.js index fdff57a65..885d07671 100644 --- a/lib/Chunk.js +++ b/lib/Chunk.js @@ -445,9 +445,9 @@ class Chunk { otherChunk.origins.forEach(origin => { this.origins.push(origin); }); - this.blocks.forEach(b => { + for(const b of this._blocks) { b.chunkReason = reason; - }); + } this.origins.forEach(origin => { if(!origin.reasons) { origin.reasons = [reason]; @@ -457,10 +457,8 @@ class Chunk { }); this._chunks.delete(otherChunk); this._chunks.delete(this); - for(const parentChunk of this._parents) { - if(parentChunk === otherChunk || parentChunk === this) - this._parents.delete(parentChunk); - } + this._parents.delete(otherChunk); + this._parents.delete(this); return true; } diff --git a/lib/ChunkTemplate.js b/lib/ChunkTemplate.js index 5c93d82a3..d48d8537d 100644 --- a/lib/ChunkTemplate.js +++ b/lib/ChunkTemplate.js @@ -40,7 +40,7 @@ module.exports = class ChunkTemplate extends Template { hash: chunk.hash }); - for(const module of chunk.modules.filter(m => m.type && m.type.startsWith("webassembly"))) { + for(const module of chunk.getModules().filter(m => m.type && m.type.startsWith("webassembly"))) { const filenameTemplate = outputOptions.webassemblyModuleFilename; result.push({ diff --git a/lib/Compilation.js b/lib/Compilation.js index 03c16803b..faa92f65d 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -1346,7 +1346,7 @@ class Compilation extends Tapable { hash.update(outputOptions.hashSalt); this.mainTemplate.updateHash(hash); this.chunkTemplate.updateHash(hash); - this.moduleTemplate.updateHash(hash); + Object.keys(this.moduleTemplates).sort().forEach(key => this.moduleTemplates[key].updateHash(hash)); this.children.forEach(child => hash.update(child.hash)); this.warnings.forEach(warning => hash.update(`${warning.message}`)); this.errors.forEach(error => hash.update(`${error.message}`)); @@ -1503,7 +1503,7 @@ Object.defineProperty(Compilation.prototype, "moduleTemplate", { return this.moduleTemplates.javascript; }, "Compilation.moduleTemplate: Use Compilation.moduleTemplates.javascript instead"), set: util.deprecate(function(value) { - this.moduleTemplate.javascript = value; + this.moduleTemplates.javascript = value; }, "Compilation.moduleTemplate: Use Compilation.moduleTemplates.javascript instead.") }); diff --git a/lib/EvalDevToolModulePlugin.js b/lib/EvalDevToolModulePlugin.js index 252b9d3f3..9d4341df6 100644 --- a/lib/EvalDevToolModulePlugin.js +++ b/lib/EvalDevToolModulePlugin.js @@ -14,7 +14,7 @@ class EvalDevToolModulePlugin { apply(compiler) { compiler.plugin("compilation", (compilation) => { - compilation.moduleTemplate.apply(new EvalDevToolModuleTemplatePlugin(this.sourceUrlComment, this.moduleFilenameTemplate)); + compilation.moduleTemplates.javascript.apply(new EvalDevToolModuleTemplatePlugin(this.sourceUrlComment, this.moduleFilenameTemplate)); }); } } diff --git a/lib/EvalSourceMapDevToolPlugin.js b/lib/EvalSourceMapDevToolPlugin.js index ecbabb0cf..4137ca085 100644 --- a/lib/EvalSourceMapDevToolPlugin.js +++ b/lib/EvalSourceMapDevToolPlugin.js @@ -24,7 +24,7 @@ class EvalSourceMapDevToolPlugin { const options = this.options; compiler.plugin("compilation", (compilation) => { new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation); - compilation.moduleTemplate.apply(new EvalSourceMapDevToolModuleTemplatePlugin(compilation, options)); + compilation.moduleTemplates.javascript.apply(new EvalSourceMapDevToolModuleTemplatePlugin(compilation, options)); }); } } diff --git a/lib/FunctionModulePlugin.js b/lib/FunctionModulePlugin.js index 5a3e53840..193fcc9e9 100644 --- a/lib/FunctionModulePlugin.js +++ b/lib/FunctionModulePlugin.js @@ -15,8 +15,8 @@ class FunctionModulePlugin { apply(compiler) { compiler.plugin("compilation", (compilation) => { - compilation.moduleTemplate.requestShortener = this.requestShortener || new RequestShortener(compiler.context); - compilation.moduleTemplate.apply(new FunctionModuleTemplatePlugin()); + compilation.moduleTemplates.javascript.requestShortener = this.requestShortener || new RequestShortener(compiler.context); + compilation.moduleTemplates.javascript.apply(new FunctionModuleTemplatePlugin()); }); } } diff --git a/lib/HotModuleReplacementPlugin.js b/lib/HotModuleReplacementPlugin.js index d6b41994a..0c33f69ca 100644 --- a/lib/HotModuleReplacementPlugin.js +++ b/lib/HotModuleReplacementPlugin.js @@ -119,7 +119,7 @@ module.exports = class HotModuleReplacementPlugin { }); const removedModules = records.chunkModuleIds[chunkId].filter(id => !allModules[id]); if(newModules.length > 0 || removedModules.length > 0) { - const source = hotUpdateChunkTemplate.render(chunkId, newModules, removedModules, compilation.hash, compilation.moduleTemplate, compilation.dependencyTemplates); + const source = hotUpdateChunkTemplate.render(chunkId, newModules, removedModules, compilation.hash, compilation.moduleTemplates.javascript, compilation.dependencyTemplates); const filename = compilation.getPath(hotUpdateChunkFilename, { hash: records.hash, chunk: currentChunk diff --git a/test/Validation.test.js b/test/Validation.test.js index 3429c4996..8af56e640 100644 --- a/test/Validation.test.js +++ b/test/Validation.test.js @@ -135,7 +135,7 @@ describe("Validation", () => { }, message: [ " - configuration.module.rules[0].oneOf[0] has an unknown property 'paser'. These properties are valid:", - " object { enforce?, exclude?, include?, issuer?, loader?, loaders?, oneOf?, options?, parser?, query?, resource?, resourceQuery?, compiler?, rules?, test?, use? }" + " object { enforce?, exclude?, include?, issuer?, loader?, loaders?, oneOf?, options?, parser?, query?, type?, resource?, resourceQuery?, compiler?, rules?, test?, use? }" ] }, { name: "additional key on root", diff --git a/test/statsCases/aggressive-splitting-entry/expected.txt b/test/statsCases/aggressive-splitting-entry/expected.txt index c6ba28e26..ff106a0e6 100644 --- a/test/statsCases/aggressive-splitting-entry/expected.txt +++ b/test/statsCases/aggressive-splitting-entry/expected.txt @@ -1,6 +1,6 @@ -Hash: 33cef25044998703062e33cef25044998703062e +Hash: 794ae6df9cb4748fbcd7794ae6df9cb4748fbcd7 Child fitting: - Hash: 33cef25044998703062e + Hash: 794ae6df9cb4748fbcd7 Time: Xms Asset Size Chunks Chunk Names 3b0abf784cffee9cdb84.js 2.29 kB 0 [emitted] @@ -25,7 +25,7 @@ Child fitting: > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [3] (webpack)/test/statsCases/aggressive-splitting-entry/e.js 899 bytes {6} [built] Child content-change: - Hash: 33cef25044998703062e + Hash: 794ae6df9cb4748fbcd7 Time: Xms Asset Size Chunks Chunk Names 3b0abf784cffee9cdb84.js 2.29 kB 0 [emitted] diff --git a/test/statsCases/aggressive-splitting-on-demand/expected.txt b/test/statsCases/aggressive-splitting-on-demand/expected.txt index a9f9ce5d4..57de94911 100644 --- a/test/statsCases/aggressive-splitting-on-demand/expected.txt +++ b/test/statsCases/aggressive-splitting-on-demand/expected.txt @@ -1,4 +1,4 @@ -Hash: d325d091bb03d9d0af86 +Hash: b9000d018fcafbe7adf7 Time: Xms Asset Size Chunks Chunk Names 1744d4ad4296f5fa250c.js 2.01 kB 0 [emitted] diff --git a/test/statsCases/chunks/expected.txt b/test/statsCases/chunks/expected.txt index 616effcc3..858e05dd8 100644 --- a/test/statsCases/chunks/expected.txt +++ b/test/statsCases/chunks/expected.txt @@ -1,4 +1,4 @@ -Hash: 5d4f33a3de57af10c4da +Hash: acd61a6f698d13599727 Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 288 bytes 0 [emitted] diff --git a/test/statsCases/color-disabled/expected.txt b/test/statsCases/color-disabled/expected.txt index cce608d6e..5f4668bd6 100644 --- a/test/statsCases/color-disabled/expected.txt +++ b/test/statsCases/color-disabled/expected.txt @@ -1,4 +1,4 @@ -Hash: 89eab1616a5ad143a5a2 +Hash: 46a7ae6dc4165f8abc60 Time: Xms Asset Size Chunks Chunk Names main.js 2.69 kB 0 [emitted] main diff --git a/test/statsCases/color-enabled-custom/expected.txt b/test/statsCases/color-enabled-custom/expected.txt index cc33d795c..872a24ecd 100644 --- a/test/statsCases/color-enabled-custom/expected.txt +++ b/test/statsCases/color-enabled-custom/expected.txt @@ -1,4 +1,4 @@ -Hash: 89eab1616a5ad143a5a2 +Hash: 46a7ae6dc4165f8abc60 Time: Xms Asset Size Chunks Chunk Names main.js 2.69 kB 0 [emitted] main diff --git a/test/statsCases/color-enabled/expected.txt b/test/statsCases/color-enabled/expected.txt index 8ada6e728..fb740b5bf 100644 --- a/test/statsCases/color-enabled/expected.txt +++ b/test/statsCases/color-enabled/expected.txt @@ -1,4 +1,4 @@ -Hash: 89eab1616a5ad143a5a2 +Hash: 46a7ae6dc4165f8abc60 Time: Xms Asset Size Chunks Chunk Names main.js 2.69 kB 0 [emitted] main diff --git a/test/statsCases/commons-chunk-min-size-0/expected.txt b/test/statsCases/commons-chunk-min-size-0/expected.txt index d0748d001..bac7ecaa6 100644 --- a/test/statsCases/commons-chunk-min-size-0/expected.txt +++ b/test/statsCases/commons-chunk-min-size-0/expected.txt @@ -1,4 +1,4 @@ -Hash: 39988cfdd8d15a084058 +Hash: 555ed68441b4e61480de Time: Xms Asset Size Chunks Chunk Names entry-1.js 81 bytes 0 [emitted] entry-1 diff --git a/test/statsCases/commons-chunk-min-size-Infinity/expected.txt b/test/statsCases/commons-chunk-min-size-Infinity/expected.txt index d19f0fca5..210c946f3 100644 --- a/test/statsCases/commons-chunk-min-size-Infinity/expected.txt +++ b/test/statsCases/commons-chunk-min-size-Infinity/expected.txt @@ -1,4 +1,4 @@ -Hash: 6478d38b6030870e0766 +Hash: 770feff5bea289bd08f4 Time: Xms Asset Size Chunks Chunk Names entry-1.js 3.32 kB 0 [emitted] entry-1 diff --git a/test/statsCases/commons-plugin-issue-4980/expected.txt b/test/statsCases/commons-plugin-issue-4980/expected.txt index 1bb9886db..858c70958 100644 --- a/test/statsCases/commons-plugin-issue-4980/expected.txt +++ b/test/statsCases/commons-plugin-issue-4980/expected.txt @@ -1,6 +1,6 @@ -Hash: acd1f75abe608dba57c70b1ed992624bd4ceefaa +Hash: c107a06e25bb732bf473181ecf9358e3cc7f45e7 Child - Hash: acd1f75abe608dba57c7 + Hash: c107a06e25bb732bf473 Time: Xms Asset Size Chunks Chunk Names app.js 1.32 kB 0 [emitted] app @@ -11,7 +11,7 @@ Child [./submodule-a.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-a.js 59 bytes {0} [built] [./submodule-b.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-b.js 59 bytes {0} [built] Child - Hash: 0b1ed992624bd4ceefaa + Hash: 181ecf9358e3cc7f45e7 Time: Xms Asset Size Chunks Chunk Names app.js 1.37 kB 0 [emitted] app diff --git a/test/statsCases/define-plugin/expected.txt b/test/statsCases/define-plugin/expected.txt index 66bf59863..357600191 100644 --- a/test/statsCases/define-plugin/expected.txt +++ b/test/statsCases/define-plugin/expected.txt @@ -1,12 +1,12 @@ -Hash: 8bb1a50077aee68e988a597c54a008106ce8b531 +Hash: 5740106240ac3936376e1d8c50bebd858f67edaf Child - Hash: 8bb1a50077aee68e988a + Hash: 5740106240ac3936376e Time: Xms Asset Size Chunks Chunk Names main.js 2.73 kB 0 [emitted] main [0] (webpack)/test/statsCases/define-plugin/index.js 24 bytes {0} [built] Child - Hash: 597c54a008106ce8b531 + Hash: 1d8c50bebd858f67edaf Time: Xms Asset Size Chunks Chunk Names main.js 2.73 kB 0 [emitted] main diff --git a/test/statsCases/exclude-with-loader/expected.txt b/test/statsCases/exclude-with-loader/expected.txt index fba1315ac..a36b319f9 100644 --- a/test/statsCases/exclude-with-loader/expected.txt +++ b/test/statsCases/exclude-with-loader/expected.txt @@ -1,4 +1,4 @@ -Hash: 8c02b98c18c91aa84690 +Hash: 42d4b473056b7c1c9f38 Time: Xms Asset Size Chunks Chunk Names bundle.js 3.14 kB 0 [emitted] main diff --git a/test/statsCases/external/expected.txt b/test/statsCases/external/expected.txt index 2e8ee8ea0..7ed996f36 100644 --- a/test/statsCases/external/expected.txt +++ b/test/statsCases/external/expected.txt @@ -1,4 +1,4 @@ -Hash: 36483aa6c04f6ef13570 +Hash: 6d4c276e12a806fa09b1 Time: Xms Asset Size Chunks Chunk Names main.js 2.82 kB 0 [emitted] main diff --git a/test/statsCases/filter-warnings/expected.txt b/test/statsCases/filter-warnings/expected.txt index fe3f5b5fe..06c595861 100644 --- a/test/statsCases/filter-warnings/expected.txt +++ b/test/statsCases/filter-warnings/expected.txt @@ -1,12 +1,12 @@ -Hash: 0f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a000f94f7deae4c04d56a00 +Hash: 19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -19,43 +19,43 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -68,13 +68,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -87,13 +87,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -106,13 +106,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -125,13 +125,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -144,13 +144,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: 0f94f7deae4c04d56a00 + Hash: 19b74c5b0289d95eca2a Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 0f94f7deae4c04d56a00:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] diff --git a/test/statsCases/import-context-filter/expected.txt b/test/statsCases/import-context-filter/expected.txt index 96817f3ab..e34b3533a 100644 --- a/test/statsCases/import-context-filter/expected.txt +++ b/test/statsCases/import-context-filter/expected.txt @@ -1,4 +1,4 @@ -Hash: 7e892e0fb490714c0a3a +Hash: 6c4d6f1ed0a9a90ec93e Time: Xms Asset Size Chunks Chunk Names 0.js 339 bytes 0 [emitted] diff --git a/test/statsCases/import-weak/expected.txt b/test/statsCases/import-weak/expected.txt index e094ffedf..aeca2c4c0 100644 --- a/test/statsCases/import-weak/expected.txt +++ b/test/statsCases/import-weak/expected.txt @@ -1,4 +1,4 @@ -Hash: 8ac1d37f7cee7ab1016d +Hash: a6cd1e3ec94a80959c78 Time: Xms Asset Size Chunks Chunk Names 0.js 149 bytes 0 [emitted] diff --git a/test/statsCases/limit-chunk-count-plugin/expected.txt b/test/statsCases/limit-chunk-count-plugin/expected.txt index ea26f54c4..54bf42376 100644 --- a/test/statsCases/limit-chunk-count-plugin/expected.txt +++ b/test/statsCases/limit-chunk-count-plugin/expected.txt @@ -1,6 +1,6 @@ -Hash: d3b4d57e725fbf0c40c40384242efaa60e350cb2a8afa85f69ff21e19fb4d9c7396cbd5b5cf16e63 +Hash: 468570e5397bec3aa1424f36dcb9c59adabdac76a4dfe141df617e196eba275cb1ecca589a656bdb Child - Hash: d3b4d57e725fbf0c40c4 + Hash: 468570e5397bec3aa142 Time: Xms Asset Size Chunks Chunk Names bundle.js 3.61 kB 0 [emitted] main @@ -12,7 +12,7 @@ Child [4] (webpack)/test/statsCases/limit-chunk-count-plugin/d.js 22 bytes {0} [built] [5] (webpack)/test/statsCases/limit-chunk-count-plugin/e.js 22 bytes {0} [built] Child - Hash: 0384242efaa60e350cb2 + Hash: 4f36dcb9c59adabdac76 Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 651 bytes 0 [emitted] @@ -26,7 +26,7 @@ Child chunk {1} bundle.js (main) 73 bytes [entry] [rendered] [0] (webpack)/test/statsCases/limit-chunk-count-plugin/index.js 73 bytes {1} [built] Child - Hash: a8afa85f69ff21e19fb4 + Hash: a4dfe141df617e196eba Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 504 bytes 0 [emitted] @@ -42,7 +42,7 @@ Child chunk {2} bundle.js (main) 73 bytes [entry] [rendered] [0] (webpack)/test/statsCases/limit-chunk-count-plugin/index.js 73 bytes {2} [built] Child - Hash: d9c7396cbd5b5cf16e63 + Hash: 275cb1ecca589a656bdb Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 232 bytes 0 [emitted] diff --git a/test/statsCases/max-modules-default/expected.txt b/test/statsCases/max-modules-default/expected.txt index 3dce37f8e..3ff08548b 100644 --- a/test/statsCases/max-modules-default/expected.txt +++ b/test/statsCases/max-modules-default/expected.txt @@ -1,4 +1,4 @@ -Hash: 7a772243f1745ecb230f +Hash: 25e5bbed2cc755384806 Time: Xms Asset Size Chunks Chunk Names main.js 6 kB 0 [emitted] main diff --git a/test/statsCases/max-modules/expected.txt b/test/statsCases/max-modules/expected.txt index 81ec06aff..870f5764e 100644 --- a/test/statsCases/max-modules/expected.txt +++ b/test/statsCases/max-modules/expected.txt @@ -1,4 +1,4 @@ -Hash: 7a772243f1745ecb230f +Hash: 25e5bbed2cc755384806 Time: Xms Asset Size Chunks Chunk Names main.js 6 kB 0 [emitted] main diff --git a/test/statsCases/named-chunks-plugin-async/expected.txt b/test/statsCases/named-chunks-plugin-async/expected.txt index dd5e26394..a2d467c5c 100644 --- a/test/statsCases/named-chunks-plugin-async/expected.txt +++ b/test/statsCases/named-chunks-plugin-async/expected.txt @@ -1,4 +1,4 @@ -Hash: cd277029f12cdb352584 +Hash: e569776cf2d7bb15f549 Time: Xms Asset Size Chunks Chunk Names chunk-containing-__a_js.js 316 bytes chunk-containing-__a_js [emitted] diff --git a/test/statsCases/named-chunks-plugin/expected.txt b/test/statsCases/named-chunks-plugin/expected.txt index 1e410da72..257836f00 100644 --- a/test/statsCases/named-chunks-plugin/expected.txt +++ b/test/statsCases/named-chunks-plugin/expected.txt @@ -1,4 +1,4 @@ -Hash: b3622b84af67b4db881c +Hash: a1229254603619424568 Time: Xms Asset Size Chunks Chunk Names entry.js 615 bytes entry [emitted] entry diff --git a/test/statsCases/optimize-chunks/expected.txt b/test/statsCases/optimize-chunks/expected.txt index 1f4df5d10..66b1d32bc 100644 --- a/test/statsCases/optimize-chunks/expected.txt +++ b/test/statsCases/optimize-chunks/expected.txt @@ -1,4 +1,4 @@ -Hash: bfbf50a57f37361544f4 +Hash: 7c00c9ec24322c092eb7 Time: Xms Asset Size Chunks Chunk Names 0.js 281 bytes 0 [emitted] cir1 diff --git a/test/statsCases/preset-detailed/expected.txt b/test/statsCases/preset-detailed/expected.txt index fe4b0c16d..3cd5880ef 100644 --- a/test/statsCases/preset-detailed/expected.txt +++ b/test/statsCases/preset-detailed/expected.txt @@ -1,4 +1,4 @@ -Hash: ed693a88a68d2e3a365a +Hash: 7b6e615d7bd302eb9c50 Time: Xms Asset Size Chunks Chunk Names 0.js 288 bytes 0 [emitted] diff --git a/test/statsCases/preset-normal/expected.txt b/test/statsCases/preset-normal/expected.txt index eb8be625f..43e370123 100644 --- a/test/statsCases/preset-normal/expected.txt +++ b/test/statsCases/preset-normal/expected.txt @@ -1,4 +1,4 @@ -Hash: ed693a88a68d2e3a365a +Hash: 7b6e615d7bd302eb9c50 Time: Xms Asset Size Chunks Chunk Names 0.js 288 bytes 0 [emitted] diff --git a/test/statsCases/preset-verbose/expected.txt b/test/statsCases/preset-verbose/expected.txt index df6a6124a..f69043b6c 100644 --- a/test/statsCases/preset-verbose/expected.txt +++ b/test/statsCases/preset-verbose/expected.txt @@ -1,4 +1,4 @@ -Hash: ed693a88a68d2e3a365a +Hash: 7b6e615d7bd302eb9c50 Time: Xms Asset Size Chunks Chunk Names 0.js 288 bytes 0 [emitted] diff --git a/test/statsCases/resolve-plugin-context/expected.txt b/test/statsCases/resolve-plugin-context/expected.txt index 074eaf443..cf9d33a95 100644 --- a/test/statsCases/resolve-plugin-context/expected.txt +++ b/test/statsCases/resolve-plugin-context/expected.txt @@ -1,4 +1,4 @@ -Hash: 77d7803a0e5cab4bf94e +Hash: b28ec09e6f09816bd407 Time: Xms Asset Size Chunks Chunk Names bundle.js 3.1 kB 0 [emitted] main diff --git a/test/statsCases/reverse-sort-modules/expected.txt b/test/statsCases/reverse-sort-modules/expected.txt index 41e2ce736..f6fd12e6c 100644 --- a/test/statsCases/reverse-sort-modules/expected.txt +++ b/test/statsCases/reverse-sort-modules/expected.txt @@ -1,4 +1,4 @@ -Hash: 7a772243f1745ecb230f +Hash: 25e5bbed2cc755384806 Time: Xms Asset Size Chunks Chunk Names main.js 6 kB 0 [emitted] main diff --git a/test/statsCases/scope-hoisting-multi/expected.txt b/test/statsCases/scope-hoisting-multi/expected.txt index 31c65585f..2b0f5002d 100644 --- a/test/statsCases/scope-hoisting-multi/expected.txt +++ b/test/statsCases/scope-hoisting-multi/expected.txt @@ -1,6 +1,6 @@ -Hash: 25da10e7d3d4121b1f85d6f6aa5f20b982e1aff9 +Hash: 8619511e846dc23eb000e02721a227f38dff757d Child - Hash: 25da10e7d3d4121b1f85 + Hash: 8619511e846dc23eb000 Time: Xms [0] (webpack)/test/statsCases/scope-hoisting-multi/common2.js 25 bytes {3} {4} [built] [1] (webpack)/test/statsCases/scope-hoisting-multi/common_lazy_shared.js 25 bytes {0} {1} {2} [built] @@ -14,7 +14,7 @@ Child [9] (webpack)/test/statsCases/scope-hoisting-multi/second.js 177 bytes {4} [built] [10] (webpack)/test/statsCases/scope-hoisting-multi/lazy_second.js 55 bytes {1} [built] Child - Hash: d6f6aa5f20b982e1aff9 + Hash: e02721a227f38dff757d Time: Xms [0] (webpack)/test/statsCases/scope-hoisting-multi/common_lazy_shared.js 25 bytes {0} {1} {2} [built] [1] (webpack)/test/statsCases/scope-hoisting-multi/vendor.js 25 bytes {5} [built] diff --git a/test/statsCases/separate-css-bundle/expected.txt b/test/statsCases/separate-css-bundle/expected.txt index 8fabce7be..60af3a771 100644 --- a/test/statsCases/separate-css-bundle/expected.txt +++ b/test/statsCases/separate-css-bundle/expected.txt @@ -1,6 +1,6 @@ -Hash: da16790d5db6d9935b08cf1165d0e30fbaab2ce7 +Hash: 9b8205a049992bc9783bb1a58f5b0b09d9dd1037 Child - Hash: da16790d5db6d9935b08 + Hash: 9b8205a049992bc9783b Time: Xms Asset Size Chunks Chunk Names fd4c2ca1440010a55587.js 2.83 kB 0 [emitted] main @@ -15,7 +15,7 @@ Child [0] (webpack)/node_modules/css-loader!(webpack)/test/statsCases/separate-css-bundle/a/file.css 199 bytes {0} [built] [1] (webpack)/node_modules/css-loader/lib/css-base.js 2.26 kB {0} [built] Child - Hash: cf1165d0e30fbaab2ce7 + Hash: b1a58f5b0b09d9dd1037 Time: Xms Asset Size Chunks Chunk Names fd4c2ca1440010a55587.js 2.83 kB 0 [emitted] main diff --git a/test/statsCases/simple-more-info/expected.txt b/test/statsCases/simple-more-info/expected.txt index ca953f934..3368a6345 100644 --- a/test/statsCases/simple-more-info/expected.txt +++ b/test/statsCases/simple-more-info/expected.txt @@ -1,4 +1,4 @@ -Hash: df82344a911f69966ecc +Hash: 2e10a5e30d58364c392c Time: Xms Asset Size Chunks Chunk Names bundle.js 2.69 kB 0 [emitted] main diff --git a/test/statsCases/simple/expected.txt b/test/statsCases/simple/expected.txt index d00173ca2..81f7f1400 100644 --- a/test/statsCases/simple/expected.txt +++ b/test/statsCases/simple/expected.txt @@ -1,4 +1,4 @@ -Hash: df82344a911f69966ecc +Hash: 2e10a5e30d58364c392c Time: Xms Asset Size Chunks Chunk Names bundle.js 2.69 kB 0 [emitted] main diff --git a/test/statsCases/tree-shaking/expected.txt b/test/statsCases/tree-shaking/expected.txt index a25f7374a..cac6798fd 100644 --- a/test/statsCases/tree-shaking/expected.txt +++ b/test/statsCases/tree-shaking/expected.txt @@ -1,4 +1,4 @@ -Hash: 762e00600c7e7e1ad161 +Hash: 86e656e04ad1845b5137 Time: Xms Asset Size Chunks Chunk Names bundle.js 7.25 kB 0 [emitted] main diff --git a/test/statsCases/warnings-uglifyjs/expected.txt b/test/statsCases/warnings-uglifyjs/expected.txt index 06b64ce3c..bc216f8e0 100644 --- a/test/statsCases/warnings-uglifyjs/expected.txt +++ b/test/statsCases/warnings-uglifyjs/expected.txt @@ -1,4 +1,4 @@ -Hash: 54b9e9a2850ab55d7e8f +Hash: 10e3e5dbac353b4cd892 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main From 00f2b5ede76e43c7e1c4b8791985cac6476506cd Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sat, 11 Nov 2017 18:48:29 +0100 Subject: [PATCH 30/85] advanced module type refactoring added json type .mjs default to javascript/esm type adjusted parser plugins to react on module type --- lib/APIPlugin.js | 2 +- lib/CompatibilityPlugin.js | 16 +-- lib/ConstPlugin.js | 2 +- lib/DefinePlugin.js | 2 +- lib/ExtendedAPIPlugin.js | 2 +- lib/FunctionModuleTemplatePlugin.js | 15 ++- lib/HotModuleReplacementPlugin.js | 3 +- lib/JavascriptModulesPlugin.js | 6 +- lib/JsonModulesPlugin.js | 32 +++++ lib/JsonParser.js | 27 +++++ lib/LibraryTemplatePlugin.js | 2 +- lib/Module.js | 12 +- lib/ModuleTemplate.js | 3 +- lib/NodeStuffPlugin.js | 2 +- lib/NormalModule.js | 2 +- lib/NormalModuleFactory.js | 12 +- lib/ProvidePlugin.js | 2 +- lib/RequireJsStuffPlugin.js | 2 +- lib/Template.js | 4 +- lib/UseStrictPlugin.js | 2 +- lib/WebAssemblyModulesPlugin.js | 4 +- lib/WebpackOptionsApply.js | 15 ++- lib/WebpackOptionsDefaulter.js | 2 +- lib/dependencies/AMDPlugin.js | 2 +- ...AMDRequireDependenciesBlockParserPlugin.js | 4 +- lib/dependencies/CommonJsPlugin.js | 2 +- .../HarmonyCompatibilityDependency.js | 2 +- .../HarmonyDetectionParserPlugin.js | 5 +- .../HarmonyExportExpressionDependency.js | 2 +- ...armonyExportImportedSpecifierDependency.js | 6 +- .../HarmonyExportSpecifierDependency.js | 2 +- lib/dependencies/HarmonyModulesPlugin.js | 2 +- lib/dependencies/ImportPlugin.js | 2 +- lib/dependencies/RequireContextPlugin.js | 2 +- lib/dependencies/RequireEnsurePlugin.js | 2 +- lib/dependencies/RequireIncludePlugin.js | 2 +- lib/dependencies/SystemPlugin.js | 2 +- lib/node/NodeMainTemplatePlugin.js | 113 ++++++++++-------- lib/node/NodeSourcePlugin.js | 2 +- .../ReadFileCompileWasmMainTemplatePlugin.js | 83 +++++++++++++ ...ReadFileCompileWasmModuleTemplatePlugin.js | 39 ++++++ lib/node/ReadFileCompileWasmTemplatePlugin.js | 19 +++ lib/optimize/ConcatenatedModule.js | 10 +- lib/optimize/ModuleConcatenationPlugin.js | 2 +- .../FetchCompileWasmMainTemplatePlugin.js | 47 ++++---- .../FetchCompileWasmModuleTemplatePlugin.js | 6 +- .../FetchCompileWasmTemplatePlugin.js | 0 lib/{ => web}/JsonpChunkTemplatePlugin.js | 0 .../JsonpExportMainTemplatePlugin.js | 0 .../JsonpHotUpdateChunkTemplatePlugin.js | 0 lib/{ => web}/JsonpMainTemplate.runtime.js | 0 lib/{ => web}/JsonpMainTemplatePlugin.js | 7 +- lib/{ => web}/JsonpTemplatePlugin.js | 0 lib/webpack.js | 9 +- package.json | 2 +- schemas/webpackOptionsSchema.json | 1 + test/ExternalModule.unittest.js | 8 +- .../JsonpExportMainTemplatePlugin.unittest.js | 2 +- test/NormalModule.unittest.js | 4 + test/TestCases.test.js | 6 +- test/cases/loaders/issue-2299/loader/index.js | 4 +- test/cases/mjs/esm-by-default/index.mjs | 8 ++ test/cases/wasm/simple/index.js | 7 ++ test/cases/wasm/simple/module.js | 5 + test/cases/wasm/simple/wasm.wasm | Bin 0 -> 63 bytes .../aggressive-splitting-entry/expected.txt | 18 +-- .../expected.txt | 8 +- test/statsCases/chunks/expected.txt | 4 +- test/statsCases/color-disabled/expected.txt | 2 +- .../color-enabled-custom/expected.txt | 2 +- test/statsCases/color-enabled/expected.txt | 2 +- .../commons-chunk-min-size-0/expected.txt | 4 +- .../expected.txt | 2 +- .../expected.txt | 10 +- .../commons-plugin-issue-4980/expected.txt | 10 +- test/statsCases/define-plugin/expected.txt | 6 +- .../exclude-with-loader/expected.txt | 4 +- test/statsCases/external/expected.txt | 2 +- test/statsCases/filter-warnings/expected.txt | 42 +++---- .../import-context-filter/expected.txt | 4 +- test/statsCases/import-weak/expected.txt | 4 +- .../limit-chunk-count-plugin/expected.txt | 16 +-- .../max-modules-default/expected.txt | 2 +- test/statsCases/max-modules/expected.txt | 2 +- .../module-deduplication-named/expected.txt | 6 +- .../module-deduplication/expected.txt | 6 +- .../named-chunks-plugin-async/expected.txt | 4 +- .../named-chunks-plugin/expected.txt | 4 +- test/statsCases/optimize-chunks/expected.txt | 4 +- test/statsCases/preset-detailed/expected.txt | 4 +- test/statsCases/preset-normal/expected.txt | 4 +- test/statsCases/preset-verbose/expected.txt | 4 +- .../resolve-plugin-context/expected.txt | 2 +- .../reverse-sort-modules/expected.txt | 2 +- .../scope-hoisting-multi/expected.txt | 6 +- .../separate-css-bundle/expected.txt | 10 +- test/statsCases/simple-more-info/expected.txt | 2 +- test/statsCases/simple/expected.txt | 2 +- test/statsCases/tree-shaking/expected.txt | 2 +- .../statsCases/warnings-uglifyjs/expected.txt | 2 +- yarn.lock | 2 +- 101 files changed, 537 insertions(+), 265 deletions(-) create mode 100644 lib/JsonModulesPlugin.js create mode 100644 lib/JsonParser.js create mode 100644 lib/node/ReadFileCompileWasmMainTemplatePlugin.js create mode 100644 lib/node/ReadFileCompileWasmModuleTemplatePlugin.js create mode 100644 lib/node/ReadFileCompileWasmTemplatePlugin.js rename lib/{ => web}/FetchCompileWasmMainTemplatePlugin.js (59%) rename lib/{ => web}/FetchCompileWasmModuleTemplatePlugin.js (88%) rename lib/{ => web}/FetchCompileWasmTemplatePlugin.js (100%) rename lib/{ => web}/JsonpChunkTemplatePlugin.js (100%) rename lib/{ => web}/JsonpExportMainTemplatePlugin.js (100%) rename lib/{ => web}/JsonpHotUpdateChunkTemplatePlugin.js (100%) rename lib/{ => web}/JsonpMainTemplate.runtime.js (100%) rename lib/{ => web}/JsonpMainTemplatePlugin.js (98%) rename lib/{ => web}/JsonpTemplatePlugin.js (100%) create mode 100644 test/cases/mjs/esm-by-default/index.mjs create mode 100644 test/cases/wasm/simple/index.js create mode 100644 test/cases/wasm/simple/module.js create mode 100644 test/cases/wasm/simple/wasm.wasm diff --git a/lib/APIPlugin.js b/lib/APIPlugin.js index 6456ad85a..19791d08e 100644 --- a/lib/APIPlugin.js +++ b/lib/APIPlugin.js @@ -32,7 +32,7 @@ class APIPlugin { compilation.dependencyFactories.set(ConstDependency, new NullFactory()); compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); - params.normalModuleFactory.plugin("parser", parser => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic", "parser javascript/esm"], parser => { Object.keys(REPLACEMENTS).forEach(key => { parser.plugin(`expression ${key}`, ParserHelpers.toConstantDependency(REPLACEMENTS[key])); parser.plugin(`evaluate typeof ${key}`, ParserHelpers.evaluateToString(REPLACEMENT_TYPES[key])); diff --git a/lib/CompatibilityPlugin.js b/lib/CompatibilityPlugin.js index c6fdd890c..d171f3b2c 100644 --- a/lib/CompatibilityPlugin.js +++ b/lib/CompatibilityPlugin.js @@ -8,9 +8,6 @@ const ConstDependency = require("./dependencies/ConstDependency"); const NullFactory = require("./NullFactory"); -const jsonLoaderPath = require.resolve("json-loader"); -const matchJson = /\.json$/i; - class CompatibilityPlugin { apply(compiler) { @@ -18,7 +15,7 @@ class CompatibilityPlugin { compilation.dependencyFactories.set(ConstDependency, new NullFactory()); compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin("parser javascript/auto", (parser, parserOptions) => { if(typeof parserOptions.browserify !== "undefined" && !parserOptions.browserify) return; @@ -40,17 +37,6 @@ class CompatibilityPlugin { return true; }); }); - - params.normalModuleFactory.plugin("after-resolve", (data, done) => { - // if this is a json file and there are no loaders active, we use the json-loader in order to avoid parse errors - // @see https://github.com/webpack/webpack/issues/3363 - if(matchJson.test(data.request) && data.loaders.length === 0) { - data.loaders.push({ - loader: jsonLoaderPath - }); - } - done(null, data); - }); }); } } diff --git a/lib/ConstPlugin.js b/lib/ConstPlugin.js index 294be09a7..f7c075813 100644 --- a/lib/ConstPlugin.js +++ b/lib/ConstPlugin.js @@ -18,7 +18,7 @@ class ConstPlugin { compilation.dependencyFactories.set(ConstDependency, new NullFactory()); compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); - params.normalModuleFactory.plugin("parser", parser => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic", "parser javascript/esm"], parser => { parser.plugin("statement if", statement => { const param = parser.evaluateExpression(statement.test); const bool = param.asBool(); diff --git a/lib/DefinePlugin.js b/lib/DefinePlugin.js index 9f03f6c4d..7ba0ce625 100644 --- a/lib/DefinePlugin.js +++ b/lib/DefinePlugin.js @@ -36,7 +36,7 @@ class DefinePlugin { compilation.dependencyFactories.set(ConstDependency, new NullFactory()); compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); - params.normalModuleFactory.plugin("parser", (parser) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic", "parser javascript/esm"], (parser) => { const walkDefinitions = (definitions, prefix) => { Object.keys(definitions).forEach((key) => { const code = definitions[key]; diff --git a/lib/ExtendedAPIPlugin.js b/lib/ExtendedAPIPlugin.js index b3df2ba6f..895a5080f 100644 --- a/lib/ExtendedAPIPlugin.js +++ b/lib/ExtendedAPIPlugin.js @@ -36,7 +36,7 @@ class ExtendedAPIPlugin { }); mainTemplate.plugin("global-hash", () => true); - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic", "parser javascript/esm"], (parser, parserOptions) => { Object.keys(REPLACEMENTS).forEach(key => { parser.plugin(`expression ${key}`, ParserHelpers.toConstantDependency(REPLACEMENTS[key])); parser.plugin(`evaluate typeof ${key}`, ParserHelpers.evaluateToString(REPLACEMENT_TYPES[key])); diff --git a/lib/FunctionModuleTemplatePlugin.js b/lib/FunctionModuleTemplatePlugin.js index a83be52e8..0507884d2 100644 --- a/lib/FunctionModuleTemplatePlugin.js +++ b/lib/FunctionModuleTemplatePlugin.js @@ -11,12 +11,19 @@ class FunctionModuleTemplatePlugin { apply(moduleTemplate) { moduleTemplate.plugin("render", (moduleSource, module) => { const source = new ConcatSource(); - const defaultArguments = [module.moduleArgument || "module", module.exportsArgument || "exports"]; + const args = [module.moduleArgument]; // TODO remove HACK checking type for javascript - if(!module.type || !module.type.startsWith("javascript") || (module.arguments && module.arguments.length !== 0) || module.hasDependencies(d => d.requireWebpackRequire !== false)) { - defaultArguments.push("__webpack_require__"); + if(module.type && module.type.startsWith("javascript")) { + args.push(module.exportsArgument); + if(module.hasDependencies(d => d.requireWebpackRequire !== false)) { + args.push("__webpack_require__"); + } + } else if(module.type && module.type.startsWith("json")) { + // no additional arguments needed + } else { + args.push(module.exportsArgument, "__webpack_require__"); } - source.add("/***/ (function(" + defaultArguments.concat(module.arguments || []).join(", ") + ") {\n\n"); + source.add("/***/ (function(" + args.join(", ") + ") {\n\n"); if(module.strict) source.add("\"use strict\";\n"); source.add(moduleSource); source.add("\n\n/***/ })"); diff --git a/lib/HotModuleReplacementPlugin.js b/lib/HotModuleReplacementPlugin.js index 0c33f69ca..eb7c2e0a1 100644 --- a/lib/HotModuleReplacementPlugin.js +++ b/lib/HotModuleReplacementPlugin.js @@ -190,7 +190,8 @@ module.exports = class HotModuleReplacementPlugin { ]); }); - normalModuleFactory.plugin("parser", (parser, parserOptions) => { + // TODO add HMR support for javascript/esm + normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic"], (parser, parserOptions) => { parser.plugin("expression __webpack_hash__", ParserHelpers.toConstantDependency("__webpack_require__.h()")); parser.plugin("evaluate typeof __webpack_hash__", ParserHelpers.evaluateToString("string")); parser.plugin("evaluate Identifier module.hot", expr => { diff --git a/lib/JavascriptModulesPlugin.js b/lib/JavascriptModulesPlugin.js index 992c5d71a..39b711cbf 100644 --- a/lib/JavascriptModulesPlugin.js +++ b/lib/JavascriptModulesPlugin.js @@ -8,8 +8,10 @@ const Parser = require("./Parser"); class JavascriptModulesPlugin { apply(compiler) { - compiler.plugin("compilation", (compilation, { normalModuleFactory }) => { - normalModuleFactory.plugin(["create-parser javascript/auto", "create-parser javascript/esm"], () => { + compiler.plugin("compilation", (compilation, { + normalModuleFactory + }) => { + normalModuleFactory.plugin(["create-parser javascript/auto", "create-parser javascript/dynamic", "create-parser javascript/esm"], () => { return new Parser(); }); }); diff --git a/lib/JsonModulesPlugin.js b/lib/JsonModulesPlugin.js new file mode 100644 index 000000000..7c513cdd7 --- /dev/null +++ b/lib/JsonModulesPlugin.js @@ -0,0 +1,32 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const JsonParser = require("./JsonParser"); +const ConcatSource = require("webpack-sources").ConcatSource; + +class JsonModulesPlugin { + apply(compiler) { + compiler.plugin("compilation", (compilation, { + normalModuleFactory + }) => { + normalModuleFactory.plugin("create-parser json", () => { + return new JsonParser(); + }); + compilation.moduleTemplates.javascript.plugin("content", (moduleSource, module) => { + if(module.type && module.type.startsWith("json")) { + const source = new ConcatSource(); + source.add(`${module.moduleArgument}.exports = `); + source.add(moduleSource); + return source; + } else { + return moduleSource; + } + }); + }); + } +} + +module.exports = JsonModulesPlugin; diff --git a/lib/JsonParser.js b/lib/JsonParser.js new file mode 100644 index 000000000..4d2467320 --- /dev/null +++ b/lib/JsonParser.js @@ -0,0 +1,27 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const ConstDependency = require("./dependencies/ConstDependency"); + +class JsonParser { + constructor(options) { + this.options = options; + } + + parse(source, state) { + const regExp = /\u2028|\u2029/g; // invalid in JavaScript but valid JSON + let match = regExp.exec(source); + while(match) { + const escaped = match[0] === "\u2028" ? "\\u2028" : "\\u2029"; + const dep = new ConstDependency(escaped, [match.index, match.index]); + state.module.addDependency(dep); + match = regExp.exec(source); + } + return state; + } +} + +module.exports = JsonParser; diff --git a/lib/LibraryTemplatePlugin.js b/lib/LibraryTemplatePlugin.js index 93cb6b07b..73cb4072c 100644 --- a/lib/LibraryTemplatePlugin.js +++ b/lib/LibraryTemplatePlugin.js @@ -79,7 +79,7 @@ class LibraryTemplatePlugin { })); break; case "jsonp": - var JsonpExportMainTemplatePlugin = require("./JsonpExportMainTemplatePlugin"); + var JsonpExportMainTemplatePlugin = require("./web/JsonpExportMainTemplatePlugin"); compilation.apply(new JsonpExportMainTemplatePlugin(this.name)); break; default: diff --git a/lib/Module.js b/lib/Module.js index ccb8dd5b4..e6aba1249 100644 --- a/lib/Module.js +++ b/lib/Module.js @@ -59,8 +59,8 @@ class Module extends DependenciesBlock { this.errors = []; this.strict = false; this.meta = {}; - this.exportsArgument = undefined; - this.moduleArgument = undefined; + this.exportsArgument = "exports"; + this.moduleArgument = "module"; this.assets = null; this.fileDependencies = undefined; this.contextDependencies = undefined; @@ -261,6 +261,14 @@ class Module extends DependenciesBlock { unbuild() { this.disconnect(); } + + get arguments() { + throw new Error("Module.arguments was removed, there is no replacement."); + } + + set arguments(value) { + throw new Error("Module.arguments was removed, there is no replacement."); + } } Object.defineProperty(Module.prototype, "entry", { diff --git a/lib/ModuleTemplate.js b/lib/ModuleTemplate.js index 63370d856..90c435300 100644 --- a/lib/ModuleTemplate.js +++ b/lib/ModuleTemplate.js @@ -13,7 +13,8 @@ module.exports = class ModuleTemplate extends Template { render(module, dependencyTemplates, options) { const moduleSource = module.source(dependencyTemplates, this.outputOptions, this.requestShortener); - const moduleSourcePostModule = this.applyPluginsWaterfall("module", moduleSource, module, options, dependencyTemplates); + const moduleSourcePostContent = this.applyPluginsWaterfall("content", moduleSource, module, options, dependencyTemplates); + const moduleSourcePostModule = this.applyPluginsWaterfall("module", moduleSourcePostContent, module, options, dependencyTemplates); const moduleSourcePostRender = this.applyPluginsWaterfall("render", moduleSourcePostModule, module, options, dependencyTemplates); return this.applyPluginsWaterfall("package", moduleSourcePostRender, module, options, dependencyTemplates); } diff --git a/lib/NodeStuffPlugin.js b/lib/NodeStuffPlugin.js index 1f45c397e..2d00e128d 100644 --- a/lib/NodeStuffPlugin.js +++ b/lib/NodeStuffPlugin.js @@ -21,7 +21,7 @@ class NodeStuffPlugin { compilation.dependencyFactories.set(ConstDependency, new NullFactory()); compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic"], (parser, parserOptions) => { if(parserOptions.node === false) return; diff --git a/lib/NormalModule.js b/lib/NormalModule.js index 092169d55..fb9eb1a5c 100644 --- a/lib/NormalModule.js +++ b/lib/NormalModule.js @@ -363,7 +363,7 @@ class NormalModule extends Module { contextArgument(block) { if(this === block) { - return this.exportsArgument || "exports"; + return this.exportsArgument; } return "this"; } diff --git a/lib/NormalModuleFactory.js b/lib/NormalModuleFactory.js index ceead2f65..d54a35f5d 100644 --- a/lib/NormalModuleFactory.js +++ b/lib/NormalModuleFactory.js @@ -191,7 +191,7 @@ class NormalModuleFactory extends Tapable { if(err) return callback(err); loaders = results[0].concat(loaders, results[1], results[2]); process.nextTick(() => { - const type = settings.type || "javascript/auto"; + const type = settings.type || this.getDefaultType(resourcePath); callback(null, { context: context, request: loaders.map(loaderToIdent).concat([resource]).join("!"), @@ -210,6 +210,16 @@ class NormalModuleFactory extends Tapable { }); } + getDefaultType(resourcePath) { + if(/\.wasm$/.test(resourcePath)) + return "webassembly/experimental"; + if(/\.mjs$/.test(resourcePath)) + return "javascript/esm"; + if(/\.json$/.test(resourcePath)) + return "json"; + return "javascript/auto"; + } + create(data, callback) { const dependencies = data.dependencies; const cacheEntry = dependencies[0].__NormalModuleFactoryCache; diff --git a/lib/ProvidePlugin.js b/lib/ProvidePlugin.js index a23402797..58bf86ed8 100644 --- a/lib/ProvidePlugin.js +++ b/lib/ProvidePlugin.js @@ -19,7 +19,7 @@ class ProvidePlugin { compiler.plugin("compilation", (compilation, params) => { compilation.dependencyFactories.set(ConstDependency, new NullFactory()); compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic", "parser javascript/esm"], (parser, parserOptions) => { Object.keys(definitions).forEach(name => { var request = [].concat(definitions[name]); var splittedName = name.split("."); diff --git a/lib/RequireJsStuffPlugin.js b/lib/RequireJsStuffPlugin.js index c2f8f200e..6e964b56d 100644 --- a/lib/RequireJsStuffPlugin.js +++ b/lib/RequireJsStuffPlugin.js @@ -14,7 +14,7 @@ module.exports = class RequireJsStuffPlugin { compiler.plugin("compilation", (compilation, params) => { compilation.dependencyFactories.set(ConstDependency, new NullFactory()); compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template()); - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic"], (parser, parserOptions) => { if(typeof parserOptions.requireJs !== "undefined" && !parserOptions.requireJs) return; diff --git a/lib/Template.js b/lib/Template.js index 43b1a59b9..df83f733c 100644 --- a/lib/Template.js +++ b/lib/Template.js @@ -138,7 +138,9 @@ module.exports = class Template extends Tapable { var allModules = modules.map(module => { return { id: module.id, - source: moduleTemplate.render(module, dependencyTemplates, { chunk }) + source: moduleTemplate.render(module, dependencyTemplates, { + chunk + }) }; }); if(removedModules && removedModules.length > 0) { diff --git a/lib/UseStrictPlugin.js b/lib/UseStrictPlugin.js index f3fa2cbd6..ca76c0cab 100644 --- a/lib/UseStrictPlugin.js +++ b/lib/UseStrictPlugin.js @@ -9,7 +9,7 @@ const ConstDependency = require("./dependencies/ConstDependency"); class UseStrictPlugin { apply(compiler) { compiler.plugin("compilation", (compilation, params) => { - params.normalModuleFactory.plugin("parser", (parser) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic", "parser javascript/esm"], (parser) => { const parserInstance = parser; parser.plugin("program", (ast) => { const firstNode = ast.body[0]; diff --git a/lib/WebAssemblyModulesPlugin.js b/lib/WebAssemblyModulesPlugin.js index 131819ace..977e07990 100644 --- a/lib/WebAssemblyModulesPlugin.js +++ b/lib/WebAssemblyModulesPlugin.js @@ -8,7 +8,9 @@ const WebAssemblyParser = require("./WebAssemblyParser"); class WebAssemblyModulesPlugin { apply(compiler) { - compiler.plugin("compilation", (compilation, { normalModuleFactory }) => { + compiler.plugin("compilation", (compilation, { + normalModuleFactory + }) => { normalModuleFactory.plugin("create-parser webassembly/experimental", () => { return new WebAssemblyParser(); }); diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js index 1eedf112c..0ec15c995 100644 --- a/lib/WebpackOptionsApply.js +++ b/lib/WebpackOptionsApply.js @@ -7,6 +7,7 @@ const OptionsApply = require("./OptionsApply"); const JavascriptModulesPlugin = require("./JavascriptModulesPlugin"); +const JsonModulesPlugin = require("./JsonModulesPlugin"); const WebAssemblyModulesPlugin = require("./WebAssemblyModulesPlugin"); const LoaderTargetPlugin = require("./LoaderTargetPlugin"); @@ -66,14 +67,15 @@ class WebpackOptionsApply extends OptionsApply { if(typeof options.target === "string") { let JsonpTemplatePlugin; let FetchCompileWasmTemplatePlugin; + let ReadFileCompileWasmTemplatePlugin; let NodeSourcePlugin; let NodeTargetPlugin; let NodeTemplatePlugin; switch(options.target) { case "web": - JsonpTemplatePlugin = require("./JsonpTemplatePlugin"); - FetchCompileWasmTemplatePlugin = require("./FetchCompileWasmTemplatePlugin"); + JsonpTemplatePlugin = require("./web/JsonpTemplatePlugin"); + FetchCompileWasmTemplatePlugin = require("./web/FetchCompileWasmTemplatePlugin"); NodeSourcePlugin = require("./node/NodeSourcePlugin"); compiler.apply( new JsonpTemplatePlugin(options.output), @@ -86,9 +88,11 @@ class WebpackOptionsApply extends OptionsApply { case "webworker": { let WebWorkerTemplatePlugin = require("./webworker/WebWorkerTemplatePlugin"); + FetchCompileWasmTemplatePlugin = require("./web/FetchCompileWasmTemplatePlugin"); NodeSourcePlugin = require("./node/NodeSourcePlugin"); compiler.apply( new WebWorkerTemplatePlugin(), + new FetchCompileWasmTemplatePlugin(options.output), new FunctionModulePlugin(options.output), new NodeSourcePlugin(options.node), new LoaderTargetPlugin(options.target) @@ -98,18 +102,20 @@ class WebpackOptionsApply extends OptionsApply { case "node": case "async-node": NodeTemplatePlugin = require("./node/NodeTemplatePlugin"); + ReadFileCompileWasmTemplatePlugin = require("./node/ReadFileCompileWasmTemplatePlugin"); NodeTargetPlugin = require("./node/NodeTargetPlugin"); compiler.apply( new NodeTemplatePlugin({ asyncChunkLoading: options.target === "async-node" }), + new ReadFileCompileWasmTemplatePlugin(options.output), new FunctionModulePlugin(options.output), new NodeTargetPlugin(), new LoaderTargetPlugin("node") ); break; case "node-webkit": - JsonpTemplatePlugin = require("./JsonpTemplatePlugin"); + JsonpTemplatePlugin = require("./web/JsonpTemplatePlugin"); NodeTargetPlugin = require("./node/NodeTargetPlugin"); ExternalsPlugin = require("./ExternalsPlugin"); compiler.apply( @@ -160,7 +166,7 @@ class WebpackOptionsApply extends OptionsApply { ); break; case "electron-renderer": - JsonpTemplatePlugin = require("./JsonpTemplatePlugin"); + JsonpTemplatePlugin = require("./web/JsonpTemplatePlugin"); NodeTargetPlugin = require("./node/NodeTargetPlugin"); ExternalsPlugin = require("./ExternalsPlugin"); compiler.apply( @@ -239,6 +245,7 @@ class WebpackOptionsApply extends OptionsApply { } compiler.apply( new JavascriptModulesPlugin(), + new JsonModulesPlugin(), new WebAssemblyModulesPlugin() ); diff --git a/lib/WebpackOptionsDefaulter.js b/lib/WebpackOptionsDefaulter.js index eb03e859a..8415fcfb5 100644 --- a/lib/WebpackOptionsDefaulter.js +++ b/lib/WebpackOptionsDefaulter.js @@ -98,7 +98,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter { this.set("resolve", "call", value => Object.assign({}, value)); this.set("resolve.unsafeCache", true); this.set("resolve.modules", ["node_modules"]); - this.set("resolve.extensions", [".js", ".json"]); + this.set("resolve.extensions", [".mjs", ".js", ".json"]); this.set("resolve.mainFiles", ["index"]); this.set("resolve.aliasFields", "make", (options) => { if(options.target === "web" || options.target === "webworker") diff --git a/lib/dependencies/AMDPlugin.js b/lib/dependencies/AMDPlugin.js index fd3c605cd..21f3f23e2 100644 --- a/lib/dependencies/AMDPlugin.js +++ b/lib/dependencies/AMDPlugin.js @@ -56,7 +56,7 @@ class AMDPlugin { compilation.dependencyFactories.set(LocalModuleDependency, new NullFactory()); compilation.dependencyTemplates.set(LocalModuleDependency, new LocalModuleDependency.Template()); - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic"], (parser, parserOptions) => { if(typeof parserOptions.amd !== "undefined" && !parserOptions.amd) return; diff --git a/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js b/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js index 329b3e0d8..89a224a93 100644 --- a/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +++ b/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js @@ -150,9 +150,9 @@ class AMDRequireDependenciesBlockParserPlugin { if(param.string === "require") { dep = new ConstDependency("__webpack_require__", param.string); } else if(param.string === "module") { - dep = new ConstDependency(parser.state.module.moduleArgument || "module", param.range); + dep = new ConstDependency(parser.state.module.moduleArgument, param.range); } else if(param.string === "exports") { - dep = new ConstDependency(parser.state.module.exportsArgument || "exports", param.range); + dep = new ConstDependency(parser.state.module.exportsArgument, param.range); } else if(localModule = LocalModulesHelpers.getLocalModule(parser.state, param.string)) { // eslint-disable-line no-cond-assign dep = new LocalModuleDependency(localModule, param.range); } else { diff --git a/lib/dependencies/CommonJsPlugin.js b/lib/dependencies/CommonJsPlugin.js index 9bef044a7..3bb176f52 100644 --- a/lib/dependencies/CommonJsPlugin.js +++ b/lib/dependencies/CommonJsPlugin.js @@ -47,7 +47,7 @@ class CommonJsPlugin { compilation.dependencyFactories.set(RequireHeaderDependency, new NullFactory()); compilation.dependencyTemplates.set(RequireHeaderDependency, new RequireHeaderDependency.Template()); - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic"], (parser, parserOptions) => { if(typeof parserOptions.commonjs !== "undefined" && !parserOptions.commonjs) return; diff --git a/lib/dependencies/HarmonyCompatibilityDependency.js b/lib/dependencies/HarmonyCompatibilityDependency.js index 1370346e0..a6a086ffb 100644 --- a/lib/dependencies/HarmonyCompatibilityDependency.js +++ b/lib/dependencies/HarmonyCompatibilityDependency.js @@ -20,7 +20,7 @@ HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate apply(dep, source) { const usedExports = dep.originModule.usedExports; if(usedExports && !Array.isArray(usedExports)) { - const exportName = dep.originModule.exportsArgument || "exports"; + const exportName = dep.originModule.exportsArgument; const content = `Object.defineProperty(${exportName}, "__esModule", { value: true });\n`; source.insert(-10, content); } diff --git a/lib/dependencies/HarmonyDetectionParserPlugin.js b/lib/dependencies/HarmonyDetectionParserPlugin.js index 224286a1b..943674e39 100644 --- a/lib/dependencies/HarmonyDetectionParserPlugin.js +++ b/lib/dependencies/HarmonyDetectionParserPlugin.js @@ -10,7 +10,8 @@ const HarmonyInitDependency = require("./HarmonyInitDependency"); module.exports = class HarmonyDetectionParserPlugin { apply(parser) { parser.plugin("program", (ast) => { - var isHarmony = ast.body.some(statement => { + const isStrictHarmony = parser.state.module.type === "javascript/esm"; + const isHarmony = isStrictHarmony || ast.body.some(statement => { return /^(Import|Export).*Declaration$/.test(statement.type); }); if(isHarmony) { @@ -45,6 +46,8 @@ module.exports = class HarmonyDetectionParserPlugin { module.meta.harmonyModule = true; module.strict = true; module.exportsArgument = "__webpack_exports__"; + if(isStrictHarmony) + module.moduleArgument = "__webpack_module__"; } }); diff --git a/lib/dependencies/HarmonyExportExpressionDependency.js b/lib/dependencies/HarmonyExportExpressionDependency.js index 5b52541ed..610ac7a20 100644 --- a/lib/dependencies/HarmonyExportExpressionDependency.js +++ b/lib/dependencies/HarmonyExportExpressionDependency.js @@ -39,7 +39,7 @@ HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTempla } getContent(module, used) { - const exportsName = module.exportsArgument || "exports"; + const exportsName = module.exportsArgument; if(used) { return `/* harmony default export */ ${exportsName}[${JSON.stringify(used)}] = `; } diff --git a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js index 925659c20..bcf16df01 100644 --- a/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +++ b/lib/dependencies/HarmonyExportImportedSpecifierDependency.js @@ -344,7 +344,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS content += "if(" + JSON.stringify(activeExports.concat("default")) + ".indexOf(__WEBPACK_IMPORT_KEY__) < 0) "; else content += "if(__WEBPACK_IMPORT_KEY__ !== 'default') "; - const exportsName = dep.originModule.exportsArgument || "exports"; + const exportsName = dep.originModule.exportsArgument; return content + `(function(key) { __webpack_require__.d(${exportsName}, key, function() { return ${name}[key]; }) }(__WEBPACK_IMPORT_KEY__));\n`; } @@ -354,13 +354,13 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS } getReexportStatement(module, key, name, valueKey) { - const exportsName = module.exportsArgument || "exports"; + const exportsName = module.exportsArgument; const returnValue = this.getReturnValue(valueKey); return `__webpack_require__.d(${exportsName}, ${JSON.stringify(key)}, function() { return ${name}${returnValue}; });\n`; } getConditionalReexportStatement(module, key, name, valueKey) { - const exportsName = module.exportsArgument || "exports"; + const exportsName = module.exportsArgument; const returnValue = this.getReturnValue(valueKey); return `if(__webpack_require__.o(${name}, ${JSON.stringify(valueKey)})) __webpack_require__.d(${exportsName}, ${JSON.stringify(key)}, function() { return ${name}${returnValue}; });\n`; } diff --git a/lib/dependencies/HarmonyExportSpecifierDependency.js b/lib/dependencies/HarmonyExportSpecifierDependency.js index b9e73f477..cb2b60bfa 100644 --- a/lib/dependencies/HarmonyExportSpecifierDependency.js +++ b/lib/dependencies/HarmonyExportSpecifierDependency.js @@ -42,7 +42,7 @@ HarmonyExportSpecifierDependency.Template = class HarmonyExportSpecifierDependen return `/* unused harmony export ${(dep.name || "namespace")} */\n`; } - const exportsName = dep.originModule.exportsArgument || "exports"; + const exportsName = dep.originModule.exportsArgument; return `/* harmony export (binding) */ __webpack_require__.d(${exportsName}, ${JSON.stringify(used)}, function() { return ${dep.id}; });\n`; } diff --git a/lib/dependencies/HarmonyModulesPlugin.js b/lib/dependencies/HarmonyModulesPlugin.js index 279183b87..a507a27b3 100644 --- a/lib/dependencies/HarmonyModulesPlugin.js +++ b/lib/dependencies/HarmonyModulesPlugin.js @@ -59,7 +59,7 @@ class HarmonyModulesPlugin { compilation.dependencyFactories.set(HarmonyAcceptImportDependency, normalModuleFactory); compilation.dependencyTemplates.set(HarmonyAcceptImportDependency, new HarmonyAcceptImportDependency.Template()); - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/esm"], (parser, parserOptions) => { if(typeof parserOptions.harmony !== "undefined" && !parserOptions.harmony) return; diff --git a/lib/dependencies/ImportPlugin.js b/lib/dependencies/ImportPlugin.js index 708f93d6f..3eb9ee9ef 100644 --- a/lib/dependencies/ImportPlugin.js +++ b/lib/dependencies/ImportPlugin.js @@ -33,7 +33,7 @@ class ImportPlugin { compilation.dependencyFactories.set(ImportContextDependency, contextModuleFactory); compilation.dependencyTemplates.set(ImportContextDependency, new ImportContextDependency.Template()); - normalModuleFactory.plugin("parser", (parser, parserOptions) => { + normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic", "parser javascript/esm"], (parser, parserOptions) => { if(typeof parserOptions.import !== "undefined" && !parserOptions.import) return; diff --git a/lib/dependencies/RequireContextPlugin.js b/lib/dependencies/RequireContextPlugin.js index ebd3e2020..0739c64ac 100644 --- a/lib/dependencies/RequireContextPlugin.js +++ b/lib/dependencies/RequireContextPlugin.js @@ -30,7 +30,7 @@ class RequireContextPlugin { compilation.dependencyFactories.set(ContextElementDependency, normalModuleFactory); - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic"], (parser, parserOptions) => { if(typeof parserOptions.requireContext !== "undefined" && !parserOptions.requireContext) return; diff --git a/lib/dependencies/RequireEnsurePlugin.js b/lib/dependencies/RequireEnsurePlugin.js index 307b3ec78..d3f7718d0 100644 --- a/lib/dependencies/RequireEnsurePlugin.js +++ b/lib/dependencies/RequireEnsurePlugin.js @@ -25,7 +25,7 @@ class RequireEnsurePlugin { compilation.dependencyFactories.set(RequireEnsureDependency, new NullFactory()); compilation.dependencyTemplates.set(RequireEnsureDependency, new RequireEnsureDependency.Template()); - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic"], (parser, parserOptions) => { if(typeof parserOptions.requireEnsure !== "undefined" && !parserOptions.requireEnsure) return; diff --git a/lib/dependencies/RequireIncludePlugin.js b/lib/dependencies/RequireIncludePlugin.js index f3ad6974d..cd4a3f194 100644 --- a/lib/dependencies/RequireIncludePlugin.js +++ b/lib/dependencies/RequireIncludePlugin.js @@ -18,7 +18,7 @@ class RequireIncludePlugin { compilation.dependencyFactories.set(RequireIncludeDependency, normalModuleFactory); compilation.dependencyTemplates.set(RequireIncludeDependency, new RequireIncludeDependency.Template()); - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic"], (parser, parserOptions) => { if(typeof parserOptions.requireInclude !== "undefined" && !parserOptions.requireInclude) return; diff --git a/lib/dependencies/SystemPlugin.js b/lib/dependencies/SystemPlugin.js index 895302a73..d92d82d8e 100644 --- a/lib/dependencies/SystemPlugin.js +++ b/lib/dependencies/SystemPlugin.js @@ -12,7 +12,7 @@ class SystemPlugin { apply(compiler) { compiler.plugin("compilation", (compilation, params) => { - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic"], (parser, parserOptions) => { if(typeof parserOptions.system !== "undefined" && !parserOptions.system) return; diff --git a/lib/node/NodeMainTemplatePlugin.js b/lib/node/NodeMainTemplatePlugin.js index b4e299832..3ae37ff99 100644 --- a/lib/node/NodeMainTemplatePlugin.js +++ b/lib/node/NodeMainTemplatePlugin.js @@ -44,7 +44,7 @@ module.exports = class NodeMainTemplatePlugin { } return source; }); - mainTemplate.plugin("require-ensure", (_, chunk, hash) => { + mainTemplate.plugin("require-ensure", (source, chunk, hash) => { const chunkFilename = mainTemplate.outputOptions.chunkFilename; const chunkMaps = chunk.getChunkMaps(); const insertMoreModules = [ @@ -55,61 +55,69 @@ module.exports = class NodeMainTemplatePlugin { ]; if(asyncChunkLoading) { return mainTemplate.asString([ - "// \"0\" is the signal for \"already loaded\"", - "if(installedChunks[chunkId] === 0)", + source, + "", + "// ReadFile + VM.run chunk loading for javascript", + "", + "var installedChunkData = installedChunks[chunkId];", + "if(installedChunkData !== 0) { // 0 means \"already installed\".", mainTemplate.indent([ - "return Promise.resolve();" - ]), - "// array of [resolve, reject, promise] means \"currently loading\"", - "if(installedChunks[chunkId])", - mainTemplate.indent([ - "return installedChunks[chunkId][2];" - ]), - "// load the chunk and return promise to it", - "var promise = new Promise(function(resolve, reject) {", - mainTemplate.indent([ - "installedChunks[chunkId] = [resolve, reject];", - "var filename = __dirname + " + mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(`/${chunkFilename}`), { - hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, - hashWithLength: (length) => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`, - chunk: { - id: "\" + chunkId + \"", - hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`, - hashWithLength: (length) => { - const shortChunkHashMap = {}; - Object.keys(chunkMaps.hash).forEach((chunkId) => { - if(typeof chunkMaps.hash[chunkId] === "string") - shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length); - }); - return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`; - }, - name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "` - } - }) + ";", - "require('fs').readFile(filename, 'utf-8', function(err, content) {", + "// array of [resolve, reject, promise] means \"currently loading\"", + "if(installedChunkData) {", mainTemplate.indent([ - "if(err) return reject(err);", - "var chunk = {};", - "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" + - "(chunk, require, require('path').dirname(filename), filename);" - ].concat(insertMoreModules).concat([ - "var callbacks = [];", - "for(var i = 0; i < chunkIds.length; i++) {", + "promises.push(installedChunkData[2]);" + ]), + "} else {", + mainTemplate.indent([ + "// load the chunk and return promise to it", + "var promise = new Promise(function(resolve, reject) {", mainTemplate.indent([ - "if(installedChunks[chunkIds[i]])", + "installedChunkData = installedChunks[chunkId] = [resolve, reject];", + "var filename = __dirname + " + mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(`/${chunkFilename}`), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: (length) => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`, + chunk: { + id: "\" + chunkId + \"", + hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`, + hashWithLength: (length) => { + const shortChunkHashMap = {}; + Object.keys(chunkMaps.hash).forEach((chunkId) => { + if(typeof chunkMaps.hash[chunkId] === "string") + shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length); + }); + return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`; + }, + name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "` + } + }) + ";", + "require('fs').readFile(filename, 'utf-8', function(err, content) {", mainTemplate.indent([ - "callbacks = callbacks.concat(installedChunks[chunkIds[i]][0]);" - ]), - "installedChunks[chunkIds[i]] = 0;" + "if(err) return reject(err);", + "var chunk = {};", + "require('vm').runInThisContext('(function(exports, require, __dirname, __filename) {' + content + '\\n})', filename)" + + "(chunk, require, require('path').dirname(filename), filename);" + ].concat(insertMoreModules).concat([ + "var callbacks = [];", + "for(var i = 0; i < chunkIds.length; i++) {", + mainTemplate.indent([ + "if(installedChunks[chunkIds[i]])", + mainTemplate.indent([ + "callbacks = callbacks.concat(installedChunks[chunkIds[i]][0]);" + ]), + "installedChunks[chunkIds[i]] = 0;" + ]), + "}", + "for(i = 0; i < callbacks.length; i++)", + mainTemplate.indent("callbacks[i]();") + ])), + "});" ]), - "}", - "for(i = 0; i < callbacks.length; i++)", - mainTemplate.indent("callbacks[i]();") - ])), - "});" + "});", + "promises.push(installedChunkData[2] = promise);" + ]), + "}" ]), - "});", - "return installedChunks[chunkId][2] = promise;" + "}" ]); } else { const request = mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(`./${chunkFilename}`), { @@ -130,6 +138,10 @@ module.exports = class NodeMainTemplatePlugin { } }); return mainTemplate.asString([ + source, + "", + "// require() chunk loading for javascript", + "", "// \"0\" is the signal for \"already loaded\"", "if(installedChunks[chunkId] !== 0) {", mainTemplate.indent([ @@ -139,7 +151,6 @@ module.exports = class NodeMainTemplatePlugin { mainTemplate.indent("installedChunks[chunkIds[i]] = 0;") ])), "}", - "return Promise.resolve();" ]); } }); diff --git a/lib/node/NodeSourcePlugin.js b/lib/node/NodeSourcePlugin.js index 42520a2f0..81a91b510 100644 --- a/lib/node/NodeSourcePlugin.js +++ b/lib/node/NodeSourcePlugin.js @@ -37,7 +37,7 @@ module.exports = class NodeSourcePlugin { }; compiler.plugin("compilation", (compilation, params) => { - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic", "parser javascript/esm"], (parser, parserOptions) => { if(parserOptions.node === false) return; diff --git a/lib/node/ReadFileCompileWasmMainTemplatePlugin.js b/lib/node/ReadFileCompileWasmMainTemplatePlugin.js new file mode 100644 index 000000000..e59f42c74 --- /dev/null +++ b/lib/node/ReadFileCompileWasmMainTemplatePlugin.js @@ -0,0 +1,83 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +class ReadFileCompileWasmMainTemplatePlugin { + + apply(mainTemplate) { + mainTemplate.plugin("local-vars", (source, chunk) => { + return mainTemplate.asString([ + source, + "", + "// object to store loaded and loading wasm modules", + "var installedWasmModules = {};", + ]); + }); + mainTemplate.plugin("require-ensure", (source, chunk, hash) => { + const webassemblyModuleFilename = mainTemplate.outputOptions.webassemblyModuleFilename; + const chunkModuleMaps = chunk.getChunkModuleMaps(false, m => m.type.startsWith("webassembly")); + if(Object.keys(chunkModuleMaps.id).length === 0) return source; + const wasmModuleSrcPath = mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(webassemblyModuleFilename), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`, + module: { + id: "\" + wasmModuleId + \"", + hash: `" + ${JSON.stringify(chunkModuleMaps.hash)}[wasmModuleId] + "`, + hashWithLength(length) { + const shortChunkHashMap = Object.create(null); + Object.keys(chunkModuleMaps.hash).forEach(wasmModuleId => { + if(typeof chunkModuleMaps.hash[wasmModuleId] === "string") + shortChunkHashMap[wasmModuleId] = chunkModuleMaps.hash[wasmModuleId].substr(0, length); + }); + return `" + ${JSON.stringify(shortChunkHashMap)}[wasmModuleId] + "`; + } + } + }); + return mainTemplate.asString([ + source, + "", + "// ReadFile + compile chunk loading for webassembly", + "", + `var wasmModules = ${JSON.stringify(chunkModuleMaps.id)}[chunkId] || [];`, + "", + "wasmModules.forEach(function(wasmModuleId) {", + mainTemplate.indent([ + "var installedWasmModuleData = installedWasmModules[wasmModuleId];", + "", + "// a Promise means \"currently loading\" or \"already loaded\".", + "promises.push(installedWasmModuleData ||", + mainTemplate.indent([ + "(installedWasmModules[wasmModuleId] = new Promise(function(resolve, reject) {", + mainTemplate.indent([ + `require('fs').readFile(require('path').resolve(__dirname, ${wasmModuleSrcPath}), function(err, buffer) {`, + mainTemplate.indent([ + "if(err) return reject(err);", + "resolve(WebAssembly.compile(buffer));" + ]), + "});" + ]), + `}).then(function(module) { ${mainTemplate.requireFn}.w[wasmModuleId] = module; }))` + ]), + ");", + ]), + "});", + ]); + }); + mainTemplate.plugin("require-extensions", (source, chunk) => { + return mainTemplate.asString([ + source, + "", + "// object with all compiled WebAssmbly.Modules", + `${mainTemplate.requireFn}.w = {};` + ]); + }); + mainTemplate.plugin("hash", hash => { + hash.update("ReadFileCompileWasmMainTemplatePlugin"); + hash.update("1"); + hash.update(`${mainTemplate.outputOptions.webassemblyModuleFilename}`); + }); + } +} +module.exports = ReadFileCompileWasmMainTemplatePlugin; diff --git a/lib/node/ReadFileCompileWasmModuleTemplatePlugin.js b/lib/node/ReadFileCompileWasmModuleTemplatePlugin.js new file mode 100644 index 000000000..f68bddec0 --- /dev/null +++ b/lib/node/ReadFileCompileWasmModuleTemplatePlugin.js @@ -0,0 +1,39 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const RawSource = require("webpack-sources").RawSource; + +class ReadFileCompileWasmModuleTemplatePlugin { + apply(moduleTemplate) { + moduleTemplate.plugin("content", (moduleSource, module, { + chunk + }) => { + if(module.type && module.type.startsWith("webassembly")) { + if(chunk.isInitial()) + throw new Error("Sync WebAsssmbly compilation is not yet implemented"); + const source = new RawSource([ + "\"use strict\";", + "", + "// Instanciate WebAssembly module", + "var instance = new WebAssembly.Instance(__webpack_require__.w[module.i], {});", + "", + "// export exports from WebAssmbly module", + // TODO rewrite this to getters depending on exports to support circular dependencies + "module.exports = instance.exports;" + ].join("\n")); + return source; + } else { + return moduleSource; + } + }); + + moduleTemplate.plugin("hash", hash => { + hash.update("ReadFileCompileWasmModuleTemplatePlugin"); + hash.update("1"); + }); + } +} +module.exports = ReadFileCompileWasmModuleTemplatePlugin; diff --git a/lib/node/ReadFileCompileWasmTemplatePlugin.js b/lib/node/ReadFileCompileWasmTemplatePlugin.js new file mode 100644 index 000000000..ce6440da6 --- /dev/null +++ b/lib/node/ReadFileCompileWasmTemplatePlugin.js @@ -0,0 +1,19 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const ReadFileCompileWasmMainTemplatePlugin = require("./ReadFileCompileWasmMainTemplatePlugin"); +const ReadFileCompileWasmModuleTemplatePlugin = require("./ReadFileCompileWasmModuleTemplatePlugin"); + +class ReadFileCompileWasmTemplatePlugin { + apply(compiler) { + compiler.plugin("this-compilation", (compilation) => { + compilation.mainTemplate.apply(new ReadFileCompileWasmMainTemplatePlugin()); + compilation.moduleTemplates.javascript.apply(new ReadFileCompileWasmModuleTemplatePlugin()); + }); + } +} + +module.exports = ReadFileCompileWasmTemplatePlugin; diff --git a/lib/optimize/ConcatenatedModule.js b/lib/optimize/ConcatenatedModule.js index 9a0dc0111..10d2fee80 100644 --- a/lib/optimize/ConcatenatedModule.js +++ b/lib/optimize/ConcatenatedModule.js @@ -9,8 +9,8 @@ const Template = require("../Template"); const Parser = require("../Parser"); const acorn = require("acorn"); const escope = require("escope"); -const ReplaceSource = require("webpack-sources/lib/ReplaceSource"); -const ConcatSource = require("webpack-sources/lib/ConcatSource"); +const ReplaceSource = require("webpack-sources").ReplaceSource; +const ConcatSource = require("webpack-sources").ConcatSource; const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency"); const HarmonyImportSideEffectDependency = require("../dependencies/HarmonyImportSideEffectDependency"); const HarmonyImportSpecifierDependency = require("../dependencies/HarmonyImportSpecifierDependency"); @@ -599,7 +599,7 @@ class ConcatenatedModule extends Module { // add harmony compatibility flag (must be first because of possible circular dependencies) const usedExports = this.rootModule.usedExports; if(usedExports === true) { - result.add(`Object.defineProperty(${this.exportsArgument || "exports"}, "__esModule", { value: true });\n`); + result.add(`Object.defineProperty(${this.exportsArgument}, "__esModule", { value: true });\n`); } // define required namespace objects (must be before evaluation modules) @@ -790,7 +790,7 @@ class HarmonyExportExpressionDependencyConcatenatedTemplate { let content = "/* harmony default export */ var __WEBPACK_MODULE_DEFAULT_EXPORT__ = "; if(dep.originModule === this.rootModule) { const used = dep.originModule.isUsed("default"); - const exportsName = dep.originModule.exportsArgument || "exports"; + const exportsName = dep.originModule.exportsArgument; if(used) content += `${exportsName}[${JSON.stringify(used)}] = `; } @@ -874,7 +874,7 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate { const exportData = new Buffer(def.id, "utf-8").toString("hex"); // eslint-disable-line node/no-deprecated-api finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}__`; } - const exportsName = this.rootModule.exportsArgument || "exports"; + const exportsName = this.rootModule.exportsArgument; const content = `/* concated harmony reexport */__webpack_require__.d(${exportsName}, ${JSON.stringify(used)}, function() { return ${finalName}; });\n`; source.insert(-1, content); }); diff --git a/lib/optimize/ModuleConcatenationPlugin.js b/lib/optimize/ModuleConcatenationPlugin.js index e62ff9139..293a035cf 100644 --- a/lib/optimize/ModuleConcatenationPlugin.js +++ b/lib/optimize/ModuleConcatenationPlugin.js @@ -22,7 +22,7 @@ class ModuleConcatenationPlugin { apply(compiler) { compiler.plugin("compilation", (compilation, params) => { - params.normalModuleFactory.plugin("parser", (parser, parserOptions) => { + params.normalModuleFactory.plugin(["parser javascript/auto", "parser javascript/dynamic", "parser javascript/esm"], (parser, parserOptions) => { parser.plugin("call eval", () => { parser.state.module.meta.hasEval = true; }); diff --git a/lib/FetchCompileWasmMainTemplatePlugin.js b/lib/web/FetchCompileWasmMainTemplatePlugin.js similarity index 59% rename from lib/FetchCompileWasmMainTemplatePlugin.js rename to lib/web/FetchCompileWasmMainTemplatePlugin.js index 8219d9708..813c7b820 100644 --- a/lib/FetchCompileWasmMainTemplatePlugin.js +++ b/lib/web/FetchCompileWasmMainTemplatePlugin.js @@ -7,21 +7,21 @@ class FetchCompileWasmMainTemplatePlugin { apply(mainTemplate) { - mainTemplate.plugin("local-vars", function(source, chunk) { - return this.asString([ + mainTemplate.plugin("local-vars", (source, chunk) => { + return mainTemplate.asString([ source, "", "// object to store loaded and loading wasm modules", "var installedWasmModules = {};", ]); }); - mainTemplate.plugin("require-ensure", function(source, chunk, hash) { - const webassemblyModuleFilename = this.outputOptions.webassemblyModuleFilename; + mainTemplate.plugin("require-ensure", (source, chunk, hash) => { + const webassemblyModuleFilename = mainTemplate.outputOptions.webassemblyModuleFilename; const chunkModuleMaps = chunk.getChunkModuleMaps(false, m => m.type.startsWith("webassembly")); if(Object.keys(chunkModuleMaps.id).length === 0) return source; - const wasmModuleSrcPath = this.applyPluginsWaterfall("asset-path", JSON.stringify(webassemblyModuleFilename), { - hash: `" + ${this.renderCurrentHashCode(hash)} + "`, - hashWithLength: length => `" + ${this.renderCurrentHashCode(hash, length)} + "`, + const wasmModuleSrcPath = mainTemplate.applyPluginsWaterfall("asset-path", JSON.stringify(webassemblyModuleFilename), { + hash: `" + ${mainTemplate.renderCurrentHashCode(hash)} + "`, + hashWithLength: length => `" + ${mainTemplate.renderCurrentHashCode(hash, length)} + "`, module: { id: "\" + wasmModuleId + \"", hash: `" + ${JSON.stringify(chunkModuleMaps.hash)}[wasmModuleId] + "`, @@ -35,7 +35,7 @@ class FetchCompileWasmMainTemplatePlugin { } } }); - return this.asString([ + return mainTemplate.asString([ source, "", "// Fetch + compile chunk loading for webassembly", @@ -43,46 +43,43 @@ class FetchCompileWasmMainTemplatePlugin { `var wasmModules = ${JSON.stringify(chunkModuleMaps.id)}[chunkId] || [];`, "", "wasmModules.forEach(function(wasmModuleId) {", - this.indent([ + mainTemplate.indent([ "var installedWasmModuleData = installedWasmModules[wasmModuleId];", "", "// a Promise means \"currently loading\" or \"already loaded\".", "promises.push(installedWasmModuleData ||", - this.indent([ - `promises.push(installedWasmModules[wasmModuleId] = fetch(${this.requireFn}.p + ${wasmModuleSrcPath}).then(function(response) {`, - this.indent([ + mainTemplate.indent([ + `(installedWasmModules[wasmModuleId] = fetch(${mainTemplate.requireFn}.p + ${wasmModuleSrcPath}).then(function(response) {`, + mainTemplate.indent([ "if(WebAssembly.compileStreaming) {", - this.indent([ + mainTemplate.indent([ "return WebAssembly.compileStreaming(response);" ]), "} else {", - this.indent([ + mainTemplate.indent([ "return response.arrayBuffer().then(function(bytes) { return WebAssembly.compile(bytes); });", ]), "}" ]), - `}).then(function(module) { ${this.requireFn}.w[wasmModuleId] = module; }))` + `}).then(function(module) { ${mainTemplate.requireFn}.w[wasmModuleId] = module; }))` ]), ");", ]), "});", ]); }); - mainTemplate.plugin("require-extensions", function(source, chunk) { - return this.asString([ + mainTemplate.plugin("require-extensions", (source, chunk) => { + return mainTemplate.asString([ source, "", "// object with all compiled WebAssmbly.Modules", - `${this.requireFn}.w = {};` + `${mainTemplate.requireFn}.w = {};` ]); }); - mainTemplate.plugin("hash", function(hash) { - hash.update("jsonp"); - hash.update("5"); - hash.update(`${this.outputOptions.filename}`); - hash.update(`${this.outputOptions.chunkFilename}`); - hash.update(`${this.outputOptions.jsonpFunction}`); - hash.update(`${this.outputOptions.hotUpdateFunction}`); + mainTemplate.plugin("hash", hash => { + hash.update("FetchCompileWasmMainTemplatePlugin"); + hash.update("1"); + hash.update(`${mainTemplate.outputOptions.webassemblyModuleFilename}`); }); } } diff --git a/lib/FetchCompileWasmModuleTemplatePlugin.js b/lib/web/FetchCompileWasmModuleTemplatePlugin.js similarity index 88% rename from lib/FetchCompileWasmModuleTemplatePlugin.js rename to lib/web/FetchCompileWasmModuleTemplatePlugin.js index 10d2436b9..c2f2141a2 100644 --- a/lib/FetchCompileWasmModuleTemplatePlugin.js +++ b/lib/web/FetchCompileWasmModuleTemplatePlugin.js @@ -8,7 +8,9 @@ const RawSource = require("webpack-sources").RawSource; class FetchCompileWasmModuleTemplatePlugin { apply(moduleTemplate) { - moduleTemplate.plugin("module", function(moduleSource, module, { chunk }) { + moduleTemplate.plugin("content", (moduleSource, module, { + chunk + }) => { if(module.type && module.type.startsWith("webassembly")) { if(chunk.isInitial()) throw new Error("Sync WebAsssmbly compilation is not yet implemented"); @@ -28,7 +30,7 @@ class FetchCompileWasmModuleTemplatePlugin { } }); - moduleTemplate.plugin("hash", function(hash) { + moduleTemplate.plugin("hash", hash => { hash.update("FetchCompileWasmModuleTemplatePlugin"); hash.update("1"); }); diff --git a/lib/FetchCompileWasmTemplatePlugin.js b/lib/web/FetchCompileWasmTemplatePlugin.js similarity index 100% rename from lib/FetchCompileWasmTemplatePlugin.js rename to lib/web/FetchCompileWasmTemplatePlugin.js diff --git a/lib/JsonpChunkTemplatePlugin.js b/lib/web/JsonpChunkTemplatePlugin.js similarity index 100% rename from lib/JsonpChunkTemplatePlugin.js rename to lib/web/JsonpChunkTemplatePlugin.js diff --git a/lib/JsonpExportMainTemplatePlugin.js b/lib/web/JsonpExportMainTemplatePlugin.js similarity index 100% rename from lib/JsonpExportMainTemplatePlugin.js rename to lib/web/JsonpExportMainTemplatePlugin.js diff --git a/lib/JsonpHotUpdateChunkTemplatePlugin.js b/lib/web/JsonpHotUpdateChunkTemplatePlugin.js similarity index 100% rename from lib/JsonpHotUpdateChunkTemplatePlugin.js rename to lib/web/JsonpHotUpdateChunkTemplatePlugin.js diff --git a/lib/JsonpMainTemplate.runtime.js b/lib/web/JsonpMainTemplate.runtime.js similarity index 100% rename from lib/JsonpMainTemplate.runtime.js rename to lib/web/JsonpMainTemplate.runtime.js diff --git a/lib/JsonpMainTemplatePlugin.js b/lib/web/JsonpMainTemplatePlugin.js similarity index 98% rename from lib/JsonpMainTemplatePlugin.js rename to lib/web/JsonpMainTemplatePlugin.js index fdd77f4fe..5f218e20f 100644 --- a/lib/JsonpMainTemplatePlugin.js +++ b/lib/web/JsonpMainTemplatePlugin.js @@ -4,7 +4,7 @@ */ "use strict"; -const Template = require("./Template"); +const Template = require("../Template"); class JsonpMainTemplatePlugin { @@ -115,14 +115,13 @@ class JsonpMainTemplatePlugin { mainTemplate.indent([ "installedChunkData = installedChunks[chunkId] = [resolve, reject];" ]), - "installedChunkData[2] = promise;", "});", + "promises.push(installedChunkData[2] = promise);", "", "// start chunk loading", "var head = document.getElementsByTagName('head')[0];", mainTemplate.applyPluginsWaterfall("jsonp-script", "", chunk, hash), - "head.appendChild(script);", - "promises.push(promise);" + "head.appendChild(script);" ]), "}", ]), diff --git a/lib/JsonpTemplatePlugin.js b/lib/web/JsonpTemplatePlugin.js similarity index 100% rename from lib/JsonpTemplatePlugin.js rename to lib/web/JsonpTemplatePlugin.js diff --git a/lib/webpack.js b/lib/webpack.js index 007a1a5ce..d1fedfd2b 100644 --- a/lib/webpack.js +++ b/lib/webpack.js @@ -87,7 +87,6 @@ exportPlugins(exports, { "CachePlugin": () => require("./CachePlugin"), "ExtendedAPIPlugin": () => require("./ExtendedAPIPlugin"), "ExternalsPlugin": () => require("./ExternalsPlugin"), - "JsonpTemplatePlugin": () => require("./JsonpTemplatePlugin"), "LibraryTemplatePlugin": () => require("./LibraryTemplatePlugin"), "LoaderTargetPlugin": () => require("./LoaderTargetPlugin"), "MemoryOutputFileSystem": () => require("./MemoryOutputFileSystem"), @@ -119,3 +118,11 @@ exportPlugins(exports.optimize = {}, { "OccurrenceOrderPlugin": () => require("./optimize/OccurrenceOrderPlugin"), "UglifyJsPlugin": () => require("./optimize/UglifyJsPlugin") }); +exportPlugins(exports.web = {}, { + "JsonpTemplatePlugin": () => require("./web/JsonpTemplatePlugin"), + "FetchCompileWasmTemplatePlugin": () => require("./web/FetchCompileWasmTemplatePlugin"), +}); +exportPlugins(exports.node = {}, { + "NodeTemplatePlugin": () => require("./node/NodeTemplatePlugin"), + "ReadFileCompileWasmTemplatePlugin": () => require("./node/ReadFileCompileWasmTemplatePlugin"), +}); diff --git a/package.json b/package.json index cca11eb64..77a3f8d69 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,6 @@ "enhanced-resolve": "^3.4.0", "escope": "^3.6.0", "interpret": "^1.0.0", - "json-loader": "^0.5.4", "loader-runner": "^2.3.0", "loader-utils": "^1.1.0", "memory-fs": "~0.4.1", @@ -47,6 +46,7 @@ "jade": "^1.11.0", "jade-loader": "~0.8.0", "js-beautify": "^1.5.10", + "json-loader": "^0.5.7", "less": "^2.5.1", "less-loader": "^4.0.3", "lodash": "^4.17.4", diff --git a/schemas/webpackOptionsSchema.json b/schemas/webpackOptionsSchema.json index 9c5b855c7..43077874e 100644 --- a/schemas/webpackOptionsSchema.json +++ b/schemas/webpackOptionsSchema.json @@ -663,6 +663,7 @@ "javascript/auto", "javascript/dynamic", "javascript/esm", + "json", "webassembly/experimental" ] }, diff --git a/test/ExternalModule.unittest.js b/test/ExternalModule.unittest.js index 93c69c98d..2a74f94b7 100644 --- a/test/ExternalModule.unittest.js +++ b/test/ExternalModule.unittest.js @@ -247,7 +247,7 @@ module.exports = some/request;`; it("deletgates to #getSourceForGlobalVariableExternal", function() { ["this", "window", "global"].forEach((type, i) => { // set up - externalModule.type = type; + externalModule.externalType = type; // invoke externalModule.getSourceString(); @@ -264,7 +264,7 @@ module.exports = some/request;`; it("deletgates to #getSourceForCommonJsExternal", function() { ["commonjs", "commonjs2"].forEach((type, i) => { // set up - externalModule.type = type; + externalModule.externalType = type; // invoke externalModule.getSourceString(); @@ -281,7 +281,7 @@ module.exports = some/request;`; it("deletgates to #getSourceForAmdOrUmdExternal", function() { ["amd", "umd", "umd2"].forEach((type, i) => { // set up - externalModule.type = type; + externalModule.externalType = type; // invoke externalModule.getSourceString(); @@ -298,7 +298,7 @@ module.exports = some/request;`; it("deletgates to #getSourceForGlobalVariableExternal", function() { ["foo", "bar", undefined].forEach((type, i) => { // set up - externalModule.type = type; + externalModule.externalType = type; // invoke externalModule.getSourceString(); diff --git a/test/JsonpExportMainTemplatePlugin.unittest.js b/test/JsonpExportMainTemplatePlugin.unittest.js index 79bc9fc8c..2613f10cd 100644 --- a/test/JsonpExportMainTemplatePlugin.unittest.js +++ b/test/JsonpExportMainTemplatePlugin.unittest.js @@ -4,7 +4,7 @@ const should = require("should"); const sinon = require("sinon"); const TemplatePluginEnvironment = require("./helpers/TemplatePluginEnvironment"); const ConcatSource = require("webpack-sources").ConcatSource; -const JsonpExportMainTemplatePlugin = require("../lib/JsonpExportMainTemplatePlugin"); +const JsonpExportMainTemplatePlugin = require("../lib/web/JsonpExportMainTemplatePlugin"); describe("JsonpExportMainTemplatePlugin", () => { let env; diff --git a/test/NormalModule.unittest.js b/test/NormalModule.unittest.js index 826aa6363..7715310a9 100644 --- a/test/NormalModule.unittest.js +++ b/test/NormalModule.unittest.js @@ -26,6 +26,7 @@ describe("NormalModule", function() { parse() {} }; normalModule = new NormalModule( + "javascript/auto", request, userRequest, rawRequest, @@ -68,6 +69,7 @@ describe("NormalModule", function() { beforeEach(function() { userRequest = "some/userRequest!some/other/userRequest!some/thing/is/off/here"; normalModule = new NormalModule( + "javascript/auto", request, userRequest, rawRequest, @@ -86,6 +88,7 @@ describe("NormalModule", function() { it("ignores paths in query parameters", function() { userRequest = "some/context/loader?query=foo\\bar&otherPath=testpath/other"; normalModule = new NormalModule( + "javascript/auto", request, userRequest, rawRequest, @@ -109,6 +112,7 @@ describe("NormalModule", function() { beforeEach(function() { resource = baseResource + "?some=query"; normalModule = new NormalModule( + "javascript/auto", request, userRequest, rawRequest, diff --git a/test/TestCases.test.js b/test/TestCases.test.js index 0ecf9ccfc..659a57c7c 100644 --- a/test/TestCases.test.js +++ b/test/TestCases.test.js @@ -133,7 +133,7 @@ describe("TestCases", () => { modules: ["web_modules", "node_modules"], mainFields: ["webpack", "browser", "web", "browserify", ["jam", "main"], "main"], aliasFields: ["browser"], - extensions: [".webpack.js", ".web.js", ".js", ".json"] + extensions: [".mjs", ".webpack.js", ".web.js", ".js", ".json"] }, resolveLoader: { modules: ["web_loaders", "web_modules", "node_loaders", "node_modules"], @@ -181,12 +181,14 @@ describe("TestCases", () => { const p = path.join(outputDirectory, module); const fn = vm.runInThisContext("(function(require, module, exports, __dirname, it) {" + fs.readFileSync(p, "utf-8") + "\n})", p); const m = { - exports: {} + exports: {}, + webpackTestSuiteModule: true }; fn.call(m.exports, _require, m, m.exports, outputDirectory, _it); return m.exports; } else return require(module); } + _require.webpackTestSuiteRequire = true; _require("./bundle.js"); if(exportedTest === 0) return done(new Error("No tests exported by test case")); done(); diff --git a/test/cases/loaders/issue-2299/loader/index.js b/test/cases/loaders/issue-2299/loader/index.js index b29af5426..6b2edcda0 100644 --- a/test/cases/loaders/issue-2299/loader/index.js +++ b/test/cases/loaders/issue-2299/loader/index.js @@ -9,8 +9,8 @@ module.exports = function(content) { if(err) { return callback(err); } - callback(null, this.exec(source, url)); - }.bind(this)); + callback(null, JSON.parse(source)); + }); }.bind(this), function(err, results) { if(err) { diff --git a/test/cases/mjs/esm-by-default/index.mjs b/test/cases/mjs/esm-by-default/index.mjs new file mode 100644 index 000000000..839b81030 --- /dev/null +++ b/test/cases/mjs/esm-by-default/index.mjs @@ -0,0 +1,8 @@ +it("should not have commonjs stuff available", function() { + if(typeof module !== "undefined") { // If module is available + module.should.have.property("webpackTestSuiteModule"); // it must be the node.js module + } + if(typeof require !== "undefined") { // If require is available + require.should.have.property("webpackTestSuiteRequire"); // it must be the node.js require + } +}); diff --git a/test/cases/wasm/simple/index.js b/test/cases/wasm/simple/index.js new file mode 100644 index 000000000..aa5fa4dbb --- /dev/null +++ b/test/cases/wasm/simple/index.js @@ -0,0 +1,7 @@ +it("should allow to run a WebAssembly module", function(done) { + import("./module").then(function(module) { + const result = module.run(); + result.should.be.eql(42); + done(); + }); +}); diff --git a/test/cases/wasm/simple/module.js b/test/cases/wasm/simple/module.js new file mode 100644 index 000000000..353e57c62 --- /dev/null +++ b/test/cases/wasm/simple/module.js @@ -0,0 +1,5 @@ +import { add, getNumber } from "./wasm.wasm"; + +export function run() { + return add(getNumber(), 2); +} diff --git a/test/cases/wasm/simple/wasm.wasm b/test/cases/wasm/simple/wasm.wasm new file mode 100644 index 0000000000000000000000000000000000000000..5364a02e7843ddafd1d3273e61e29a4ab08c1939 GIT binary patch literal 63 zcmZQbEY4+QU|?Y6W=deHuV<`JU|_6gW@chwWEW;)PE1K*VBkzoE%7VOO-e0dVC3Rs SVrNibP+-jBW?^vD;06F&`3htJ literal 0 HcmV?d00001 diff --git a/test/statsCases/aggressive-splitting-entry/expected.txt b/test/statsCases/aggressive-splitting-entry/expected.txt index ff106a0e6..5259241a1 100644 --- a/test/statsCases/aggressive-splitting-entry/expected.txt +++ b/test/statsCases/aggressive-splitting-entry/expected.txt @@ -1,13 +1,13 @@ -Hash: 794ae6df9cb4748fbcd7794ae6df9cb4748fbcd7 +Hash: 0c4822f4b0f344d71ebc0c4822f4b0f344d71ebc Child fitting: - Hash: 794ae6df9cb4748fbcd7 + Hash: 0c4822f4b0f344d71ebc Time: Xms Asset Size Chunks Chunk Names 3b0abf784cffee9cdb84.js 2.29 kB 0 [emitted] fd43aeccca69e5179cb6.js 1.98 kB 4 [emitted] - 37a2e572a7162ac860f9.js 5.94 kB 5 [emitted] + 0fb4d7363ffcca01b706.js 5.94 kB 5 [emitted] e1f8db72211be4caf41d.js 1.03 kB 6 [emitted] - Entrypoint main = 37a2e572a7162ac860f9.js e1f8db72211be4caf41d.js fd43aeccca69e5179cb6.js 3b0abf784cffee9cdb84.js + Entrypoint main = 0fb4d7363ffcca01b706.js e1f8db72211be4caf41d.js fd43aeccca69e5179cb6.js 3b0abf784cffee9cdb84.js chunk {0} 3b0abf784cffee9cdb84.js 1.91 kB [initial] [rendered] > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js 112 bytes {0} [built] @@ -17,7 +17,7 @@ Child fitting: > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [0] (webpack)/test/statsCases/aggressive-splitting-entry/b.js 899 bytes {4} [built] [1] (webpack)/test/statsCases/aggressive-splitting-entry/c.js 899 bytes {4} [built] - chunk {5} 37a2e572a7162ac860f9.js 1.8 kB [entry] [rendered] [recorded] + chunk {5} 0fb4d7363ffcca01b706.js 1.8 kB [entry] [rendered] [recorded] > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [2] (webpack)/test/statsCases/aggressive-splitting-entry/d.js 899 bytes {5} [built] [5] (webpack)/test/statsCases/aggressive-splitting-entry/a.js 899 bytes {5} [built] @@ -25,14 +25,14 @@ Child fitting: > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [3] (webpack)/test/statsCases/aggressive-splitting-entry/e.js 899 bytes {6} [built] Child content-change: - Hash: 794ae6df9cb4748fbcd7 + Hash: 0c4822f4b0f344d71ebc Time: Xms Asset Size Chunks Chunk Names 3b0abf784cffee9cdb84.js 2.29 kB 0 [emitted] fd43aeccca69e5179cb6.js 1.98 kB 4 [emitted] - 37a2e572a7162ac860f9.js 5.94 kB 5 [emitted] + 0fb4d7363ffcca01b706.js 5.94 kB 5 [emitted] e1f8db72211be4caf41d.js 1.03 kB 6 [emitted] - Entrypoint main = 37a2e572a7162ac860f9.js e1f8db72211be4caf41d.js fd43aeccca69e5179cb6.js 3b0abf784cffee9cdb84.js + Entrypoint main = 0fb4d7363ffcca01b706.js e1f8db72211be4caf41d.js fd43aeccca69e5179cb6.js 3b0abf784cffee9cdb84.js chunk {0} 3b0abf784cffee9cdb84.js 1.91 kB [initial] [rendered] > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js 112 bytes {0} [built] @@ -42,7 +42,7 @@ Child content-change: > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [0] (webpack)/test/statsCases/aggressive-splitting-entry/b.js 899 bytes {4} [built] [1] (webpack)/test/statsCases/aggressive-splitting-entry/c.js 899 bytes {4} [built] - chunk {5} 37a2e572a7162ac860f9.js 1.8 kB [entry] [rendered] [recorded] + chunk {5} 0fb4d7363ffcca01b706.js 1.8 kB [entry] [rendered] [recorded] > aggressive-splitted main [4] (webpack)/test/statsCases/aggressive-splitting-entry/index.js [2] (webpack)/test/statsCases/aggressive-splitting-entry/d.js 899 bytes {5} [built] [5] (webpack)/test/statsCases/aggressive-splitting-entry/a.js 899 bytes {5} [built] diff --git a/test/statsCases/aggressive-splitting-on-demand/expected.txt b/test/statsCases/aggressive-splitting-on-demand/expected.txt index 57de94911..9831b7686 100644 --- a/test/statsCases/aggressive-splitting-on-demand/expected.txt +++ b/test/statsCases/aggressive-splitting-on-demand/expected.txt @@ -1,4 +1,4 @@ -Hash: b9000d018fcafbe7adf7 +Hash: 643982be9b8a84182a8b Time: Xms Asset Size Chunks Chunk Names 1744d4ad4296f5fa250c.js 2.01 kB 0 [emitted] @@ -8,8 +8,8 @@ fcea9401f4f21cf79d39.js 1.99 kB 1 [emitted] c1e3d74e221cc503e2e1.js 1.99 kB 4 [emitted] 3d41758100f56aac517e.js 1.03 kB 5 [emitted] c64eeda8f0bfba682f9d.js 1.03 kB 6 [emitted] -9410b3c3e392a3a95fec.js 8.52 kB 7 [emitted] main -Entrypoint main = 9410b3c3e392a3a95fec.js +520c994eaddf273485ec.js 8.5 kB 7 [emitted] main +Entrypoint main = 520c994eaddf273485ec.js chunk {0} 1744d4ad4296f5fa250c.js 1.8 kB {7} [recorded] > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 4:0-51 > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 5:0-44 @@ -44,6 +44,6 @@ chunk {5} 3d41758100f56aac517e.js 899 bytes {7} chunk {6} c64eeda8f0bfba682f9d.js 899 bytes {7} > [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 1:0-16 [10] (webpack)/test/statsCases/aggressive-splitting-on-demand/a.js 899 bytes {6} [built] -chunk {7} 9410b3c3e392a3a95fec.js (main) 248 bytes [entry] +chunk {7} 520c994eaddf273485ec.js (main) 248 bytes [entry] > main [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 248 bytes {7} [built] \ No newline at end of file diff --git a/test/statsCases/chunks/expected.txt b/test/statsCases/chunks/expected.txt index 858e05dd8..db81d30c1 100644 --- a/test/statsCases/chunks/expected.txt +++ b/test/statsCases/chunks/expected.txt @@ -1,10 +1,10 @@ -Hash: acd61a6f698d13599727 +Hash: 5fa31bb3cd49eecb6ebd Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 288 bytes 0 [emitted] 1.bundle.js 152 bytes 1 [emitted] 2.bundle.js 232 bytes 2 [emitted] - bundle.js 7.16 kB 3 [emitted] main + bundle.js 7.14 kB 3 [emitted] main chunk {0} 0.bundle.js 54 bytes {3} [rendered] > [0] (webpack)/test/statsCases/chunks/index.js 3:0-16 [3] (webpack)/test/statsCases/chunks/c.js 54 bytes {0} [built] diff --git a/test/statsCases/color-disabled/expected.txt b/test/statsCases/color-disabled/expected.txt index 5f4668bd6..ee4cea7df 100644 --- a/test/statsCases/color-disabled/expected.txt +++ b/test/statsCases/color-disabled/expected.txt @@ -1,4 +1,4 @@ -Hash: 46a7ae6dc4165f8abc60 +Hash: 9b62d877d26dd61e1fb9 Time: Xms Asset Size Chunks Chunk Names main.js 2.69 kB 0 [emitted] main diff --git a/test/statsCases/color-enabled-custom/expected.txt b/test/statsCases/color-enabled-custom/expected.txt index 872a24ecd..8b05ecb98 100644 --- a/test/statsCases/color-enabled-custom/expected.txt +++ b/test/statsCases/color-enabled-custom/expected.txt @@ -1,4 +1,4 @@ -Hash: 46a7ae6dc4165f8abc60 +Hash: 9b62d877d26dd61e1fb9 Time: Xms Asset Size Chunks Chunk Names main.js 2.69 kB 0 [emitted] main diff --git a/test/statsCases/color-enabled/expected.txt b/test/statsCases/color-enabled/expected.txt index fb740b5bf..dfc322394 100644 --- a/test/statsCases/color-enabled/expected.txt +++ b/test/statsCases/color-enabled/expected.txt @@ -1,4 +1,4 @@ -Hash: 46a7ae6dc4165f8abc60 +Hash: 9b62d877d26dd61e1fb9 Time: Xms Asset Size Chunks Chunk Names main.js 2.69 kB 0 [emitted] main diff --git a/test/statsCases/commons-chunk-min-size-0/expected.txt b/test/statsCases/commons-chunk-min-size-0/expected.txt index bac7ecaa6..2563752ab 100644 --- a/test/statsCases/commons-chunk-min-size-0/expected.txt +++ b/test/statsCases/commons-chunk-min-size-0/expected.txt @@ -1,8 +1,8 @@ -Hash: 555ed68441b4e61480de +Hash: 6e3e301d55085d22e738 Time: Xms Asset Size Chunks Chunk Names entry-1.js 81 bytes 0 [emitted] entry-1 -vendor-1.js 8.24 kB 1 [emitted] vendor-1 +vendor-1.js 8.21 kB 1 [emitted] vendor-1 [0] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/a.js 22 bytes {1} [built] [1] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/b.js 22 bytes {1} [built] [2] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/c.js 22 bytes {1} [built] diff --git a/test/statsCases/commons-chunk-min-size-Infinity/expected.txt b/test/statsCases/commons-chunk-min-size-Infinity/expected.txt index 210c946f3..19cb9793e 100644 --- a/test/statsCases/commons-chunk-min-size-Infinity/expected.txt +++ b/test/statsCases/commons-chunk-min-size-Infinity/expected.txt @@ -1,4 +1,4 @@ -Hash: 770feff5bea289bd08f4 +Hash: 6b34e4a15d90c981775e Time: Xms Asset Size Chunks Chunk Names entry-1.js 3.32 kB 0 [emitted] entry-1 diff --git a/test/statsCases/commons-chunk-plugin-children/expected.txt b/test/statsCases/commons-chunk-plugin-children/expected.txt index 87db05bb1..0fe9efe79 100644 --- a/test/statsCases/commons-chunk-plugin-children/expected.txt +++ b/test/statsCases/commons-chunk-plugin-children/expected.txt @@ -6,7 +6,7 @@ Child normal: 3.bundle.js 837 bytes 3 [emitted] x2 4.bundle.js 530 bytes 4 [emitted] x1 5.bundle.js 1.15 kB 5 [emitted] xx5 - bundle.js 7.24 kB 6 [emitted] main + bundle.js 7.21 kB 6 [emitted] main chunk {0} 0.bundle.js (x4) 56 bytes {6} [rendered] > x4 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 4:0-42 [0] (webpack)/test/statsCases/commons-chunk-plugin-children/a.js 0 bytes {0} {1} {2} {3} {4} [built] @@ -51,7 +51,7 @@ Child children: 3.bundle.js 692 bytes 3 [emitted] x2 4.bundle.js 472 bytes 4 [emitted] x1 5.bundle.js 1.15 kB 5 [emitted] xx5 - bundle.js 7.36 kB 6 [emitted] main + bundle.js 7.34 kB 6 [emitted] main chunk {0} 0.bundle.js (x4) 56 bytes {6} [rendered] > x4 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 4:0-42 [1] (webpack)/test/statsCases/commons-chunk-plugin-children/c.js 0 bytes {0} {1} {5} [built] @@ -90,7 +90,7 @@ Child async: 4.bundle.js 692 bytes 4 [emitted] x2 5.bundle.js 472 bytes 5 [emitted] x1 6.bundle.js 1.15 kB 6 [emitted] xx5 - bundle.js 7.44 kB 7 [emitted] main + bundle.js 7.42 kB 7 [emitted] main chunk {0} 0.bundle.js 0 bytes {7} [rendered] > async commons x1 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 1:0-42 > async commons x2 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 2:0-42 @@ -134,7 +134,7 @@ Child deep-children: 3.bundle.js 912 bytes 3 [emitted] x3 4.bundle.js 692 bytes 4 [emitted] x2 5.bundle.js 472 bytes 5 [emitted] x1 - bundle.js 7.41 kB 6 [emitted] main + bundle.js 7.39 kB 6 [emitted] main chunk {0} 0.bundle.js (xx5) 42 bytes {6} [rendered] > xx5 [9] (webpack)/test/statsCases/commons-chunk-plugin-children/x5.js 3:0-44 [3] (webpack)/test/statsCases/commons-chunk-plugin-children/d.js 0 bytes {0} {1} [built] @@ -171,7 +171,7 @@ Child deep-async: 4.bundle.js 692 bytes 4 [emitted] x2 5.bundle.js 472 bytes 5 [emitted] x1 6.bundle.js 1.03 kB 6 [emitted] xx5 - bundle.js 7.44 kB 7 [emitted] main + bundle.js 7.42 kB 7 [emitted] main chunk {0} 0.bundle.js 0 bytes {7} [rendered] > async commons x1 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 1:0-42 > async commons x2 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 2:0-42 diff --git a/test/statsCases/commons-plugin-issue-4980/expected.txt b/test/statsCases/commons-plugin-issue-4980/expected.txt index 858c70958..6aac57fd0 100644 --- a/test/statsCases/commons-plugin-issue-4980/expected.txt +++ b/test/statsCases/commons-plugin-issue-4980/expected.txt @@ -1,22 +1,22 @@ -Hash: c107a06e25bb732bf473181ecf9358e3cc7f45e7 +Hash: 5d62edfa66d98709f5017b119fd7e38c61b8ef0d Child - Hash: c107a06e25bb732bf473 + Hash: 5d62edfa66d98709f501 Time: Xms Asset Size Chunks Chunk Names app.js 1.32 kB 0 [emitted] app vendor.3210cd7580ff3ec8d7c1.js 619 bytes 1 [emitted] vendor - runtime.js 7.25 kB 2 [emitted] runtime + runtime.js 7.22 kB 2 [emitted] runtime [./constants.js] (webpack)/test/statsCases/commons-plugin-issue-4980/constants.js 87 bytes {1} [built] [./entry-1.js] (webpack)/test/statsCases/commons-plugin-issue-4980/entry-1.js 67 bytes {0} [built] [./submodule-a.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-a.js 59 bytes {0} [built] [./submodule-b.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-b.js 59 bytes {0} [built] Child - Hash: 181ecf9358e3cc7f45e7 + Hash: 7b119fd7e38c61b8ef0d Time: Xms Asset Size Chunks Chunk Names app.js 1.37 kB 0 [emitted] app vendor.3210cd7580ff3ec8d7c1.js 619 bytes 1 [emitted] vendor - runtime.js 7.25 kB 2 [emitted] runtime + runtime.js 7.22 kB 2 [emitted] runtime [./constants.js] (webpack)/test/statsCases/commons-plugin-issue-4980/constants.js 87 bytes {1} [built] [./entry-2.js] (webpack)/test/statsCases/commons-plugin-issue-4980/entry-2.js 67 bytes {0} [built] [./submodule-a.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-a.js 59 bytes {0} [built] diff --git a/test/statsCases/define-plugin/expected.txt b/test/statsCases/define-plugin/expected.txt index 357600191..254b15707 100644 --- a/test/statsCases/define-plugin/expected.txt +++ b/test/statsCases/define-plugin/expected.txt @@ -1,12 +1,12 @@ -Hash: 5740106240ac3936376e1d8c50bebd858f67edaf +Hash: 591f65b34ea2fed28590a2524f672c23ebaef569 Child - Hash: 5740106240ac3936376e + Hash: 591f65b34ea2fed28590 Time: Xms Asset Size Chunks Chunk Names main.js 2.73 kB 0 [emitted] main [0] (webpack)/test/statsCases/define-plugin/index.js 24 bytes {0} [built] Child - Hash: 1d8c50bebd858f67edaf + Hash: a2524f672c23ebaef569 Time: Xms Asset Size Chunks Chunk Names main.js 2.73 kB 0 [emitted] main diff --git a/test/statsCases/exclude-with-loader/expected.txt b/test/statsCases/exclude-with-loader/expected.txt index a36b319f9..ee191ccd0 100644 --- a/test/statsCases/exclude-with-loader/expected.txt +++ b/test/statsCases/exclude-with-loader/expected.txt @@ -1,7 +1,7 @@ -Hash: 42d4b473056b7c1c9f38 +Hash: e2851c8d4cdd7e82ca78 Time: Xms Asset Size Chunks Chunk Names -bundle.js 3.14 kB 0 [emitted] main +bundle.js 3.13 kB 0 [emitted] main + 1 hidden asset [0] (webpack)/test/statsCases/exclude-with-loader/index.js 77 bytes {0} [built] [1] (webpack)/test/statsCases/exclude-with-loader/a.txt 43 bytes {0} [built] diff --git a/test/statsCases/external/expected.txt b/test/statsCases/external/expected.txt index 7ed996f36..fb58d209c 100644 --- a/test/statsCases/external/expected.txt +++ b/test/statsCases/external/expected.txt @@ -1,4 +1,4 @@ -Hash: 6d4c276e12a806fa09b1 +Hash: 7aea3de5f4fd504d5195 Time: Xms Asset Size Chunks Chunk Names main.js 2.82 kB 0 [emitted] main diff --git a/test/statsCases/filter-warnings/expected.txt b/test/statsCases/filter-warnings/expected.txt index 06c595861..cc502098f 100644 --- a/test/statsCases/filter-warnings/expected.txt +++ b/test/statsCases/filter-warnings/expected.txt @@ -1,12 +1,12 @@ -Hash: 19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a19b74c5b0289d95eca2a +Hash: cd4abefb3963c61372a0cd4abefb3963c61372a0cd4abefb3963c61372a0cd4abefb3963c61372a0cd4abefb3963c61372a0cd4abefb3963c61372a0cd4abefb3963c61372a0cd4abefb3963c61372a0cd4abefb3963c61372a0cd4abefb3963c61372a0cd4abefb3963c61372a0cd4abefb3963c61372a0cd4abefb3963c61372a0 Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -19,43 +19,43 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -68,13 +68,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -87,13 +87,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -106,13 +106,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -125,13 +125,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -144,13 +144,13 @@ Child Dropping unused function someRemoteUnUsedFunction4 [./a.js:6,0] Dropping unused function someRemoteUnUsedFunction5 [./a.js:7,0] Child - Hash: 19b74c5b0289d95eca2a + Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap 19b74c5b0289d95eca2a:5,0] + Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] diff --git a/test/statsCases/import-context-filter/expected.txt b/test/statsCases/import-context-filter/expected.txt index e34b3533a..bc1c5f812 100644 --- a/test/statsCases/import-context-filter/expected.txt +++ b/test/statsCases/import-context-filter/expected.txt @@ -1,10 +1,10 @@ -Hash: 6c4d6f1ed0a9a90ec93e +Hash: 9a8c88d293855a916088 Time: Xms Asset Size Chunks Chunk Names 0.js 339 bytes 0 [emitted] 1.js 345 bytes 1 [emitted] 2.js 336 bytes 2 [emitted] -entry.js 7.88 kB 3 [emitted] entry +entry.js 7.86 kB 3 [emitted] entry [0] (webpack)/test/statsCases/import-context-filter/templates/bar.js 38 bytes {2} [optional] [built] [1] (webpack)/test/statsCases/import-context-filter/templates/baz.js 38 bytes {1} [optional] [built] [2] (webpack)/test/statsCases/import-context-filter/templates/foo.js 38 bytes {0} [optional] [built] diff --git a/test/statsCases/import-weak/expected.txt b/test/statsCases/import-weak/expected.txt index aeca2c4c0..c07cea651 100644 --- a/test/statsCases/import-weak/expected.txt +++ b/test/statsCases/import-weak/expected.txt @@ -1,8 +1,8 @@ -Hash: a6cd1e3ec94a80959c78 +Hash: 9915cc41cf8ad107ab1e Time: Xms Asset Size Chunks Chunk Names 0.js 149 bytes 0 [emitted] -entry.js 7.28 kB 1 [emitted] entry +entry.js 7.26 kB 1 [emitted] entry [0] (webpack)/test/statsCases/import-weak/modules/b.js 22 bytes {0} [built] [1] (webpack)/test/statsCases/import-weak/entry.js 120 bytes {1} [built] [2] (webpack)/test/statsCases/import-weak/modules/a.js 37 bytes [built] \ No newline at end of file diff --git a/test/statsCases/limit-chunk-count-plugin/expected.txt b/test/statsCases/limit-chunk-count-plugin/expected.txt index 54bf42376..663baee2c 100644 --- a/test/statsCases/limit-chunk-count-plugin/expected.txt +++ b/test/statsCases/limit-chunk-count-plugin/expected.txt @@ -1,6 +1,6 @@ -Hash: 468570e5397bec3aa1424f36dcb9c59adabdac76a4dfe141df617e196eba275cb1ecca589a656bdb +Hash: 8a563b80ea8746a3892436a7c7bbedbe36681d4bad59fc60a72e40a54e4dcc419a84b806e80ea299 Child - Hash: 468570e5397bec3aa142 + Hash: 8a563b80ea8746a38924 Time: Xms Asset Size Chunks Chunk Names bundle.js 3.61 kB 0 [emitted] main @@ -12,11 +12,11 @@ Child [4] (webpack)/test/statsCases/limit-chunk-count-plugin/d.js 22 bytes {0} [built] [5] (webpack)/test/statsCases/limit-chunk-count-plugin/e.js 22 bytes {0} [built] Child - Hash: 4f36dcb9c59adabdac76 + Hash: 36a7c7bbedbe36681d4b Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 651 bytes 0 [emitted] - bundle.js 7.19 kB 1 [emitted] main + bundle.js 7.17 kB 1 [emitted] main chunk {0} 0.bundle.js 118 bytes {1} [rendered] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] [2] (webpack)/test/statsCases/limit-chunk-count-plugin/b.js 22 bytes {0} [built] @@ -26,12 +26,12 @@ Child chunk {1} bundle.js (main) 73 bytes [entry] [rendered] [0] (webpack)/test/statsCases/limit-chunk-count-plugin/index.js 73 bytes {1} [built] Child - Hash: a4dfe141df617e196eba + Hash: ad59fc60a72e40a54e4d Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 504 bytes 0 [emitted] 1.bundle.js 232 bytes 1 [emitted] - bundle.js 7.19 kB 2 [emitted] main + bundle.js 7.17 kB 2 [emitted] main chunk {0} 0.bundle.js 74 bytes {2} [rendered] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] [3] (webpack)/test/statsCases/limit-chunk-count-plugin/c.js 30 bytes {0} [built] @@ -42,13 +42,13 @@ Child chunk {2} bundle.js (main) 73 bytes [entry] [rendered] [0] (webpack)/test/statsCases/limit-chunk-count-plugin/index.js 73 bytes {2} [built] Child - Hash: 275cb1ecca589a656bdb + Hash: cc419a84b806e80ea299 Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 232 bytes 0 [emitted] 1.bundle.js 254 bytes 1 [emitted] 2.bundle.js 333 bytes 2 [emitted] - bundle.js 7.18 kB 3 [emitted] main + bundle.js 7.16 kB 3 [emitted] main chunk {0} 0.bundle.js 44 bytes {2} {3} [rendered] [2] (webpack)/test/statsCases/limit-chunk-count-plugin/b.js 22 bytes {0} [built] [5] (webpack)/test/statsCases/limit-chunk-count-plugin/e.js 22 bytes {0} [built] diff --git a/test/statsCases/max-modules-default/expected.txt b/test/statsCases/max-modules-default/expected.txt index 3ff08548b..6748fbbad 100644 --- a/test/statsCases/max-modules-default/expected.txt +++ b/test/statsCases/max-modules-default/expected.txt @@ -1,4 +1,4 @@ -Hash: 25e5bbed2cc755384806 +Hash: ce34adc7e3ac058ea5f0 Time: Xms Asset Size Chunks Chunk Names main.js 6 kB 0 [emitted] main diff --git a/test/statsCases/max-modules/expected.txt b/test/statsCases/max-modules/expected.txt index 870f5764e..e409d3306 100644 --- a/test/statsCases/max-modules/expected.txt +++ b/test/statsCases/max-modules/expected.txt @@ -1,4 +1,4 @@ -Hash: 25e5bbed2cc755384806 +Hash: ce34adc7e3ac058ea5f0 Time: Xms Asset Size Chunks Chunk Names main.js 6 kB 0 [emitted] main diff --git a/test/statsCases/module-deduplication-named/expected.txt b/test/statsCases/module-deduplication-named/expected.txt index cba3a9d98..0d1b12147 100644 --- a/test/statsCases/module-deduplication-named/expected.txt +++ b/test/statsCases/module-deduplication-named/expected.txt @@ -2,9 +2,9 @@ Asset Size Chunks Chunk Names 0.js 839 bytes 0 [emitted] async3 1.js 839 bytes 1 [emitted] async2 2.js 839 bytes 2 [emitted] async1 -e3.js 8.23 kB 3 [emitted] e3 -e2.js 8.21 kB 4 [emitted] e2 -e1.js 8.19 kB 5 [emitted] e1 +e3.js 8.21 kB 3 [emitted] e3 +e2.js 8.19 kB 4 [emitted] e2 +e1.js 8.17 kB 5 [emitted] e1 chunk {0} 0.js (async3) 89 bytes {1} {3} [rendered] [4] (webpack)/test/statsCases/module-deduplication-named/h.js 9 bytes {0} {3} [built] [7] (webpack)/test/statsCases/module-deduplication-named/async3.js 80 bytes {0} [built] diff --git a/test/statsCases/module-deduplication/expected.txt b/test/statsCases/module-deduplication/expected.txt index ef8125bc7..483db51d9 100644 --- a/test/statsCases/module-deduplication/expected.txt +++ b/test/statsCases/module-deduplication/expected.txt @@ -5,9 +5,9 @@ Asset Size Chunks Chunk Names 3.js 692 bytes 3 [emitted] 4.js 692 bytes 4 [emitted] 5.js 692 bytes 5 [emitted] -e3.js 8.43 kB 6 [emitted] e3 -e2.js 8.4 kB 7 [emitted] e2 -e1.js 8.38 kB 8 [emitted] e1 +e3.js 8.4 kB 6 [emitted] e3 +e2.js 8.38 kB 7 [emitted] e2 +e1.js 8.36 kB 8 [emitted] e1 chunk {0} 0.js 37 bytes {7} {8} [rendered] [6] (webpack)/test/statsCases/module-deduplication/async3.js 28 bytes {0} {3} [built] [7] (webpack)/test/statsCases/module-deduplication/h.js 9 bytes {0} {6} [built] diff --git a/test/statsCases/named-chunks-plugin-async/expected.txt b/test/statsCases/named-chunks-plugin-async/expected.txt index a2d467c5c..32c48427c 100644 --- a/test/statsCases/named-chunks-plugin-async/expected.txt +++ b/test/statsCases/named-chunks-plugin-async/expected.txt @@ -1,9 +1,9 @@ -Hash: e569776cf2d7bb15f549 +Hash: 2bb1fb80e892d7ca83ed Time: Xms Asset Size Chunks Chunk Names chunk-containing-__a_js.js 316 bytes chunk-containing-__a_js [emitted] chunk-containing-__b_js.js 173 bytes chunk-containing-__b_js [emitted] - entry.js 7.07 kB entry [emitted] entry + entry.js 7.04 kB entry [emitted] entry [0] (webpack)/test/statsCases/named-chunks-plugin-async/modules/b.js 22 bytes {chunk-containing-__b_js} [built] [1] (webpack)/test/statsCases/named-chunks-plugin-async/entry.js 47 bytes {entry} [built] [2] (webpack)/test/statsCases/named-chunks-plugin-async/modules/a.js 37 bytes {chunk-containing-__a_js} [built] \ No newline at end of file diff --git a/test/statsCases/named-chunks-plugin/expected.txt b/test/statsCases/named-chunks-plugin/expected.txt index 257836f00..a1a8e8846 100644 --- a/test/statsCases/named-chunks-plugin/expected.txt +++ b/test/statsCases/named-chunks-plugin/expected.txt @@ -1,8 +1,8 @@ -Hash: a1229254603619424568 +Hash: 3e5729d50a2db92f6b0e Time: Xms Asset Size Chunks Chunk Names entry.js 615 bytes entry [emitted] entry -manifest.js 7.26 kB manifest [emitted] manifest +manifest.js 7.23 kB manifest [emitted] manifest vendor.js 469 bytes vendor [emitted] vendor [0] multi ./modules/a ./modules/b 40 bytes {vendor} [built] [./entry.js] (webpack)/test/statsCases/named-chunks-plugin/entry.js 72 bytes {entry} [built] diff --git a/test/statsCases/optimize-chunks/expected.txt b/test/statsCases/optimize-chunks/expected.txt index 66b1d32bc..a2a12b23a 100644 --- a/test/statsCases/optimize-chunks/expected.txt +++ b/test/statsCases/optimize-chunks/expected.txt @@ -1,4 +1,4 @@ -Hash: 7c00c9ec24322c092eb7 +Hash: f3ec4488d129c46ade54 Time: Xms Asset Size Chunks Chunk Names 0.js 281 bytes 0 [emitted] cir1 @@ -8,7 +8,7 @@ Time: Xms 4.js 212 bytes 4, 6 [emitted] chunk 5.js 356 bytes 5, 3 [emitted] cir2 from cir1 6.js 130 bytes 6 [emitted] ac in ab -main.js 7.85 kB 7 [emitted] main +main.js 7.83 kB 7 [emitted] main chunk {0} 0.js (cir1) 81 bytes {3} {7} [rendered] > duplicate cir1 from cir2 [6] (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-detailed/expected.txt b/test/statsCases/preset-detailed/expected.txt index 3cd5880ef..e9f1a0880 100644 --- a/test/statsCases/preset-detailed/expected.txt +++ b/test/statsCases/preset-detailed/expected.txt @@ -1,10 +1,10 @@ -Hash: 7b6e615d7bd302eb9c50 +Hash: c40b21f5fbec6559b344 Time: Xms Asset Size Chunks Chunk Names 0.js 288 bytes 0 [emitted] 1.js 152 bytes 1 [emitted] 2.js 232 bytes 2 [emitted] -main.js 7.16 kB 3 [emitted] main +main.js 7.13 kB 3 [emitted] main Entrypoint main = main.js chunk {0} 0.js 54 bytes {3} [rendered] > [0] (webpack)/test/statsCases/preset-detailed/index.js 3:0-16 diff --git a/test/statsCases/preset-normal/expected.txt b/test/statsCases/preset-normal/expected.txt index 43e370123..b55fbe2b8 100644 --- a/test/statsCases/preset-normal/expected.txt +++ b/test/statsCases/preset-normal/expected.txt @@ -1,10 +1,10 @@ -Hash: 7b6e615d7bd302eb9c50 +Hash: c40b21f5fbec6559b344 Time: Xms Asset Size Chunks Chunk Names 0.js 288 bytes 0 [emitted] 1.js 152 bytes 1 [emitted] 2.js 232 bytes 2 [emitted] -main.js 7.16 kB 3 [emitted] main +main.js 7.13 kB 3 [emitted] main [0] (webpack)/test/statsCases/preset-normal/index.js 51 bytes {3} [built] [1] (webpack)/test/statsCases/preset-normal/a.js 22 bytes {3} [built] [2] (webpack)/test/statsCases/preset-normal/b.js 22 bytes {1} [built] diff --git a/test/statsCases/preset-verbose/expected.txt b/test/statsCases/preset-verbose/expected.txt index f69043b6c..4bf2546bb 100644 --- a/test/statsCases/preset-verbose/expected.txt +++ b/test/statsCases/preset-verbose/expected.txt @@ -1,10 +1,10 @@ -Hash: 7b6e615d7bd302eb9c50 +Hash: c40b21f5fbec6559b344 Time: Xms Asset Size Chunks Chunk Names 0.js 288 bytes 0 [emitted] 1.js 152 bytes 1 [emitted] 2.js 232 bytes 2 [emitted] -main.js 7.16 kB 3 [emitted] main +main.js 7.13 kB 3 [emitted] main Entrypoint main = main.js chunk {0} 0.js 54 bytes {3} [rendered] > [0] (webpack)/test/statsCases/preset-verbose/index.js 3:0-16 diff --git a/test/statsCases/resolve-plugin-context/expected.txt b/test/statsCases/resolve-plugin-context/expected.txt index cf9d33a95..183dc0882 100644 --- a/test/statsCases/resolve-plugin-context/expected.txt +++ b/test/statsCases/resolve-plugin-context/expected.txt @@ -1,4 +1,4 @@ -Hash: b28ec09e6f09816bd407 +Hash: 2f10a36f9685efee695a Time: Xms Asset Size Chunks Chunk Names bundle.js 3.1 kB 0 [emitted] main diff --git a/test/statsCases/reverse-sort-modules/expected.txt b/test/statsCases/reverse-sort-modules/expected.txt index f6fd12e6c..7dabf4970 100644 --- a/test/statsCases/reverse-sort-modules/expected.txt +++ b/test/statsCases/reverse-sort-modules/expected.txt @@ -1,4 +1,4 @@ -Hash: 25e5bbed2cc755384806 +Hash: ce34adc7e3ac058ea5f0 Time: Xms Asset Size Chunks Chunk Names main.js 6 kB 0 [emitted] main diff --git a/test/statsCases/scope-hoisting-multi/expected.txt b/test/statsCases/scope-hoisting-multi/expected.txt index 2b0f5002d..24cf832c3 100644 --- a/test/statsCases/scope-hoisting-multi/expected.txt +++ b/test/statsCases/scope-hoisting-multi/expected.txt @@ -1,6 +1,6 @@ -Hash: 8619511e846dc23eb000e02721a227f38dff757d +Hash: 1392f84a24c55c490b5e2d28fa80892d711ae32b Child - Hash: 8619511e846dc23eb000 + Hash: 1392f84a24c55c490b5e Time: Xms [0] (webpack)/test/statsCases/scope-hoisting-multi/common2.js 25 bytes {3} {4} [built] [1] (webpack)/test/statsCases/scope-hoisting-multi/common_lazy_shared.js 25 bytes {0} {1} {2} [built] @@ -14,7 +14,7 @@ Child [9] (webpack)/test/statsCases/scope-hoisting-multi/second.js 177 bytes {4} [built] [10] (webpack)/test/statsCases/scope-hoisting-multi/lazy_second.js 55 bytes {1} [built] Child - Hash: e02721a227f38dff757d + Hash: 2d28fa80892d711ae32b Time: Xms [0] (webpack)/test/statsCases/scope-hoisting-multi/common_lazy_shared.js 25 bytes {0} {1} {2} [built] [1] (webpack)/test/statsCases/scope-hoisting-multi/vendor.js 25 bytes {5} [built] diff --git a/test/statsCases/separate-css-bundle/expected.txt b/test/statsCases/separate-css-bundle/expected.txt index 60af3a771..cd2085a6e 100644 --- a/test/statsCases/separate-css-bundle/expected.txt +++ b/test/statsCases/separate-css-bundle/expected.txt @@ -1,9 +1,9 @@ -Hash: 9b8205a049992bc9783bb1a58f5b0b09d9dd1037 +Hash: 83e56382e56968147d36dee705eb8be60b2037db Child - Hash: 9b8205a049992bc9783b + Hash: 83e56382e56968147d36 Time: Xms Asset Size Chunks Chunk Names - fd4c2ca1440010a55587.js 2.83 kB 0 [emitted] main + 240942974444681d3abd.js 2.83 kB 0 [emitted] main c815cf440254d4f3bba4e7041db00a28.css 26 bytes 0 [emitted] main [0] (webpack)/test/statsCases/separate-css-bundle/a/index.js 23 bytes {0} [built] [1] (webpack)/test/statsCases/separate-css-bundle/a/file.css 41 bytes {0} [built] @@ -15,10 +15,10 @@ Child [0] (webpack)/node_modules/css-loader!(webpack)/test/statsCases/separate-css-bundle/a/file.css 199 bytes {0} [built] [1] (webpack)/node_modules/css-loader/lib/css-base.js 2.26 kB {0} [built] Child - Hash: b1a58f5b0b09d9dd1037 + Hash: dee705eb8be60b2037db Time: Xms Asset Size Chunks Chunk Names - fd4c2ca1440010a55587.js 2.83 kB 0 [emitted] main + 240942974444681d3abd.js 2.83 kB 0 [emitted] main a3f385680aef7a9bb2a517699532cc34.css 28 bytes 0 [emitted] main [0] (webpack)/test/statsCases/separate-css-bundle/b/index.js 23 bytes {0} [built] [1] (webpack)/test/statsCases/separate-css-bundle/b/file.css 41 bytes {0} [built] diff --git a/test/statsCases/simple-more-info/expected.txt b/test/statsCases/simple-more-info/expected.txt index 3368a6345..aace31f91 100644 --- a/test/statsCases/simple-more-info/expected.txt +++ b/test/statsCases/simple-more-info/expected.txt @@ -1,4 +1,4 @@ -Hash: 2e10a5e30d58364c392c +Hash: 9bd1f5491993467e8b27 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.69 kB 0 [emitted] main diff --git a/test/statsCases/simple/expected.txt b/test/statsCases/simple/expected.txt index 81f7f1400..5302d2575 100644 --- a/test/statsCases/simple/expected.txt +++ b/test/statsCases/simple/expected.txt @@ -1,4 +1,4 @@ -Hash: 2e10a5e30d58364c392c +Hash: 9bd1f5491993467e8b27 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.69 kB 0 [emitted] main diff --git a/test/statsCases/tree-shaking/expected.txt b/test/statsCases/tree-shaking/expected.txt index cac6798fd..8296fa34d 100644 --- a/test/statsCases/tree-shaking/expected.txt +++ b/test/statsCases/tree-shaking/expected.txt @@ -1,4 +1,4 @@ -Hash: 86e656e04ad1845b5137 +Hash: 2500e9cab76400ff4f51 Time: Xms Asset Size Chunks Chunk Names bundle.js 7.25 kB 0 [emitted] main diff --git a/test/statsCases/warnings-uglifyjs/expected.txt b/test/statsCases/warnings-uglifyjs/expected.txt index bc216f8e0..889394ddc 100644 --- a/test/statsCases/warnings-uglifyjs/expected.txt +++ b/test/statsCases/warnings-uglifyjs/expected.txt @@ -1,4 +1,4 @@ -Hash: 10e3e5dbac353b4cd892 +Hash: 7df1195d08327e14c776 Time: Xms Asset Size Chunks Chunk Names bundle.js 2.13 kB 0 [emitted] main diff --git a/yarn.lock b/yarn.lock index b3e6d70b2..b9a972ff7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2232,7 +2232,7 @@ jsesc@~0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" -json-loader@^0.5.4: +json-loader@^0.5.7: version "0.5.7" resolved "https://registry.yarnpkg.com/json-loader/-/json-loader-0.5.7.tgz#dca14a70235ff82f0ac9a3abeb60d337a365185d" From 003d8a5f33508ba6ea7cc7f8dc9e7d1ec45a3d7b Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sat, 11 Nov 2017 19:41:55 +0100 Subject: [PATCH 31/85] filter wasm tests in older node.js versions --- test/cases/wasm/simple/test.filter.js | 5 +++++ test/helpers/supportsWebAssembly.js | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 test/cases/wasm/simple/test.filter.js create mode 100644 test/helpers/supportsWebAssembly.js diff --git a/test/cases/wasm/simple/test.filter.js b/test/cases/wasm/simple/test.filter.js new file mode 100644 index 000000000..231773496 --- /dev/null +++ b/test/cases/wasm/simple/test.filter.js @@ -0,0 +1,5 @@ +var supportsWebAssembly = require("../../../helpers/supportsWebAssembly"); + +module.exports = function(config) { + return supportsWebAssembly(); +}; diff --git a/test/helpers/supportsWebAssembly.js b/test/helpers/supportsWebAssembly.js new file mode 100644 index 000000000..51cbdbb57 --- /dev/null +++ b/test/helpers/supportsWebAssembly.js @@ -0,0 +1,7 @@ +module.exports = function supportsWebAssembly() { + try { + return typeof WebAssembly !== "undefined"; + } catch(e) { + return false; + } +}; From 08e26b9d2ace09ece1014c74c9dcdd15c52efc92 Mon Sep 17 00:00:00 2001 From: hardfist Date: Tue, 14 Nov 2017 20:43:27 +0800 Subject: [PATCH 32/85] fix typo&& wrong links in examples/README.md --- examples/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/README.md b/examples/README.md index 47e30b4b0..5551b76c2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -21,7 +21,7 @@ [multiple-entry-points-commons-chunk-css-bundle](multiple-entry-points-commons-chunk-css-bundle) -[names-chunks](names-chunks) example demonstrating merging of chunks with named chunks +[named-chunks](named-chunks) example demonstrating merging of chunks with named chunks [two-explicit-vendor-chunks](two-explicit-vendor-chunks) From ee84d788ddcd1f5d90fa3e19840716a5f61631c7 Mon Sep 17 00:00:00 2001 From: Tushar Sharma Date: Wed, 15 Nov 2017 13:58:45 +0530 Subject: [PATCH 33/85] vars to lets and const --- lib/Compilation.js | 2 +- lib/DllModuleFactory.js | 4 ++-- lib/ExternalsPlugin.js | 2 +- lib/FlagDependencyUsagePlugin.js | 2 +- lib/OptionsDefaulter.js | 4 ++-- lib/dependencies/HarmonyDetectionParserPlugin.js | 7 +++++-- lib/dependencies/HarmonyImportDependency.js | 2 +- lib/dependencies/LocalModulesHelpers.js | 8 ++++---- 8 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/Compilation.js b/lib/Compilation.js index 127c796d7..bd165ed28 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -1425,7 +1425,7 @@ class Compilation extends Tapable { } createChildCompiler(name, outputOptions, plugins) { - var idx = (this.childrenCounters[name] || 0); + const idx = (this.childrenCounters[name] || 0); this.childrenCounters[name] = idx + 1; return this.compiler.createChildCompiler(this, name, idx, outputOptions, plugins); } diff --git a/lib/DllModuleFactory.js b/lib/DllModuleFactory.js index 67417933c..bc4751d88 100644 --- a/lib/DllModuleFactory.js +++ b/lib/DllModuleFactory.js @@ -4,8 +4,8 @@ */ "use strict"; -var Tapable = require("tapable"); -var DllModule = require("./DllModule"); +const Tapable = require("tapable"); +const DllModule = require("./DllModule"); class DllModuleFactory extends Tapable { constructor() { diff --git a/lib/ExternalsPlugin.js b/lib/ExternalsPlugin.js index 420843283..17057a21b 100644 --- a/lib/ExternalsPlugin.js +++ b/lib/ExternalsPlugin.js @@ -4,7 +4,7 @@ */ "use strict"; -var ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin"); +const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin"); class ExternalsPlugin { constructor(type, externals) { diff --git a/lib/FlagDependencyUsagePlugin.js b/lib/FlagDependencyUsagePlugin.js index 23b843eca..61327d175 100644 --- a/lib/FlagDependencyUsagePlugin.js +++ b/lib/FlagDependencyUsagePlugin.js @@ -30,7 +30,7 @@ class FlagDependencyUsagePlugin { else if(usedExports === true) module.usedExports = true; else if(Array.isArray(usedExports)) { - var old = module.usedExports ? module.usedExports.length : -1; + const old = module.usedExports ? module.usedExports.length : -1; module.usedExports = addToSet(module.usedExports || [], usedExports); if(module.usedExports.length === old) return; diff --git a/lib/OptionsDefaulter.js b/lib/OptionsDefaulter.js index d063cca43..be018b4ba 100644 --- a/lib/OptionsDefaulter.js +++ b/lib/OptionsDefaulter.js @@ -6,7 +6,7 @@ function getProperty(obj, name) { name = name.split("."); - for(var i = 0; i < name.length - 1; i++) { + for(let i = 0; i < name.length - 1; i++) { obj = obj[name[i]]; if(typeof obj !== "object" || !obj) return; } @@ -15,7 +15,7 @@ function getProperty(obj, name) { function setProperty(obj, name, value) { name = name.split("."); - for(var i = 0; i < name.length - 1; i++) { + for(let i = 0; i < name.length - 1; i++) { if(typeof obj[name[i]] !== "object" && typeof obj[name[i]] !== "undefined") return; if(!obj[name[i]]) obj[name[i]] = {}; obj = obj[name[i]]; diff --git a/lib/dependencies/HarmonyDetectionParserPlugin.js b/lib/dependencies/HarmonyDetectionParserPlugin.js index e7864e9da..62849ea04 100644 --- a/lib/dependencies/HarmonyDetectionParserPlugin.js +++ b/lib/dependencies/HarmonyDetectionParserPlugin.js @@ -9,7 +9,7 @@ const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency module.exports = class HarmonyDetectionParserPlugin { apply(parser) { parser.plugin("program", (ast) => { - var isHarmony = ast.body.some(statement => { + const isHarmony = ast.body.some(statement => { return /^(Import|Export).*Declaration$/.test(statement.type); }); if(isHarmony) { @@ -32,7 +32,7 @@ module.exports = class HarmonyDetectionParserPlugin { module.exportsArgument = "__webpack_exports__"; } }); - var nonHarmonyIdentifiers = ["define", "exports"]; + const nonHarmonyIdentifiers = ["define", "exports"]; nonHarmonyIdentifiers.forEach(identifer => { parser.plugin(`evaluate typeof ${identifer}`, nullInHarmony); parser.plugin(`typeof ${identifer}`, skipInHarmony); @@ -53,4 +53,7 @@ module.exports = class HarmonyDetectionParserPlugin { return null; } } + + + }; diff --git a/lib/dependencies/HarmonyImportDependency.js b/lib/dependencies/HarmonyImportDependency.js index 59f9b226a..f7f219f00 100644 --- a/lib/dependencies/HarmonyImportDependency.js +++ b/lib/dependencies/HarmonyImportDependency.js @@ -3,7 +3,7 @@ Author Tobias Koppers @sokra */ "use strict"; -var ModuleDependency = require("./ModuleDependency"); +const ModuleDependency = require("./ModuleDependency"); class HarmonyImportDependency extends ModuleDependency { constructor(request, importedVar, range) { diff --git a/lib/dependencies/LocalModulesHelpers.js b/lib/dependencies/LocalModulesHelpers.js index a2a2be771..c5097cc97 100644 --- a/lib/dependencies/LocalModulesHelpers.js +++ b/lib/dependencies/LocalModulesHelpers.js @@ -14,8 +14,8 @@ const lookup = (parent, mod) => { segs = mod.split("/"); path.pop(); - for(var i = 0; i < segs.length; i++) { - var seg = segs[i]; + for(let i = 0; i < segs.length; i++) { + const seg = segs[i]; if(seg === "..") path.pop(); else if(seg !== ".") path.push(seg); } @@ -25,7 +25,7 @@ const lookup = (parent, mod) => { LocalModulesHelpers.addLocalModule = (state, name) => { if(!state.localModules) state.localModules = []; - var m = new LocalModule(state.module, name, state.localModules.length); + const m = new LocalModule(state.module, name, state.localModules.length); state.localModules.push(m); return m; }; @@ -36,7 +36,7 @@ LocalModulesHelpers.getLocalModule = (state, name, namedModule) => { // resolve dependency name relative to the defining named module name = lookup(namedModule, name); } - for(var i = 0; i < state.localModules.length; i++) { + for(let i = 0; i < state.localModules.length; i++) { if(state.localModules[i].name === name) return state.localModules[i]; } From a163cad8f21e38c0092735726f44f527beca9978 Mon Sep 17 00:00:00 2001 From: Tushar Sharma Date: Wed, 15 Nov 2017 14:08:44 +0530 Subject: [PATCH 34/85] eslint fixes --- lib/dependencies/HarmonyDetectionParserPlugin.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/dependencies/HarmonyDetectionParserPlugin.js b/lib/dependencies/HarmonyDetectionParserPlugin.js index 62849ea04..187f22930 100644 --- a/lib/dependencies/HarmonyDetectionParserPlugin.js +++ b/lib/dependencies/HarmonyDetectionParserPlugin.js @@ -53,7 +53,4 @@ module.exports = class HarmonyDetectionParserPlugin { return null; } } - - - }; From a05e9c7bc28e4a9faffa4c172df2483d8ec99d04 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 15 Nov 2017 14:07:53 +0100 Subject: [PATCH 35/85] add linting for tests too --- .eslintrc.js | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index d91c33a1a..39ce5f7ad 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -5,6 +5,7 @@ module.exports = { "env": { "node": true, "es6": true, + "mocha": true, }, "parserOptions": { "ecmaVersion": 2017 }, "rules": { diff --git a/package.json b/package.json index cca11eb64..25933f101 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "build:examples": "cd examples && node buildAll.js", "pretest": "npm run lint-files", "lint-files": "npm run lint && npm run beautify-lint", - "lint": "eslint lib bin hot buildin \"test/**/webpack.config.js\" \"test/binCases/**/test.js\" \"examples/**/webpack.config.js\"", + "lint": "eslint lib bin hot buildin \"test/*.js\" \"test/**/webpack.config.js\" \"test/binCases/**/test.js\" \"examples/**/webpack.config.js\"", "fix": "npm run lint -- --fix", "beautify-lint": "beautify-lint \"lib/**/*.js\" \"hot/**/*.js\" \"bin/**/*.js\" \"benchmark/*.js\" \"test/*.js\"", "nsp": "nsp check --output summary", From 5941ab0d0cbacb688e6fa90efbce16ad390d4143 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 15 Nov 2017 14:08:11 +0100 Subject: [PATCH 36/85] fix linting errors --- test/AmdMainTemplatePlugin.unittest.js | 6 +- test/BenchmarkTestCases.benchmark.js | 9 ++- test/CachePlugin.unittest.js | 4 +- test/CaseSensitiveModulesWarning.unittest.js | 4 +- test/ConfigTestCases.test.js | 2 +- .../ContextDependencyTemplateAsId.unittest.js | 12 ++-- test/ContextReplacementPlugin.unittest.js | 67 +++++++++---------- test/ExternalModule.unittest.js | 2 +- test/HotModuleReplacementPlugin.test.js | 2 +- test/HotTestCases.test.js | 2 +- test/HotUpdateChunkTemplate.unittest.js | 2 +- test/Integration.test.js | 2 +- .../JsonpExportMainTemplatePlugin.unittest.js | 2 +- test/LibraryTemplatePlugin.unittest.js | 20 +++--- test/ModuleDependencyError.unittest.js | 3 +- test/MultiCompiler.unittest.js | 6 +- test/MultiStats.unittest.js | 3 +- test/MultiWatching.unittest.js | 2 +- test/NodeTemplatePlugin.test.js | 2 +- test/NodeWatchFileSystem.unittest.js | 32 ++++----- test/NullDependency.unittest.js | 2 +- test/Parser.unittest.js | 10 ++- test/RuleSet.unittest.js | 2 +- ...eMapDevToolModuleOptionsPlugin.unittest.js | 4 +- test/Template.unittest.js | 2 +- test/Validation.test.js | 2 +- test/WatchDetection.test.js | 6 +- test/WatchTestCases.test.js | 4 +- test/WatcherEvents.test.js | 2 +- test/WebpackError.unittest.js | 2 +- test/WebpackMissingModule.unittest.js | 2 +- test/checkArrayExpectation.js | 2 +- test/compareLocations.unittest.js | 2 +- test/formatLocation.unittest.js | 2 +- test/identifier.unittest.js | 1 - 35 files changed, 112 insertions(+), 117 deletions(-) diff --git a/test/AmdMainTemplatePlugin.unittest.js b/test/AmdMainTemplatePlugin.unittest.js index 8e0a8682e..7b19ba950 100644 --- a/test/AmdMainTemplatePlugin.unittest.js +++ b/test/AmdMainTemplatePlugin.unittest.js @@ -1,7 +1,7 @@ /* global describe, beforeEach, it */ "use strict"; -const should = require("should"); +require("should"); const sinon = require("sinon"); const TemplatePluginEnvironment = require("./helpers/TemplatePluginEnvironment"); const ConcatSource = require("webpack-sources").ConcatSource; @@ -96,10 +96,6 @@ describe("AmdMainTemplatePlugin", () => { describe("with only local dependencies", () => { beforeEach(() => { - const externalFlag = { - external: false - }; - const noExternals = env.modulesListWithExternals.map((module) => Object.assign(module, externalFlag)); env.chunk = { getModules: () => env.modulesListWithExternals }; diff --git a/test/BenchmarkTestCases.benchmark.js b/test/BenchmarkTestCases.benchmark.js index c3cf8cec9..0754f9d35 100644 --- a/test/BenchmarkTestCases.benchmark.js +++ b/test/BenchmarkTestCases.benchmark.js @@ -1,12 +1,11 @@ "use strict"; -const should = require("should"); +require("should"); const path = require("path"); const fs = require("fs"); const asyncLib = require("async"); var Test = require("mocha/lib/test"); -const webpack = require("../lib/webpack"); const Benchmark = require("benchmark"); describe("BenchmarkTestCases", function() { @@ -35,7 +34,7 @@ describe("BenchmarkTestCases", function() { const baselineRevision = baselineInfo.rev; const baselinePath = path.resolve(baselinesPath, baselineRevision); if(fs.existsSync(path.resolve(baselinePath, ".git"))) { - doLoadWebpack() + doLoadWebpack(); } else { try { fs.mkdirSync(baselinePath); @@ -64,7 +63,7 @@ describe("BenchmarkTestCases", function() { }); callback(); } - }, done) + }, done); }); }); @@ -80,7 +79,7 @@ describe("BenchmarkTestCases", function() { if(err) return callback(err); const match = /^([a-f0-9]+)\s*([a-f0-9]+)\s*([a-f0-9]+)?\s*$/.exec(resultParents); if(!match) return callback(new Error("Invalid result from git rev-list")); - const head = match[1] + const head = match[1]; const parent1 = match[2]; const parent2 = match[3]; if(parent2 && parent1) { diff --git a/test/CachePlugin.unittest.js b/test/CachePlugin.unittest.js index 66c73ce8a..65b6bc07a 100644 --- a/test/CachePlugin.unittest.js +++ b/test/CachePlugin.unittest.js @@ -1,9 +1,7 @@ "use strict"; -const should = require("should"); -const sinon = require("sinon"); +require("should"); const CachePlugin = require("../lib/CachePlugin"); -const applyPluginWithOptions = require("./helpers/applyPluginWithOptions"); describe("CachePlugin", () => { let env; diff --git a/test/CaseSensitiveModulesWarning.unittest.js b/test/CaseSensitiveModulesWarning.unittest.js index 71c886d69..ab0690941 100644 --- a/test/CaseSensitiveModulesWarning.unittest.js +++ b/test/CaseSensitiveModulesWarning.unittest.js @@ -1,6 +1,6 @@ "use strict"; -const should = require("should"); +require("should"); const CaseSensitiveModulesWarning = require("../lib/CaseSensitiveModulesWarning"); const createModule = function(identifier, numberOfReasons) { @@ -49,6 +49,6 @@ Use equal casing. Compare these module identifiers: it("has the an origin", () => myCaseSensitiveModulesWarning.origin.should.be.exactly(modules[0])); - it('has the a module', () => + it("has the a module", () => myCaseSensitiveModulesWarning.module.should.be.exactly(modules[0])); }); diff --git a/test/ConfigTestCases.test.js b/test/ConfigTestCases.test.js index 78adaf263..d1d50e576 100644 --- a/test/ConfigTestCases.test.js +++ b/test/ConfigTestCases.test.js @@ -1,7 +1,7 @@ "use strict"; /* globals describe it */ -const should = require("should"); +require("should"); const path = require("path"); const fs = require("fs"); const vm = require("vm"); diff --git a/test/ContextDependencyTemplateAsId.unittest.js b/test/ContextDependencyTemplateAsId.unittest.js index 910ed906d..0332470f6 100644 --- a/test/ContextDependencyTemplateAsId.unittest.js +++ b/test/ContextDependencyTemplateAsId.unittest.js @@ -1,7 +1,7 @@ "use strict"; const _ = require("lodash"); -const should = require("should"); +require("should"); const sinon = require("sinon"); const ContextDependencyTemplateAsId = require("../lib/dependencies/ContextDependencyTemplateAsId"); @@ -51,7 +51,7 @@ describe("ContextDependencyTemplateAsId", () => { it("replaces source with missing module error", () => { env.source.replace.callCount.should.be.exactly(1); - sinon.assert.calledWith(env.source.replace, 1, 24, '!(function webpackMissingModule() { var e = new Error("Cannot find module \\"myModule\\""); e.code = \'MODULE_NOT_FOUND\'; throw e; }())'); + sinon.assert.calledWith(env.source.replace, 1, 24, "!(function webpackMissingModule() { var e = new Error(\"Cannot find module \\\"myModule\\\"\"); e.code = 'MODULE_NOT_FOUND'; throw e; }())"); }); }); @@ -71,7 +71,7 @@ describe("ContextDependencyTemplateAsId", () => { it("replaces source with webpack require with comment", () => { env.source.replace.callCount.should.be.exactly(1); - sinon.assert.calledWith(env.source.replace, 1, 24, '__webpack_require__(/*! shortened myModule */ "123").resolve'); + sinon.assert.calledWith(env.source.replace, 1, 24, "__webpack_require__(/*! shortened myModule */ \"123\").resolve"); }); }); @@ -83,7 +83,7 @@ describe("ContextDependencyTemplateAsId", () => { it("replaces source with webpack require without comment", () => { env.source.replace.callCount.should.be.exactly(1); - sinon.assert.calledWith(env.source.replace, 1, 24, '__webpack_require__("123").resolve'); + sinon.assert.calledWith(env.source.replace, 1, 24, "__webpack_require__(\"123\").resolve"); }); }); }); @@ -103,7 +103,7 @@ describe("ContextDependencyTemplateAsId", () => { it("replaces source with webpack require and wraps value", () => { env.source.replace.callCount.should.be.exactly(2); sinon.assert.calledWith(env.source.replace, 18, 24, ")"); - sinon.assert.calledWith(env.source.replace, 1, 7, '__webpack_require__(/*! shortened myModule */ "123").resolve("prepend value"'); + sinon.assert.calledWith(env.source.replace, 1, 7, "__webpack_require__(/*! shortened myModule */ \"123\").resolve(\"prepend value\""); }); }); @@ -132,7 +132,7 @@ describe("ContextDependencyTemplateAsId", () => { sinon.assert.calledWith(env.source.replace, 9, 10, "foo"); sinon.assert.calledWith(env.source.replace, 13, 14, "bar"); sinon.assert.calledWith(env.source.replace, 18, 24, ")"); - sinon.assert.calledWith(env.source.replace, 1, 7, '__webpack_require__(/*! shortened myModule */ "123").resolve("prepend value"'); + sinon.assert.calledWith(env.source.replace, 1, 7, "__webpack_require__(/*! shortened myModule */ \"123\").resolve(\"prepend value\""); }); }); }); diff --git a/test/ContextReplacementPlugin.unittest.js b/test/ContextReplacementPlugin.unittest.js index e92d60774..691c7fbba 100644 --- a/test/ContextReplacementPlugin.unittest.js +++ b/test/ContextReplacementPlugin.unittest.js @@ -3,7 +3,6 @@ const should = require("should"); const sinon = require("sinon"); const ContextReplacementPlugin = require("../lib/ContextReplacementPlugin"); -const applyPluginWithOptions = require("./helpers/applyPluginWithOptions"); const PluginEnvironment = require("./helpers/PluginEnvironment"); describe("ContextReplacementPlugin", () => { @@ -40,14 +39,14 @@ describe("ContextReplacementPlugin", () => { should(instance.newContentCreateContextMap).be.a.Function(); let x = (nothing, obj) => { - should(obj.test).be.exactly("obj") + should(obj.test).be.exactly("obj"); }; let spy = sinon.spy(x); instance.newContentCreateContextMap(undefined, spy); - should(spy.called).be.exactly(true) + should(spy.called).be.exactly(true); }); @@ -68,10 +67,10 @@ describe("ContextReplacementPlugin", () => { let obj = buildPluginWithParams(/selector/, "./folder", true, /filter/); let x = (nothing, result) => { - should(result.request).be.exactly('./folder') - should(result.dependencies[0].critical).be.exactly(false) - should(result.recursive).be.exactly(true) - should(result.regExp instanceof RegExp).be.exactly(true) + should(result.request).be.exactly("./folder"); + should(result.dependencies[0].critical).be.exactly(false); + should(result.recursive).be.exactly(true); + should(result.regExp instanceof RegExp).be.exactly(true); }; let spy = sinon.spy(x); @@ -81,24 +80,24 @@ describe("ContextReplacementPlugin", () => { dependencies: [{ critical: true }] - }, spy) + }, spy); - should(spy.called).be.exactly(true) + should(spy.called).be.exactly(true); }); it("default call with newContentCallback as a function", () => { let obj = buildPluginWithParams(/selector/, (result) => { - should(result.request).be.exactly('selector') - should(result.dependencies[0].critical).be.exactly(false) - should(result.recursive).be.exactly(undefined) - should(result.regExp).be.exactly(undefined) + should(result.request).be.exactly("selector"); + should(result.dependencies[0].critical).be.exactly(false); + should(result.recursive).be.exactly(undefined); + should(result.regExp).be.exactly(undefined); }, true, /filter/); let x = (nothing, result) => { - should(result.request).be.exactly('selector') - should(result.dependencies[0].critical).be.exactly(false) - should(result.recursive).be.exactly(undefined) - should(result.regExp).be.exactly(undefined) + should(result.request).be.exactly("selector"); + should(result.dependencies[0].critical).be.exactly(false); + should(result.recursive).be.exactly(undefined); + should(result.regExp).be.exactly(undefined); }; let spy = sinon.spy(x); @@ -108,9 +107,9 @@ describe("ContextReplacementPlugin", () => { dependencies: [{ critical: false }] - }, spy) + }, spy); - should(spy.called).be.exactly(true) + should(spy.called).be.exactly(true); }); it("call when result is false", () => { @@ -124,7 +123,7 @@ describe("ContextReplacementPlugin", () => { obj.beforeResolve.handler(false, spy); - should(spy.called).be.exactly(true) + should(spy.called).be.exactly(true); }); }); @@ -133,8 +132,8 @@ describe("ContextReplacementPlugin", () => { let obj = buildPluginWithParams(/selector/, "./folder", true, /filter/); let x = (nothing, result) => { - result.resource.should.containEql('selector') - result.resource.should.containEql('folder') + result.resource.should.containEql("selector"); + result.resource.should.containEql("folder"); }; let spy = sinon.spy(x); @@ -146,14 +145,14 @@ describe("ContextReplacementPlugin", () => { }] }, spy); - should(spy.called).be.exactly(true) + should(spy.called).be.exactly(true); }); it("default call where regex is incorrect", () => { let obj = buildPluginWithParams(/selector/, "./folder", true, /filter/); let x = (nothing, result) => { - result.resource.should.containEql('importwontwork') + result.resource.should.containEql("importwontwork"); }; let spy = sinon.spy(x); @@ -165,7 +164,7 @@ describe("ContextReplacementPlugin", () => { }] }, spy); - should(spy.called).be.exactly(true) + should(spy.called).be.exactly(true); }); it("default call where regex is correct", () => { @@ -174,7 +173,7 @@ describe("ContextReplacementPlugin", () => { }, true, /filter/); let x = (nothing, result) => { - result.resource.should.equal('selector') + result.resource.should.equal("selector"); }; let spy = sinon.spy(x); @@ -186,17 +185,17 @@ describe("ContextReplacementPlugin", () => { }] }, spy); - should(spy.called).be.exactly(true) + should(spy.called).be.exactly(true); }); it("default call where regex is correct and using function as newContent Resource", () => { let obj = buildPluginWithParams(/selector/, (result) => { - result.resource = "imadifferentselector" + result.resource = "imadifferentselector"; }, true, /filter/); let x = (nothing, result) => { - result.resource.should.containEql('selector') - result.resource.should.containEql('imadifferentselector') + result.resource.should.containEql("selector"); + result.resource.should.containEql("imadifferentselector"); }; let spy = sinon.spy(x); @@ -208,10 +207,10 @@ describe("ContextReplacementPlugin", () => { }] }, spy); - should(spy.called).be.exactly(true) + should(spy.called).be.exactly(true); }); - }) + }); }); }); @@ -223,7 +222,7 @@ let buildPluginWithParams = (resourceRegExp, newContentResource, newContentRecur instance.apply(pluginEnvironment.getEnvironmentStub()); let contextModuleFactory = pluginEnvironment.getEventBindings()[0]; - pluginEnvironment.getEventBindings().length.should.be.exactly(1) + pluginEnvironment.getEventBindings().length.should.be.exactly(1); let contextModuleFactoryPluginEnv = new PluginEnvironment(); @@ -239,5 +238,5 @@ let buildPluginWithParams = (resourceRegExp, newContentResource, newContentRecur contextModuleFactory, beforeResolve, afterResolve - } + }; }; diff --git a/test/ExternalModule.unittest.js b/test/ExternalModule.unittest.js index 93c69c98d..4ee303832 100644 --- a/test/ExternalModule.unittest.js +++ b/test/ExternalModule.unittest.js @@ -163,7 +163,7 @@ describe("ExternalModule", function() { // set up const variableToCheck = "foo"; const request = "bar"; - const expected = `if(typeof foo === 'undefined') {var e = new Error(\"Cannot find module \\\"bar\\\"\"); e.code = 'MODULE_NOT_FOUND'; throw e;} + const expected = `if(typeof foo === 'undefined') {var e = new Error("Cannot find module \\"bar\\""); e.code = 'MODULE_NOT_FOUND'; throw e;} `; // invoke diff --git a/test/HotModuleReplacementPlugin.test.js b/test/HotModuleReplacementPlugin.test.js index 86c6f1c6a..6c2c0b574 100644 --- a/test/HotModuleReplacementPlugin.test.js +++ b/test/HotModuleReplacementPlugin.test.js @@ -1,6 +1,6 @@ "use strict"; -const should = require("should"); +require("should"); const path = require("path"); const fs = require("fs"); diff --git a/test/HotTestCases.test.js b/test/HotTestCases.test.js index b2b8836c2..663346228 100644 --- a/test/HotTestCases.test.js +++ b/test/HotTestCases.test.js @@ -1,6 +1,6 @@ "use strict"; -const should = require("should"); +require("should"); const path = require("path"); const fs = require("fs"); const vm = require("vm"); diff --git a/test/HotUpdateChunkTemplate.unittest.js b/test/HotUpdateChunkTemplate.unittest.js index 33a04158e..a3626d291 100644 --- a/test/HotUpdateChunkTemplate.unittest.js +++ b/test/HotUpdateChunkTemplate.unittest.js @@ -1,6 +1,6 @@ "use strict"; -const should = require("should"); +require("should"); const sinon = require("sinon"); const HotUpdateChunkTemplate = require("../lib/HotUpdateChunkTemplate"); diff --git a/test/Integration.test.js b/test/Integration.test.js index 7be32e662..b02f754c4 100644 --- a/test/Integration.test.js +++ b/test/Integration.test.js @@ -1,6 +1,6 @@ "use strict"; -const should = require("should"); +require("should"); const path = require("path"); const webpack = require("../lib/webpack"); diff --git a/test/JsonpExportMainTemplatePlugin.unittest.js b/test/JsonpExportMainTemplatePlugin.unittest.js index 79bc9fc8c..76bd40018 100644 --- a/test/JsonpExportMainTemplatePlugin.unittest.js +++ b/test/JsonpExportMainTemplatePlugin.unittest.js @@ -1,6 +1,6 @@ "use strict"; -const should = require("should"); +require("should"); const sinon = require("sinon"); const TemplatePluginEnvironment = require("./helpers/TemplatePluginEnvironment"); const ConcatSource = require("webpack-sources").ConcatSource; diff --git a/test/LibraryTemplatePlugin.unittest.js b/test/LibraryTemplatePlugin.unittest.js index 86f398c14..76e96e589 100644 --- a/test/LibraryTemplatePlugin.unittest.js +++ b/test/LibraryTemplatePlugin.unittest.js @@ -68,28 +68,28 @@ describe("LibraryTemplatePlugin", function() { { type: "this", assertion: function(compilationContext) { - compilationContext.varExpression.should.be.exactly('this["foo"]'); + compilationContext.varExpression.should.be.exactly("this[\"foo\"]"); should(compilationContext.copyObject).be.undefined(); } }, { type: "window", assertion: function(compilationContext) { - compilationContext.varExpression.should.be.exactly('window["foo"]'); + compilationContext.varExpression.should.be.exactly("window[\"foo\"]"); should(compilationContext.copyObject).be.undefined(); } }, { type: "global", assertion: function(compilationContext) { - compilationContext.varExpression.should.be.exactly('global["foo"]'); + compilationContext.varExpression.should.be.exactly("global[\"foo\"]"); should(compilationContext.copyObject).be.undefined(); } }, { type: "commonjs", assertion: function(compilationContext) { - compilationContext.varExpression.should.be.exactly('exports["foo"]'); + compilationContext.varExpression.should.be.exactly("exports[\"foo\"]"); should(compilationContext.copyObject).be.undefined(); } }, @@ -163,42 +163,42 @@ describe("LibraryTemplatePlugin", function() { [{ type: "var", assertion: function(compilationContext) { - compilationContext.varExpression.should.be.exactly('var foo = foo || {}; foo["bar"] = foo["bar"] || {}; foo["bar"]["baz"]'); + compilationContext.varExpression.should.be.exactly("var foo = foo || {}; foo[\"bar\"] = foo[\"bar\"] || {}; foo[\"bar\"][\"baz\"]"); should(compilationContext.copyObject).be.undefined(); } }, { type: "assign", assertion: function(compilationContext) { - compilationContext.varExpression.should.be.exactly('foo = typeof foo === "object" ? foo : {}; foo["bar"] = foo["bar"] || {}; foo["bar"]["baz"]'); + compilationContext.varExpression.should.be.exactly("foo = typeof foo === \"object\" ? foo : {}; foo[\"bar\"] = foo[\"bar\"] || {}; foo[\"bar\"][\"baz\"]"); should(compilationContext.copyObject).be.undefined(); } }, { type: "this", assertion: function(compilationContext) { - compilationContext.varExpression.should.be.exactly('this["foo"] = this["foo"] || {}; this["foo"]["bar"] = this["foo"]["bar"] || {}; this["foo"]["bar"]["baz"]'); + compilationContext.varExpression.should.be.exactly("this[\"foo\"] = this[\"foo\"] || {}; this[\"foo\"][\"bar\"] = this[\"foo\"][\"bar\"] || {}; this[\"foo\"][\"bar\"][\"baz\"]"); should(compilationContext.copyObject).be.undefined(); } }, { type: "window", assertion: function(compilationContext) { - compilationContext.varExpression.should.be.exactly('window["foo"] = window["foo"] || {}; window["foo"]["bar"] = window["foo"]["bar"] || {}; window["foo"]["bar"]["baz"]'); + compilationContext.varExpression.should.be.exactly("window[\"foo\"] = window[\"foo\"] || {}; window[\"foo\"][\"bar\"] = window[\"foo\"][\"bar\"] || {}; window[\"foo\"][\"bar\"][\"baz\"]"); should(compilationContext.copyObject).be.undefined(); } }, { type: "global", assertion: function(compilationContext) { - compilationContext.varExpression.should.be.exactly('global["foo"] = global["foo"] || {}; global["foo"]["bar"] = global["foo"]["bar"] || {}; global["foo"]["bar"]["baz"]'); + compilationContext.varExpression.should.be.exactly("global[\"foo\"] = global[\"foo\"] || {}; global[\"foo\"][\"bar\"] = global[\"foo\"][\"bar\"] || {}; global[\"foo\"][\"bar\"][\"baz\"]"); should(compilationContext.copyObject).be.undefined(); } }, { type: "commonjs", assertion: function(compilationContext) { - compilationContext.varExpression.should.be.exactly('exports["foo"] = exports["foo"] || {}; exports["foo"]["bar"] = exports["foo"]["bar"] || {}; exports["foo"]["bar"]["baz"]'); + compilationContext.varExpression.should.be.exactly("exports[\"foo\"] = exports[\"foo\"] || {}; exports[\"foo\"][\"bar\"] = exports[\"foo\"][\"bar\"] || {}; exports[\"foo\"][\"bar\"][\"baz\"]"); should(compilationContext.copyObject).be.undefined(); } }, diff --git a/test/ModuleDependencyError.unittest.js b/test/ModuleDependencyError.unittest.js index 7886585f6..a485469da 100644 --- a/test/ModuleDependencyError.unittest.js +++ b/test/ModuleDependencyError.unittest.js @@ -1,8 +1,7 @@ "use strict"; const path = require("path"); -const should = require("should"); -const sinon = require("sinon"); +require("should"); const ModuleDependencyError = require("../lib/ModuleDependencyError"); describe("ModuleDependencyError", () => { diff --git a/test/MultiCompiler.unittest.js b/test/MultiCompiler.unittest.js index 10489a938..ddcd539cd 100644 --- a/test/MultiCompiler.unittest.js +++ b/test/MultiCompiler.unittest.js @@ -278,7 +278,7 @@ describe("MultiCompiler", () => { it("returns a multi-watching object", () => { const result = JSON.stringify(env.result); - result.should.be.exactly('{"watchings":["compiler1","compiler2"],"compiler":{"_plugins":{},"compilers":[{"name":"compiler1"},{"name":"compiler2"}]}}'); + result.should.be.exactly("{\"watchings\":[\"compiler1\",\"compiler2\"],\"compiler\":{\"_plugins\":{},\"compilers\":[{\"name\":\"compiler1\"},{\"name\":\"compiler2\"}]}}"); }); it("calls watch on each compiler with original options", () => { @@ -350,7 +350,7 @@ describe("MultiCompiler", () => { env.callback.callCount.should.be.exactly(1); should(env.callback.getCall(0).args[0]).be.Null(); const stats = JSON.stringify(env.callback.getCall(0).args[1]); - stats.should.be.exactly('{"stats":[{"hash":"foo"},{"hash":"bar"}],"hash":"foobar"}'); + stats.should.be.exactly("{\"stats\":[{\"hash\":\"foo\"},{\"hash\":\"bar\"}],\"hash\":\"foobar\"}"); }); }); }); @@ -518,7 +518,7 @@ describe("MultiCompiler", () => { env.callback.callCount.should.be.exactly(1); should(env.callback.getCall(0).args[0]).be.Null(); const stats = JSON.stringify(env.callback.getCall(0).args[1]); - stats.should.be.exactly('{"stats":[{"hash":"foo"},{"hash":"bar"}],"hash":"foobar"}'); + stats.should.be.exactly("{\"stats\":[{\"hash\":\"foo\"},{\"hash\":\"bar\"}],\"hash\":\"foobar\"}"); }); }); diff --git a/test/MultiStats.unittest.js b/test/MultiStats.unittest.js index 211014e88..653330bdc 100644 --- a/test/MultiStats.unittest.js +++ b/test/MultiStats.unittest.js @@ -1,7 +1,6 @@ "use strict"; -const should = require("should"); -const sinon = require("sinon"); +require("should"); const packageJSON = require("../package.json"); const MultiStats = require("../lib/MultiStats"); diff --git a/test/MultiWatching.unittest.js b/test/MultiWatching.unittest.js index 5ed0589aa..0e860c90c 100644 --- a/test/MultiWatching.unittest.js +++ b/test/MultiWatching.unittest.js @@ -1,7 +1,7 @@ "use strict"; const Tapable = require("tapable"); -const should = require("should"); +require("should"); const sinon = require("sinon"); const MultiWatching = require("../lib/MultiWatching"); diff --git a/test/NodeTemplatePlugin.test.js b/test/NodeTemplatePlugin.test.js index 9a567e0c5..418c605d8 100644 --- a/test/NodeTemplatePlugin.test.js +++ b/test/NodeTemplatePlugin.test.js @@ -1,7 +1,7 @@ /* global describe, it */ "use strict"; -const should = require("should"); +require("should"); const path = require("path"); const webpack = require("../lib/webpack"); diff --git a/test/NodeWatchFileSystem.unittest.js b/test/NodeWatchFileSystem.unittest.js index c684445dd..a848c47f1 100644 --- a/test/NodeWatchFileSystem.unittest.js +++ b/test/NodeWatchFileSystem.unittest.js @@ -4,45 +4,45 @@ var should = require("should"); var NodeWatchFileSystem = require("../lib/node/NodeWatchFileSystem"); describe("NodeWatchFileSystem", function() { - it('should throw if \'files\' argument is not an array', function() { + it("should throw if 'files' argument is not an array", function() { should(function() { - new NodeWatchFileSystem().watch(undefined) + new NodeWatchFileSystem().watch(undefined); }).throw("Invalid arguments: 'files'"); }); - it('should throw if \'dirs\' argument is not an array', function() { + it("should throw if 'dirs' argument is not an array", function() { should(function() { - new NodeWatchFileSystem().watch([], undefined) + new NodeWatchFileSystem().watch([], undefined); }).throw("Invalid arguments: 'dirs'"); }); - it('should throw if \'missing\' argument is not an array', function() { + it("should throw if 'missing' argument is not an array", function() { should(function() { - new NodeWatchFileSystem().watch([], [], undefined) + new NodeWatchFileSystem().watch([], [], undefined); }).throw("Invalid arguments: 'missing'"); }); - it('should throw if \'starttime\' argument is missing', function() { + it("should throw if 'starttime' argument is missing", function() { should(function() { - new NodeWatchFileSystem().watch([], [], [], '42', {}, function() {}) + new NodeWatchFileSystem().watch([], [], [], "42", {}, function() {}); }).throw("Invalid arguments: 'startTime'"); }); - it('should throw if \'callback\' argument is missing', function() { + it("should throw if 'callback' argument is missing", function() { should(function() { - new NodeWatchFileSystem().watch([], [], [], 42, {}, undefined) + new NodeWatchFileSystem().watch([], [], [], 42, {}, undefined); }).throw("Invalid arguments: 'callback'"); }); - it('should throw if \'options\' argument is invalid', function() { + it("should throw if 'options' argument is invalid", function() { should(function() { - new NodeWatchFileSystem().watch([], [], [], 42, 'options', function() {}) + new NodeWatchFileSystem().watch([], [], [], 42, "options", function() {}); }).throw("Invalid arguments: 'options'"); }); - it('should throw if \'callbackUndelayed\' argument is invalid', function() { + it("should throw if 'callbackUndelayed' argument is invalid", function() { should(function() { - new NodeWatchFileSystem().watch([], [], [], 42, {}, function() {}, 'undefined') + new NodeWatchFileSystem().watch([], [], [], 42, {}, function() {}, "undefined"); }).throw("Invalid arguments: 'callbackUndelayed'"); }); @@ -64,7 +64,7 @@ describe("NodeWatchFileSystem", function() { var wfs = new NodeWatchFileSystem(); var watcher = wfs.watch([fileDirect], [], [], startTime, { aggregateTimeout: 1000 - }, function(err, filesModified, dirsModified, missingCreated, fileTimestamps /*, dirTimestamps */ ) { + }, function(err, filesModified, dirsModified, missingCreated, fileTimestamps /*, dirTimestamps */) { if(err) throw err; filesModified.should.be.eql([fileDirect]); dirsModified.should.be.eql([]); @@ -83,7 +83,7 @@ describe("NodeWatchFileSystem", function() { var wfs = new NodeWatchFileSystem(); var watcher = wfs.watch([fileDirect], [], [], startTime, { aggregateTimeout: 1000 - }, function(err, filesModified, dirsModified, missingCreated, fileTimestamps /*, dirTimestamps */ ) { + }, function(err, filesModified, dirsModified, missingCreated, fileTimestamps /*, dirTimestamps */) { if(err) throw err; filesModified.should.be.eql([fileDirect]); dirsModified.should.be.eql([]); diff --git a/test/NullDependency.unittest.js b/test/NullDependency.unittest.js index 107091d2b..cbdfbb0a8 100644 --- a/test/NullDependency.unittest.js +++ b/test/NullDependency.unittest.js @@ -1,6 +1,6 @@ "use strict"; -const should = require("should"); +require("should"); const sinon = require("sinon"); const NullDependency = require("../lib/dependencies/NullDependency"); diff --git a/test/Parser.unittest.js b/test/Parser.unittest.js index 71807dec9..8065c87b3 100644 --- a/test/Parser.unittest.js +++ b/test/Parser.unittest.js @@ -6,6 +6,9 @@ const Parser = require("../lib/Parser"); const BasicEvaluatedExpression = require("../lib/BasicEvaluatedExpression"); describe("Parser", () => { + /* eslint-disable no-undef */ + /* eslint-disable no-unused-vars */ + /* eslint-disable no-inner-declarations */ const testCases = { "call ident": [ function() { @@ -58,8 +61,8 @@ describe("Parser", () => { ], "member expression": [ function() { - test[memberExpr] - test[+memberExpr] + test[memberExpr]; + test[+memberExpr]; }, { expressions: ["memberExpr", "memberExpr"] } @@ -192,6 +195,9 @@ describe("Parser", () => { } ], }; + /* eslint-enable no-undef */ + /* eslint-enable no-unused-vars */ + /* eslint-enable no-inner-declarations */ Object.keys(testCases).forEach((name) => { it("should parse " + name, () => { diff --git a/test/RuleSet.unittest.js b/test/RuleSet.unittest.js index 6fc1f5765..e456bbaa1 100644 --- a/test/RuleSet.unittest.js +++ b/test/RuleSet.unittest.js @@ -325,7 +325,7 @@ describe("RuleSet", () => { test: /\.css$/, use: [ function(data) { - return "style-loader" + return "style-loader"; }, function(data) { return { diff --git a/test/SourceMapDevToolModuleOptionsPlugin.unittest.js b/test/SourceMapDevToolModuleOptionsPlugin.unittest.js index e5b0aab49..0647ca19d 100644 --- a/test/SourceMapDevToolModuleOptionsPlugin.unittest.js +++ b/test/SourceMapDevToolModuleOptionsPlugin.unittest.js @@ -1,8 +1,8 @@ "use strict"; -const should = require("should"); +require("should"); const SourceMapDevToolModuleOptionsPlugin = require("../lib/SourceMapDevToolModuleOptionsPlugin"); -const applyPluginWithOptions = require('./helpers/applyPluginWithOptions'); +const applyPluginWithOptions = require("./helpers/applyPluginWithOptions"); describe("SourceMapDevToolModuleOptionsPlugin", () => { it("has apply function", () => (new SourceMapDevToolModuleOptionsPlugin()).apply.should.be.a.Function()); diff --git a/test/Template.unittest.js b/test/Template.unittest.js index 7e7bf52bb..6a5a7c6a6 100644 --- a/test/Template.unittest.js +++ b/test/Template.unittest.js @@ -1,6 +1,6 @@ "use strict"; -const should = require("should"); +require("should"); const Template = require("../lib/Template"); diff --git a/test/Validation.test.js b/test/Validation.test.js index 3429c4996..0fd88b3c1 100644 --- a/test/Validation.test.js +++ b/test/Validation.test.js @@ -220,7 +220,7 @@ describe("Validation", () => { try { webpack(testCase.config); } catch(err) { - if(err.name !== 'WebpackOptionsValidationError') throw err; + if(err.name !== "WebpackOptionsValidationError") throw err; if(testCase.test) { testCase.test(err); diff --git a/test/WatchDetection.test.js b/test/WatchDetection.test.js index 0b4614e05..8786150cc 100644 --- a/test/WatchDetection.test.js +++ b/test/WatchDetection.test.js @@ -1,7 +1,7 @@ "use strict"; /*globals describe it before after */ -const should = require("should"); +require("should"); const path = require("path"); const fs = require("fs"); const MemoryFs = require("memory-fs"); @@ -93,13 +93,13 @@ describe("WatchDetection", () => { function step4() { onChange = () => { if(memfs.readFileSync("/bundle.js").toString().indexOf("correct") >= 0) - step4(); + step5(); }; fs.writeFile(file2Path, "correct", "utf-8", handleError); } - function step4() { + function step5() { onChange = null; watcher.close(() => { diff --git a/test/WatchTestCases.test.js b/test/WatchTestCases.test.js index 611c56468..1b25c248e 100644 --- a/test/WatchTestCases.test.js +++ b/test/WatchTestCases.test.js @@ -1,6 +1,6 @@ "use strict"; -const should = require("should"); +require("should"); const path = require("path"); const fs = require("fs"); const vm = require("vm"); @@ -68,7 +68,7 @@ describe("WatchTestCases", () => { const dest = path.join(__dirname, "js", "watch-src", category.name); if(!fs.existsSync(dest)) fs.mkdirSync(dest); - }) + }); describe(category.name, () => { category.tests.forEach((testName) => { describe(testName, () => { diff --git a/test/WatcherEvents.test.js b/test/WatcherEvents.test.js index f23e13e54..f47fa8539 100644 --- a/test/WatcherEvents.test.js +++ b/test/WatcherEvents.test.js @@ -2,7 +2,7 @@ /*globals describe it before after */ const path = require("path"); -const should = require("should"); +require("should"); const MemoryFs = require("memory-fs"); const webpack = require("../"); diff --git a/test/WebpackError.unittest.js b/test/WebpackError.unittest.js index ec7c9b111..f52692e4b 100644 --- a/test/WebpackError.unittest.js +++ b/test/WebpackError.unittest.js @@ -2,7 +2,7 @@ const util = require("util"); -const should = require("should"); +require("should"); const WebpackError = require("../lib/WebpackError"); describe("WebpackError", () => { diff --git a/test/WebpackMissingModule.unittest.js b/test/WebpackMissingModule.unittest.js index 159182c57..d5b41b334 100644 --- a/test/WebpackMissingModule.unittest.js +++ b/test/WebpackMissingModule.unittest.js @@ -8,7 +8,7 @@ describe("WebpackMissingModule", () => { describe("#moduleCode", () => { it("returns an error message based on given error message", () => { const errorMessage = WebpackMissingModule.moduleCode("mock message"); - should(errorMessage).be.eql("var e = new Error(\"Cannot find module \\\"mock message\\\"\"); e.code = \'MODULE_NOT_FOUND\'; throw e;"); + should(errorMessage).be.eql("var e = new Error(\"Cannot find module \\\"mock message\\\"\"); e.code = 'MODULE_NOT_FOUND'; throw e;"); }); }); diff --git a/test/checkArrayExpectation.js b/test/checkArrayExpectation.js index d2c22290c..846af096a 100644 --- a/test/checkArrayExpectation.js +++ b/test/checkArrayExpectation.js @@ -29,4 +29,4 @@ module.exports = function checkArrayExpectation(testDirectory, object, kind, fil } else if(array.length > 0) { return done(new Error(`${upperCaseKind}s while compiling:\n\n${array.join("\n\n")}`)), true; } -} +}; diff --git a/test/compareLocations.unittest.js b/test/compareLocations.unittest.js index 3b36d8060..c378182aa 100644 --- a/test/compareLocations.unittest.js +++ b/test/compareLocations.unittest.js @@ -43,7 +43,7 @@ describe("compareLocations", () => { }); it("returns -1 when the first location line number comes before the second location line number", () => { - return compareLocations(a, b).should.be.exactly(-1) + return compareLocations(a, b).should.be.exactly(-1); }); it("returns 1 when the first location line number comes after the second location line number", () => diff --git a/test/formatLocation.unittest.js b/test/formatLocation.unittest.js index 979ee5c9a..6fe04edf8 100644 --- a/test/formatLocation.unittest.js +++ b/test/formatLocation.unittest.js @@ -1,6 +1,6 @@ "use strict"; -const should = require("should"); +require("should"); const formatLocation = require("../lib/formatLocation"); describe("formatLocation", () => { diff --git a/test/identifier.unittest.js b/test/identifier.unittest.js index 08e08d2b7..6a2b15c3d 100644 --- a/test/identifier.unittest.js +++ b/test/identifier.unittest.js @@ -2,7 +2,6 @@ "use strict"; const should = require("should"); -const path = require("path"); const identifierUtil = require("../lib/util/identifier"); From 3ea3fda96272393832c91d18169508e5175a05be Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 15 Nov 2017 18:43:19 +0100 Subject: [PATCH 37/85] fix unit test --- test/AmdMainTemplatePlugin.unittest.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/AmdMainTemplatePlugin.unittest.js b/test/AmdMainTemplatePlugin.unittest.js index 7b19ba950..383467e93 100644 --- a/test/AmdMainTemplatePlugin.unittest.js +++ b/test/AmdMainTemplatePlugin.unittest.js @@ -96,8 +96,12 @@ describe("AmdMainTemplatePlugin", () => { describe("with only local dependencies", () => { beforeEach(() => { + const externalFlag = { + external: false + }; + const noExternals = env.modulesListWithExternals.map((module) => Object.assign({}, module, externalFlag)); env.chunk = { - getModules: () => env.modulesListWithExternals + getModules: () => noExternals }; env.eventBinding = setupPluginAndGetEventBinding(); }); From 10d3a5943c603b10cc98d5056a2efc9da1c4c851 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 16 Nov 2017 07:06:30 +0100 Subject: [PATCH 38/85] ignore incorrect linter errors in test files --- test/NodeTemplatePlugin.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/NodeTemplatePlugin.test.js b/test/NodeTemplatePlugin.test.js index 418c605d8..db82a01a3 100644 --- a/test/NodeTemplatePlugin.test.js +++ b/test/NodeTemplatePlugin.test.js @@ -27,6 +27,7 @@ describe("NodeTemplatePlugin", () => { if(err) return err; stats.hasErrors().should.be.not.ok(); stats.hasWarnings().should.be.not.ok(); + // eslint-disable-next-line node/no-missing-require const result = require("./js/result").abc; result.nextTick.should.be.equal(process.nextTick); result.fs.should.be.equal(require("fs")); @@ -64,6 +65,7 @@ describe("NodeTemplatePlugin", () => { }, (err, stats) => { if(err) return err; stats.hasErrors().should.be.not.ok(); + // eslint-disable-next-line node/no-missing-require const result = require("./js/result2"); result.nextTick.should.be.equal(process.nextTick); result.fs.should.be.equal(require("fs")); From ce266cb6f649fc00c731b4af8cd64c9b33f2bb15 Mon Sep 17 00:00:00 2001 From: Anuraag Agrawal Date: Thu, 16 Nov 2017 15:20:50 +0900 Subject: [PATCH 39/85] Support resourceQuery in context dependencies. --- lib/ContextModule.js | 16 +++++++++++++-- lib/ContextModuleFactory.js | 4 +++- lib/ContextReplacementPlugin.js | 2 +- test/cases/parsing/context/index.js | 7 ++++++- .../parsing/context/loaders/queryloader.js | 7 +++++++ .../context-replacement/d/index.js | 10 ++++++++++ .../context-replacement/d/modules/a.js | 1 + .../context-replacement/d/queryloader.js | 7 +++++++ .../context-replacement/d/webpack.config.js | 20 +++++++++++++++++++ 9 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 test/cases/parsing/context/loaders/queryloader.js create mode 100644 test/configCases/context-replacement/d/index.js create mode 100644 test/configCases/context-replacement/d/modules/a.js create mode 100644 test/configCases/context-replacement/d/queryloader.js create mode 100644 test/configCases/context-replacement/d/webpack.config.js diff --git a/lib/ContextModule.js b/lib/ContextModule.js index d9e1d945d..e25096fa7 100644 --- a/lib/ContextModule.js +++ b/lib/ContextModule.js @@ -22,8 +22,20 @@ class ContextModule extends Module { // Info from Factory this.resolveDependencies = resolveDependencies; - this.options = options; - this.context = options.resource; + let resource, resourceQuery; + const queryIdx = options.resource.indexOf("?"); + if(queryIdx >= 0) { + resource = options.resource.substr(0, queryIdx); + resourceQuery = options.resource.substr(queryIdx); + } else { + resource = options.resource; + resourceQuery = ""; + } + this.options = Object.assign({}, options, { + resource: resource, + resourceQuery: resourceQuery + }); + this.context = this.options.resource; // Info from Build this.builtTime = undefined; diff --git a/lib/ContextModuleFactory.js b/lib/ContextModuleFactory.js index 774444c51..80c742c64 100644 --- a/lib/ContextModuleFactory.js +++ b/lib/ContextModuleFactory.js @@ -89,12 +89,14 @@ module.exports = class ContextModuleFactory extends Tapable { resolveDependencies(fs, options, callback) { const cmf = this; let resource = options.resource; + let resourceQuery = options.resourceQuery; let recursive = options.recursive; let regExp = options.regExp; let include = options.include; let exclude = options.exclude; if(!regExp || !resource) return callback(null, []); + const addDirectory = (directory, callback) => { fs.readdir(directory, (err, files) => { if(err) return callback(err); @@ -131,7 +133,7 @@ module.exports = class ContextModuleFactory extends Tapable { this.applyPluginsAsyncWaterfall("alternatives", [obj], (err, alternatives) => { if(err) return callback(err); alternatives = alternatives.filter(obj => regExp.test(obj.request)).map(obj => { - const dep = new ContextElementDependency(obj.request); + const dep = new ContextElementDependency(obj.request + resourceQuery, obj.request); dep.optional = true; return dep; }); diff --git a/lib/ContextReplacementPlugin.js b/lib/ContextReplacementPlugin.js index 761dd4dbf..4fb1b6a8a 100644 --- a/lib/ContextReplacementPlugin.js +++ b/lib/ContextReplacementPlugin.js @@ -101,7 +101,7 @@ const createResolveDependenciesFromContextMap = (createContextMap) => { createContextMap(fs, (err, map) => { if(err) return callback(err); const dependencies = Object.keys(map).map((key) => { - return new ContextElementDependency(map[key], key); + return new ContextElementDependency(map[key] + options.resourceQuery, key); }); callback(null, dependencies); }); diff --git a/test/cases/parsing/context/index.js b/test/cases/parsing/context/index.js index 888b04bd6..b8d9e0979 100644 --- a/test/cases/parsing/context/index.js +++ b/test/cases/parsing/context/index.js @@ -2,6 +2,11 @@ it("should be able to load a file with the require.context method", function() { require.context("./templates")("./tmpl").should.be.eql("test template"); (require.context("./././templates"))("./tmpl").should.be.eql("test template"); (require.context("././templates/.")("./tmpl")).should.be.eql("test template"); + require.context("./loaders/queryloader?dog=bark!./templates?cat=meow")("./tmpl").should.be.eql({ + resourceQuery: "?cat=meow", + query: "?dog=bark", + prev: "module.exports = \"test template\";" + }); require . context ( "." + "/." + "/" + "templ" + "ates" ) ( "./subdir/tmpl.js" ).should.be.eql("subdir test template"); require.context("./templates", true, /./)("xyz").should.be.eql("xyz"); }); @@ -43,4 +48,4 @@ it("should execute an empty context", function() { (function() { context(""); }).should.throw(); -}); \ No newline at end of file +}); diff --git a/test/cases/parsing/context/loaders/queryloader.js b/test/cases/parsing/context/loaders/queryloader.js new file mode 100644 index 000000000..02707b2ba --- /dev/null +++ b/test/cases/parsing/context/loaders/queryloader.js @@ -0,0 +1,7 @@ +module.exports = function(content) { + return "module.exports = " + JSON.stringify({ + resourceQuery: this.resourceQuery, + query: this.query, + prev: content + }); +}; diff --git a/test/configCases/context-replacement/d/index.js b/test/configCases/context-replacement/d/index.js new file mode 100644 index 000000000..e8a4f576f --- /dev/null +++ b/test/configCases/context-replacement/d/index.js @@ -0,0 +1,10 @@ +it("should replace a context with resource query and manual map", function() { + function rqInContext(x) { + return require(x); + } + rqInContext("a").should.be.eql({ + resourceQuery: "?cats=meow", + query: "?lions=roar", + prev: "module.exports = \"a\";\n", + }); +}); diff --git a/test/configCases/context-replacement/d/modules/a.js b/test/configCases/context-replacement/d/modules/a.js new file mode 100644 index 000000000..6cd1d0075 --- /dev/null +++ b/test/configCases/context-replacement/d/modules/a.js @@ -0,0 +1 @@ +module.exports = "a"; diff --git a/test/configCases/context-replacement/d/queryloader.js b/test/configCases/context-replacement/d/queryloader.js new file mode 100644 index 000000000..02707b2ba --- /dev/null +++ b/test/configCases/context-replacement/d/queryloader.js @@ -0,0 +1,7 @@ +module.exports = function(content) { + return "module.exports = " + JSON.stringify({ + resourceQuery: this.resourceQuery, + query: this.query, + prev: content + }); +}; diff --git a/test/configCases/context-replacement/d/webpack.config.js b/test/configCases/context-replacement/d/webpack.config.js new file mode 100644 index 000000000..a082e52ca --- /dev/null +++ b/test/configCases/context-replacement/d/webpack.config.js @@ -0,0 +1,20 @@ +var path = require("path"); +var webpack = require("../../../../"); + +module.exports = { + module: { + rules: [ + { + test: /a\.js$/, + use: [ + "./queryloader?lions=roar" + ] + } + ] + }, + plugins: [ + new webpack.ContextReplacementPlugin(/context-replacement.d$/, path.resolve(__dirname, "modules?cats=meow"), { + "a": "./a", + }) + ] +}; From e481ea53fdfde98084bfce12e0fa5f17656833ef Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 16 Nov 2017 08:59:22 +0100 Subject: [PATCH 40/85] add linting for schemas add missing descriptions in schema --- lib/WebpackOptionsValidationError.js | 52 +++- package.json | 4 +- schemas/webpackOptionsSchema.json | 414 ++++++++++++++++++++++----- test/Schemas.lint.js | 131 +++++++++ test/Validation.test.js | 74 +++-- test/lint-mocha.opts | 1 + 6 files changed, 577 insertions(+), 99 deletions(-) create mode 100644 test/Schemas.lint.js create mode 100644 test/lint-mocha.opts diff --git a/lib/WebpackOptionsValidationError.js b/lib/WebpackOptionsValidationError.js index b342b9dc4..4b3e80754 100644 --- a/lib/WebpackOptionsValidationError.js +++ b/lib/WebpackOptionsValidationError.js @@ -35,10 +35,28 @@ const getSchemaPartText = (schemaPart, additionalPath) => { while(schemaPart.$ref) schemaPart = getSchemaPart(schemaPart.$ref); let schemaText = WebpackOptionsValidationError.formatSchema(schemaPart); if(schemaPart.description) - schemaText += `\n${schemaPart.description}`; + schemaText += `\n-> ${schemaPart.description}`; return schemaText; }; +const getSchemaPartDescription = (schemaPart, additionalPath) => { + if(additionalPath) { + for(let i = 0; i < additionalPath.length; i++) { + const inner = schemaPart[additionalPath[i]]; + if(inner) + schemaPart = inner; + } + } + while(schemaPart.$ref) schemaPart = getSchemaPart(schemaPart.$ref); + if(schemaPart.description) + return `\n-> ${schemaPart.description}`; + return ""; +}; + +const filterChildren = children => { + return children.filter(err => err.keyword !== "anyOf" && err.keyword !== "allOf" && err.keyword !== "oneOf"); +}; + const indent = (str, prefix, firstLine) => { if(firstLine) { return prefix + str.replace(/\n(?!$)/g, "\n" + prefix); @@ -143,8 +161,16 @@ class WebpackOptionsValidationError extends WebpackError { return baseMessage; } else if(err.keyword === "oneOf" || err.keyword === "anyOf") { if(err.children && err.children.length > 0) { + if(err.schema.length === 1) { + const lastChild = err.children[err.children.length - 1]; + const remainingChildren = err.children.slice(0, err.children.length - 1); + return WebpackOptionsValidationError.formatValidationError(Object.assign({}, lastChild, { + children: remainingChildren, + parentSchema: Object.assign({}, err.parentSchema, lastChild.parentSchema) + })); + } return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}\n` + - `Details:\n${err.children.map(err => " * " + indent(WebpackOptionsValidationError.formatValidationError(err), " ", false)).join("\n")}`; + `Details:\n${filterChildren(err.children).map(err => " * " + indent(WebpackOptionsValidationError.formatValidationError(err), " ", false)).join("\n")}`; } return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}`; @@ -158,29 +184,33 @@ class WebpackOptionsValidationError extends WebpackError { } else if(err.keyword === "type") { switch(err.params.type) { case "object": - return `${dataPath} should be an object.`; + return `${dataPath} should be an object.${getSchemaPartDescription(err.parentSchema)}`; case "string": - return `${dataPath} should be a string.`; + return `${dataPath} should be a string.${getSchemaPartDescription(err.parentSchema)}`; case "boolean": - return `${dataPath} should be a boolean.`; + return `${dataPath} should be a boolean.${getSchemaPartDescription(err.parentSchema)}`; case "number": - return `${dataPath} should be a number.`; + return `${dataPath} should be a number.${getSchemaPartDescription(err.parentSchema)}`; case "array": return `${dataPath} should be an array:\n${getSchemaPartText(err.parentSchema)}`; } return `${dataPath} should be ${err.params.type}:\n${getSchemaPartText(err.parentSchema)}`; } else if(err.keyword === "instanceof") { - return `${dataPath} should be an instance of ${getSchemaPartText(err.parentSchema)}.`; + return `${dataPath} should be an instance of ${getSchemaPartText(err.parentSchema)}`; } else if(err.keyword === "required") { const missingProperty = err.params.missingProperty.replace(/^\./, ""); return `${dataPath} misses the property '${missingProperty}'.\n${getSchemaPartText(err.parentSchema, ["properties", missingProperty])}`; - } else if(err.keyword === "minLength" || err.keyword === "minItems") { + } else if(err.keyword === "minimum") { + return `${dataPath} ${err.message}.${getSchemaPartDescription(err.parentSchema)}`; + } else if(err.keyword === "uniqueItems") { + return `${dataPath} should not contain the item '${err.data[err.params.i]}' twice.${getSchemaPartDescription(err.parentSchema)}`; + } else if(err.keyword === "minLength" || err.keyword === "minItems" || err.keyword === "minProperties") { if(err.params.limit === 1) - return `${dataPath} should not be empty.`; + return `${dataPath} should not be empty.${getSchemaPartDescription(err.parentSchema)}`; else - return `${dataPath} ${err.message}`; + return `${dataPath} ${err.message}${getSchemaPartDescription(err.parentSchema)}`; } else if(err.keyword === "absolutePath") { - const baseMessage = `${dataPath}: ${err.message}`; + const baseMessage = `${dataPath}: ${err.message}${getSchemaPartDescription(err.parentSchema)}`; if(dataPath === "configuration.output.filename") { return `${baseMessage}\n` + "Please use output.path to specify absolute path and output.filename for the file name."; diff --git a/package.json b/package.json index ae409e943..2b7223970 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "express": "~4.13.1", "extract-text-webpack-plugin": "^3.0.0", "file-loader": "^0.11.2", + "glob": "^7.1.2", "i18n-webpack-plugin": "^1.0.0", "istanbul": "^0.4.5", "jade": "^1.11.0", @@ -103,10 +104,11 @@ "circleci:lint": "npm run lint-files && npm run nsp", "build:examples": "cd examples && node buildAll.js", "pretest": "npm run lint-files", - "lint-files": "npm run lint && npm run beautify-lint", + "lint-files": "npm run lint && npm run beautify-lint && npm run schema-lint", "lint": "eslint lib bin hot buildin \"test/**/webpack.config.js\" \"test/binCases/**/test.js\" \"examples/**/webpack.config.js\"", "fix": "npm run lint -- --fix", "beautify-lint": "beautify-lint \"lib/**/*.js\" \"hot/**/*.js\" \"bin/**/*.js\" \"benchmark/*.js\" \"test/*.js\"", + "schema-lint": "mocha test/*.lint.js --opts test/lint-mocha.opts", "nsp": "nsp check --output summary", "benchmark": "mocha --max-old-space-size=4096 --harmony --trace-deprecation test/*.benchmark.js -R spec", "cover": "npm run cover:init && npm run cover:all && npm run cover:report", diff --git a/schemas/webpackOptionsSchema.json b/schemas/webpackOptionsSchema.json index a7f8ddefa..9eda0fcea 100644 --- a/schemas/webpackOptionsSchema.json +++ b/schemas/webpackOptionsSchema.json @@ -3,6 +3,7 @@ "definitions": { "common.arrayOfStringOrStringArrayValues": { "items": { + "description": "string or array of strings", "anyOf": [ { "minLength": 1, @@ -10,6 +11,7 @@ }, { "items": { + "description": "A non-empty string", "minLength": 1, "type": "string" }, @@ -21,6 +23,7 @@ }, "common.arrayOfStringValues": { "items": { + "description": "A non-empty string", "minLength": 1, "type": "string" }, @@ -28,6 +31,7 @@ }, "common.nonEmptyArrayOfUniqueStringValues": { "items": { + "description": "A non-empty string", "minLength": 1, "type": "string" }, @@ -36,11 +40,11 @@ "uniqueItems": true }, "entry": { - "description": "The entry point(s) of the compilation.", "oneOf": [ { "minProperties": 1, "additionalProperties": { + "description": "An entry point with name", "oneOf": [ { "description": "The string is resolved to a module which is loaded upon startup.", @@ -49,7 +53,11 @@ }, { "description": "All modules are loaded upon startup. The last one is exported.", - "$ref": "#/definitions/common.nonEmptyArrayOfUniqueStringValues" + "anyOf": [ + { + "$ref": "#/definitions/common.nonEmptyArrayOfUniqueStringValues" + } + ] } ] }, @@ -57,20 +65,20 @@ "type": "object" }, { - "description": "The string is resolved to a module which is loaded upon startup.", + "description": "An entry point without name. The string is resolved to a module which is loaded upon startup.", "minLength": 1, "type": "string" }, { - "allOf": [ + "description": "An entry point without name. All modules are loaded upon startup. The last one is exported.", + "anyOf": [ { "$ref": "#/definitions/common.nonEmptyArrayOfUniqueStringValues" } - ], - "description": "All modules are loaded upon startup. The last one is exported." + ] }, { - "description": "function returning an entry object or a promise.", + "description": "A Function returning an entry object, an entry string, an entry array or a promise to these things.", "instanceof": "Function" } ] @@ -83,6 +91,7 @@ }, { "additionalProperties": { + "description": "The dependency used for the external", "anyOf": [ { "type": "string" @@ -108,24 +117,30 @@ }, { "items": { - "$ref": "#/definitions/externals" + "description": "External configuration", + "anyOf": [ + { + "$ref": "#/definitions/externals" + } + ] }, "type": "array" } - ], - "description": "Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`." + ] }, "module": { "additionalProperties": false, - "description": "Options affecting the normal modules (`NormalModuleFactory`).", "properties": { "exprContextCritical": { + "description": "Enable warnings for full dynamic dependencies", "type": "boolean" }, "exprContextRecursive": { + "description": "Enable recursive directory lookup for full dynamic dependencies", "type": "boolean" }, "exprContextRegExp": { + "description": "Sets the default regular expression for full dynamic dependencies", "anyOf": [ { "type": "boolean" @@ -136,21 +151,23 @@ ] }, "exprContextRequest": { + "description": "Set the default request for full dynamic dependencies", "type": "string" }, "loaders": { - "allOf": [ + "description": "An array of automatically applied loaders.", + "anyOf": [ { "$ref": "#/definitions/ruleSet-rules" } - ], - "description": "An array of automatically applied loaders." + ] }, "noParse": { "description": "Don't parse files matching. It's matched against the full resolved request.", "anyOf": [ { "items": { + "description": "A regular expression, when matched the module is not parsed", "instanceof": "RegExp" }, "minItems": 1, @@ -164,6 +181,7 @@ }, { "items": { + "description": "An absolute path, when the module starts with this path it is not parsed", "type": "string", "absolutePath": true }, @@ -185,12 +203,15 @@ "description": "An array of rules applied for modules." }, "unknownContextCritical": { + "description": "Enable warnings when using the require function in a not statically analyse-able way", "type": "boolean" }, "unknownContextRecursive": { + "description": "Enable recursive directory lookup when using the require function in a not statically analyse-able way", "type": "boolean" }, "unknownContextRegExp": { + "description": "Sets the regular expression when using the require function in a not statically analyse-able way", "anyOf": [ { "type": "boolean" @@ -201,9 +222,11 @@ ] }, "unknownContextRequest": { + "description": "Sets the request when using the require function in a not statically analyse-able way", "type": "string" }, "unsafeCache": { + "description": "Cache the resolving of module requests", "anyOf": [ { "type": "boolean" @@ -214,18 +237,23 @@ ] }, "wrappedContextCritical": { + "description": "Enable warnings for partial dynamic dependencies", "type": "boolean" }, "wrappedContextRecursive": { + "description": "Enable recursive directory lookup for partial dynamic dependencies", "type": "boolean" }, "wrappedContextRegExp": { + "description": "Set the inner regular expression for partial dynamic dependencies", "instanceof": "RegExp" }, "strictExportPresence": { + "description": "Emit errors instead of warnings when imported names don't exist in imported module", "type": "boolean" }, "strictThisContextOnImports": { + "description": "Handle the this context correctly according to the spec for namespace objects", "type": "boolean" } }, @@ -233,7 +261,6 @@ }, "output": { "additionalProperties": false, - "description": "Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk.", "properties": { "auxiliaryComment": { "description": "Add a comment in the UMD wrapper.", @@ -247,15 +274,19 @@ "description": "Set explicit comments for `commonjs`, `commonjs2`, `amd`, and `root`.", "properties": { "amd": { + "description": "Set comment for `amd` section in UMD", "type": "string" }, "commonjs": { + "description": "Set comment for `commonjs` (exports) section in UMD", "type": "string" }, "commonjs2": { + "description": "Set comment for `commonjs2` (module.exports) section in UMD", "type": "string" }, "root": { + "description": "Set comment for `root` (global variable) section in UMD", "type": "string" } }, @@ -300,17 +331,6 @@ }, { "description": "An object similar to `module.loaders` enables it for specific files.", - "properties": { - "exclude": { - "type": "string" - }, - "include": { - "type": "string" - }, - "test": { - "type": "string" - } - }, "type": "object" } ] @@ -332,18 +352,25 @@ "absolutePath": false }, "hashDigest": { - "minLength": 1, - "type": "string" + "description": "Digest type used for the hash", + "enum": [ + "latin1", + "hex", + "base64" + ] }, "hashDigestLength": { + "description": "Number of chars which are used for the hash", "minimum": 1, "type": "number" }, "hashFunction": { + "description": "Algorithm used for generation the hash (see node.js crypto package)", "minLength": 1, "type": "string" }, "hashSalt": { + "description": "Any string which is added to the hash to salt it", "minLength": 1, "type": "string" }, @@ -372,22 +399,34 @@ }, { "items": { + "description": "A part of the library name", "type": "string" }, "type": "array" }, { "type": "object", + "additionalProperties": false, "properties": { - "root": { "type": "string" }, - "amd": { "type": "string" }, - "commonjs": { "type": "string" } + "root": { + "description": "Name of the property exposed globally by a UMD library", + "type": "string" + }, + "amd": { + "description": "Name of the exposed AMD library in the UMD", + "type": "string" + }, + "commonjs": { + "description": "Name of the exposed commonjs export in the UMD", + "type": "string" + } } } ], "description": "If set, export the bundle as library. `output.library` is the name." }, "libraryTarget": { + "description": "Type of library", "enum": [ "var", "assign", @@ -404,6 +443,7 @@ ] }, "libraryExport": { + "description": "Specify which export should be exposed as library", "anyOf": [ { "type": "string" @@ -450,24 +490,30 @@ "additionalProperties": false, "properties": { "alias": { + "description": "Redirect module requests", "anyOf": [ { "additionalProperties": { + "description": "New request", "type": "string" }, "type": "object" }, { "items": { + "description": "Alias configuration", "additionalProperties": false, "properties": { "alias": { + "description": "New request", "type": "string" }, "name": { + "description": "Request to be redirected", "type": "string" }, "onlyModule": { + "description": "Redirect only exact matching request", "type": "boolean" } }, @@ -478,47 +524,93 @@ ] }, "aliasFields": { - "$ref": "#/definitions/common.arrayOfStringOrStringArrayValues" + "description": "Fields in the description file (package.json) which are used to redirect requests inside the module", + "anyOf": [ + { + "$ref": "#/definitions/common.arrayOfStringOrStringArrayValues" + } + ] }, "cachePredicate": { + "description": "Predicate function to decide which requests should be cached", "instanceof": "Function" }, "cacheWithContext": { + "description": "Include the context information in the cache identifier when caching", "type": "boolean" }, "descriptionFiles": { - "$ref": "#/definitions/common.arrayOfStringValues" + "description": "Filenames used to find a description file", + "anyOf": [ + { + "$ref": "#/definitions/common.arrayOfStringValues" + } + ] }, "enforceExtension": { + "description": "Enforce using one of the extensions from the extensions option", "type": "boolean" }, "enforceModuleExtension": { + "description": "Enforce using one of the module extensions from the moduleExtensions option", "type": "boolean" }, "extensions": { - "$ref": "#/definitions/common.arrayOfStringValues" + "description": "Extensions added to the request when trying to find the file", + "anyOf": [ + { + "$ref": "#/definitions/common.arrayOfStringValues" + } + ] + }, + "fileSystem": { + "description": "Filesystem for the resolver" }, - "fileSystem": {}, "mainFields": { - "$ref": "#/definitions/common.arrayOfStringOrStringArrayValues" + "description": "Field names from the description file (package.json) which are used to find the default entry point", + "anyOf": [ + { + "$ref": "#/definitions/common.arrayOfStringOrStringArrayValues" + } + ] }, "mainFiles": { - "$ref": "#/definitions/common.arrayOfStringValues" + "description": "Filenames used to find the default entry point if there is no description file or main field", + "anyOf": [ + { + "$ref": "#/definitions/common.arrayOfStringValues" + } + ] }, "moduleExtensions": { - "$ref": "#/definitions/common.arrayOfStringValues" + "description": "Extenstions added to the module request when trying to find the module", + "anyOf": [ + { + "$ref": "#/definitions/common.arrayOfStringValues" + } + ] }, "modules": { - "$ref": "#/definitions/common.arrayOfStringValues" + "description": "Folder names or directory paths where to find modules", + "anyOf": [ + { + "$ref": "#/definitions/common.arrayOfStringValues" + } + ] }, "plugins": { + "description": "Plugins for the resolver", "type": "array" }, - "resolver": {}, + "resolver": { + "description": "Custom resolver" + }, "symlinks": { + "description": "Enable resolving symlinks to the original location", "type": "boolean" }, "unsafeCache": { + "description": "Enable caching of successfully resolved requests", "anyOf": [ { "type": "boolean" @@ -530,6 +622,7 @@ ] }, "useSyncFileSystemCalls": { + "description": "Use synchronous filesystem calls for the resolver", "type": "boolean" } }, @@ -554,22 +647,52 @@ "additionalProperties": false, "properties": { "and": { - "$ref": "#/definitions/ruleSet-conditions" + "description": "Logical AND", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-conditions" + } + ] }, "exclude": { - "$ref": "#/definitions/ruleSet-condition" + "description": "Exclude all modules matching any of these conditions", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-condition" + } + ] }, "include": { - "$ref": "#/definitions/ruleSet-condition" + "description": "Exclude all modules matching not any of these conditions", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-condition" + } + ] }, "not": { - "$ref": "#/definitions/ruleSet-conditions" + "description": "Logical NOT", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-conditions" + } + ] }, "or": { - "$ref": "#/definitions/ruleSet-conditions" + "description": "Logical OR", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-conditions" + } + ] }, "test": { - "$ref": "#/definitions/ruleSet-condition" + "description": "Exclude all modules matching any of these conditions", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-condition" + } + ] } }, "type": "object" @@ -578,7 +701,12 @@ }, "ruleSet-conditions": { "items": { - "$ref": "#/definitions/ruleSet-condition" + "description": "A rule condition", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-condition" + } + ] }, "type": "array" }, @@ -600,12 +728,14 @@ "additionalProperties": false, "properties": { "enforce": { + "description": "Enforce this rule as pre or post step", "enum": [ "pre", "post" ] }, "exclude": { + "description": "Shortcut for resource.exclude", "allOf": [ { "$ref": "#/definitions/ruleSet-condition" @@ -616,6 +746,7 @@ ] }, "include": { + "description": "Shortcut for resource.include", "allOf": [ { "$ref": "#/definitions/ruleSet-condition" @@ -626,6 +757,7 @@ ] }, "issuer": { + "description": "Match the issuer of the module (The module pointing to this module)", "allOf": [ { "$ref": "#/definitions/ruleSet-condition" @@ -636,6 +768,7 @@ ] }, "loader": { + "description": "Shortcut for use.loader", "anyOf": [ { "$ref": "#/definitions/ruleSet-loader" @@ -646,22 +779,44 @@ ] }, "loaders": { - "$ref": "#/definitions/ruleSet-use" + "description": "Shortcut for use.loader", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-use" + } + ] }, "oneOf": { - "$ref": "#/definitions/ruleSet-rules" + "description": "Only execute the first matching rule in this array", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-rules" + } + ] }, "options": { - "$ref": "#/definitions/ruleSet-query" + "description": "Shortcut for use.options", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-query" + } + ] }, "parser": { + "description": "Options for parsing", "additionalProperties": true, "type": "object" }, "query": { - "$ref": "#/definitions/ruleSet-query" + "description": "Shortcut for use.query", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-query" + } + ] }, "resource": { + "description": "Match the resource path of the module", "allOf": [ { "$ref": "#/definitions/ruleSet-condition" @@ -672,15 +827,31 @@ ] }, "resourceQuery": { - "$ref": "#/definitions/ruleSet-condition" + "description": "Match the resource query of the module", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-condition" + } + ] }, "compiler": { - "$ref": "#/definitions/ruleSet-condition" + "description": "Match the child compiler name", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-condition" + } + ] }, "rules": { - "$ref": "#/definitions/ruleSet-rules" + "description": "Match and execute these rules when this rule is matched", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-rules" + } + ] }, "test": { + "description": "Shortcut for resource.test", "allOf": [ { "$ref": "#/definitions/ruleSet-condition" @@ -691,14 +862,24 @@ ] }, "use": { - "$ref": "#/definitions/ruleSet-use" + "description": "Modifiers applied to the module when rule is matched", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-use" + } + ] } }, "type": "object" }, "ruleSet-rules": { "items": { - "$ref": "#/definitions/ruleSet-rule" + "description": "A rule", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-rule" + } + ] }, "type": "array" }, @@ -712,7 +893,12 @@ }, { "items": { - "$ref": "#/definitions/ruleSet-use-item" + "description": "An use item", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-use-item" + } + ] }, "type": "array" } @@ -730,13 +916,28 @@ "additionalProperties": false, "properties": { "loader": { - "$ref": "#/definitions/ruleSet-loader" + "description": "Loader name", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-loader" + } + ] }, "options": { - "$ref": "#/definitions/ruleSet-query" + "description": "Loader options", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-query" + } + ] }, "query": { - "$ref": "#/definitions/ruleSet-query" + "description": "Loader query", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-query" + } + ] } }, "type": "object" @@ -764,7 +965,12 @@ { "type": "array", "items": { - "$ref": "#/definitions/filter-item-types" + "description": "Rule to filter", + "anyOf": [ + { + "$ref": "#/definitions/filter-item-types" + } + ] } } ] @@ -799,11 +1005,13 @@ "dependencies": { "description": "References to other configurations to depend on.", "items": { + "description": "References to another configuration to depend on.", "type": "string" }, "type": "array" }, "devServer": { + "description": "Options for the webpack-dev-server", "type": "object" }, "devtool": { @@ -820,17 +1028,32 @@ ] }, "entry": { - "$ref": "#/definitions/entry" + "description": "The entry point(s) of the compilation.", + "anyOf": [ + { + "$ref": "#/definitions/entry" + } + ] }, "externals": { - "$ref": "#/definitions/externals" + "description": "Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.", + "anyOf": [ + { + "$ref": "#/definitions/externals" + } + ] }, "loader": { "description": "Custom values available in the loader context.", "type": "object" }, "module": { - "$ref": "#/definitions/module" + "description": "Options affecting the normal modules (`NormalModuleFactory`).", + "anyOf": [ + { + "$ref": "#/definitions/module" + } + ] }, "name": { "description": "Name of the configuration. Used when loading multiple configurations.", @@ -846,6 +1069,7 @@ }, { "additionalProperties": { + "description": "Include a polyfill for the node.js module", "enum": [ false, true, @@ -855,6 +1079,7 @@ }, "properties": { "Buffer": { + "description": "Include a polyfill for the 'Buffer' variable", "enum": [ false, true, @@ -862,6 +1087,7 @@ ] }, "__dirname": { + "description": "Include a polyfill for the '__dirname' variable", "enum": [ false, true, @@ -869,6 +1095,7 @@ ] }, "__filename": { + "description": "Include a polyfill for the '__filename' variable", "enum": [ false, true, @@ -876,6 +1103,7 @@ ] }, "console": { + "description": "Include a polyfill for the 'console' variable", "enum": [ false, true, @@ -883,9 +1111,11 @@ ] }, "global": { + "description": "Include a polyfill for the 'global' variable", "type": "boolean" }, "process": { + "description": "Include a polyfill for the 'process' variable", "enum": [ false, true, @@ -898,7 +1128,12 @@ ] }, "output": { - "$ref": "#/definitions/output" + "description": "Options affecting the output of the compilation. `output` options tell webpack how to write the compiled files to disk.", + "anyOf": [ + { + "$ref": "#/definitions/output" + } + ] }, "parallelism": { "description": "The number of parallel processed modules in the compilation.", @@ -965,10 +1200,20 @@ "absolutePath": true }, "resolve": { - "$ref": "#/definitions/resolve" + "description": "Options for the resolver", + "anyOf": [ + { + "$ref": "#/definitions/resolve" + } + ] }, "resolveLoader": { - "$ref": "#/definitions/resolve" + "description": "Options for the resolver when resolving loaders", + "anyOf": [ + { + "$ref": "#/definitions/resolve" + } + ] }, "stats": { "description": "Used by the webpack CLI program to pass stats options.", @@ -1015,6 +1260,7 @@ "description": "add --env information" }, "colors": { + "description": "Enables/Disables colorful output", "oneOf": [ { "type": "boolean", @@ -1025,21 +1271,27 @@ "additionalProperties": false, "properties": { "bold": { + "description": "Custom color for bold text", "type": "string" }, "red": { + "description": "Custom color for red text", "type": "string" }, "green": { + "description": "Custom color for green text", "type": "string" }, "cyan": { + "description": "Custom color for cyan text", "type": "string" }, "magenta": { + "description": "Custom color for magenta text", "type": "string" }, "yellow": { + "description": "Custom color for yellow text", "type": "string" } } @@ -1092,19 +1344,35 @@ }, "warningsFilter": { "description": "Suppress warnings that match the specified filters. Filters can be Strings, RegExps or Functions", - "$ref": "#/definitions/filter-types" + "anyOf": [ + { + "$ref": "#/definitions/filter-types" + } + ] }, "excludeAssets": { "description": "Suppress assets that match the specified filters. Filters can be Strings, RegExps or Functions", - "$ref": "#/definitions/filter-types" + "anyOf": [ + { + "$ref": "#/definitions/filter-types" + } + ] }, "excludeModules": { "description": "Suppress modules that match the specified filters. Filters can be Strings, RegExps or Functions", - "$ref": "#/definitions/filter-types" + "anyOf": [ + { + "$ref": "#/definitions/filter-types" + } + ] }, "exclude": { "description": "Please use excludeModules instead.", - "$ref": "#/definitions/filter-types" + "anyOf": [ + { + "$ref": "#/definitions/filter-types" + } + ] }, "entrypoints": { "type": "boolean", @@ -1168,6 +1436,7 @@ ] }, "target": { + "description": "Environment to build for", "anyOf": [ { "enum": [ @@ -1192,12 +1461,15 @@ "type": "boolean" }, "watchOptions": { + "description": "Options for the watcher", + "additionalProperties": false, "properties": { "aggregateTimeout": { "description": "Delay the rebuilt after the first change. Value is a time in ms.", "type": "number" }, "poll": { + "description": "Enable polling mode for watching", "anyOf": [ { "description": "`true`: use polling.", diff --git a/test/Schemas.lint.js b/test/Schemas.lint.js new file mode 100644 index 000000000..f40b5f99b --- /dev/null +++ b/test/Schemas.lint.js @@ -0,0 +1,131 @@ +"use strict"; + +const fs = require("fs"); +const path = require("path"); +require("should"); +const glob = require("glob"); +const rootDir = path.resolve(__dirname, ".."); + +describe("Schemas", () => { + const schemas = glob.sync("schemas/**.json", { + cwd: rootDir + }); + + schemas.forEach(filename => { + describe(filename, () => { + let content; + let fileContent; + let errorWhileParsing; + + try { + fileContent = fs.readFileSync(path.resolve(rootDir, filename), "utf-8"); + content = JSON.parse(fileContent); + } catch(e) { + errorWhileParsing = e; + } + + it("should be parse-able", () => { + if(errorWhileParsing) throw errorWhileParsing; + }); + + if(content) { + + it("should be formated correctly", () => { + fileContent.replace(/\r\n?/g, "\n").should.be.eql(JSON.stringify(content, 0, 2) + "\n"); + }); + + const arrayProperties = ["oneOf", "anyOf", "allOf"]; + const allowedProperties = [ + "definitions", + "$ref", + "items", + "properties", + "additionalProperties", + "type", + "oneOf", + "anyOf", + "allOf", + "absolutePath", + "description", + "enum", + "minLength", + "minimum", + "required", + "uniqueItems", + "minItems", + "minProperties", + "instanceof" + ]; + + const validateProperty = property => { + it("should have description set", () => { + property.should.be.property("description").be.type("string"); + property.description.length.should.be.above(1); + }); + }; + + const walker = item => { + it("should only use allowed schema properties", () => { + const otherProperties = Object.keys(item).filter(p => allowedProperties.indexOf(p) < 0); + if(otherProperties.length > 0) { + throw new Error(`The properties ${otherProperties.join(", ")} are not allowed to use`); + // When allowing more properties make sure to add nice error messages for them in WebpackOptionsValidationError + } + }); + + if(Object.keys(item).indexOf("$ref") >= 0) { + it("should not have other properties next to $ref", () => { + const otherProperties = Object.keys(item).filter(p => p !== "$ref"); + if(otherProperties.length > 0) { + throw new Error(`When using $ref not other properties are possible (${otherProperties.join(", ")})`); + } + }); + } + + arrayProperties.forEach(prop => { + if(prop in item) { + describe(prop, () => { + item[prop].forEach(walker); + }); + } + }); + if("items" in item) { + describe("items", () => { + if(Object.keys(item).join() !== "$ref") { + validateProperty(item.items); + } + walker(item.items); + }); + } + if("definitions" in item) { + Object.keys(item.definitions).forEach(name => { + describe(`#${name}`, () => { + walker(item.definitions[name]); + }); + }); + } + if("properties" in item) { + it("should have additionalProperties set to some value when descriping properties", () => { + item.should.be.property("additionalProperties"); + }); + Object.keys(item.properties).forEach(name => { + describe(`> '${name}'`, () => { + const property = item.properties[name]; + validateProperty(property); + walker(property); + }); + }); + } + if(typeof item.additionalProperties === "object") { + describe("properties", () => { + validateProperty(item.additionalProperties); + walker(item.additionalProperties); + }); + } + }; + + walker(content); + } + }); + }) +}); diff --git a/test/Validation.test.js b/test/Validation.test.js index 3429c4996..8922ab2fa 100644 --- a/test/Validation.test.js +++ b/test/Validation.test.js @@ -24,7 +24,7 @@ describe("Validation", () => { message: [ " - configuration misses the property 'entry'.", " object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function", - " The entry point(s) of the compilation." + " -> The entry point(s) of the compilation." ] }, { name: "empty entry string", @@ -34,14 +34,16 @@ describe("Validation", () => { message: [ " - configuration.entry should be one of these:", " object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function", - " The entry point(s) of the compilation.", + " -> The entry point(s) of the compilation.", " Details:", " * configuration.entry should be an object.", + " -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", " * configuration.entry should not be empty.", + " -> An entry point without name. The string is resolved to a module which is loaded upon startup.", " * configuration.entry should be an array:", " [non-empty string]", " * configuration.entry should be an instance of function", - " function returning an entry object or a promise.." + " -> A Function returning an entry object, an entry string, an entry array or a promise to these things." ] }, { name: "empty entry bundle array", @@ -53,17 +55,17 @@ describe("Validation", () => { message: [ " - configuration.entry should be one of these:", " object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function", - " The entry point(s) of the compilation.", + " -> The entry point(s) of the compilation.", " Details:", " * configuration.entry['bundle'] should be a string.", + " -> The string is resolved to a module which is loaded upon startup.", " * configuration.entry['bundle'] should not be empty.", - " * configuration.entry['bundle'] should be one of these:", - " non-empty string | [non-empty string]", " * configuration.entry should be a string.", + " -> An entry point without name. The string is resolved to a module which is loaded upon startup.", " * configuration.entry should be an array:", " [non-empty string]", " * configuration.entry should be an instance of function", - " function returning an entry object or a promise.." + " -> A Function returning an entry object, an entry string, an entry array or a promise to these things." ] }, { name: "invalid instanceof", @@ -74,7 +76,36 @@ describe("Validation", () => { } }, message: [ - " - configuration.module.wrappedContextRegExp should be an instance of RegExp.", + " - configuration.module.wrappedContextRegExp should be an instance of RegExp", + " -> Set the inner regular expression for partial dynamic dependencies" + ] + }, { + name: "invalid minimum", + config: { + entry: "a", + parallelism: 0 + }, + message: [ + " - configuration.parallelism should be >= 1.", + " -> The number of parallel processed modules in the compilation." + ] + }, { + name: "repeated value", + config: { + entry: ["abc", "def", "abc"] + }, + message: [ + " - configuration.entry should be one of these:", + " object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function", + " -> The entry point(s) of the compilation.", + " Details:", + " * configuration.entry should be an object.", + " -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", + " * configuration.entry should be a string.", + " -> An entry point without name. The string is resolved to a module which is loaded upon startup.", + " * configuration.entry should not contain the item 'abc' twice.", + " * configuration.entry should be an instance of function", + " -> A Function returning an entry object, an entry string, an entry array or a promise to these things.", ] }, { name: "multiple errors", @@ -87,14 +118,18 @@ describe("Validation", () => { message: [ " - configuration.entry should be one of these:", " object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function", - " The entry point(s) of the compilation.", + " -> The entry point(s) of the compilation.", " Details:", " * configuration.entry should be an object.", + " -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", " * configuration.entry should be a string.", + " -> An entry point without name. The string is resolved to a module which is loaded upon startup.", " * configuration.entry[0] should be a string.", + " -> A non-empty string", " * configuration.entry should be an instance of function", - " function returning an entry object or a promise..", - " - configuration.output.filename should be a string." + " -> A Function returning an entry object, an entry string, an entry array or a promise to these things.", + " - configuration.output.filename should be a string.", + " -> Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files." ] }, { name: "multiple configurations", @@ -109,14 +144,18 @@ describe("Validation", () => { message: [ " - configuration[0].entry should be one of these:", " object { : non-empty string | [non-empty string] } | non-empty string | [non-empty string] | function", - " The entry point(s) of the compilation.", + " -> The entry point(s) of the compilation.", " Details:", " * configuration[0].entry should be an object.", + " -> Multiple entry bundles are created. The key is the chunk name. The value can be a string or an array.", " * configuration[0].entry should be a string.", + " -> An entry point without name. The string is resolved to a module which is loaded upon startup.", " * configuration[0].entry[0] should be a string.", + " -> A non-empty string", " * configuration[0].entry should be an instance of function", - " function returning an entry object or a promise..", - " - configuration[1].output.filename should be a string." + " -> A Function returning an entry object, an entry string, an entry array or a promise to these things.", + " - configuration[1].output.filename should be a string.", + " -> Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files." ] }, { name: "deep error", @@ -135,7 +174,8 @@ describe("Validation", () => { }, message: [ " - configuration.module.rules[0].oneOf[0] has an unknown property 'paser'. These properties are valid:", - " object { enforce?, exclude?, include?, issuer?, loader?, loaders?, oneOf?, options?, parser?, query?, resource?, resourceQuery?, compiler?, rules?, test?, use? }" + " object { enforce?, exclude?, include?, issuer?, loader?, loaders?, oneOf?, options?, parser?, query?, resource?, resourceQuery?, compiler?, rules?, test?, use? }", + " -> A rule" ] }, { name: "additional key on root", @@ -170,7 +210,7 @@ describe("Validation", () => { message: [ " - configuration.devtool should be one of these:", " string | false", - " A developer tool to enhance debugging.", + " -> A developer tool to enhance debugging.", " Details:", " * configuration.devtool should be a string.", " * configuration.devtool should be false" @@ -185,6 +225,7 @@ describe("Validation", () => { }, message: [ " - configuration.output.filename: A relative path is expected. However the provided value \"/bar\" is an absolute path!", + " -> Specifies the name of each output file on disk. You must **not** specify an absolute path here! The `output.path` option determines the location on disk the files are written to, filename is used solely for naming the individual files.", " Please use output.path to specify absolute path and output.filename for the file name." ] }, { @@ -198,6 +239,7 @@ describe("Validation", () => { }, message: [ " - configuration.context: The provided value \"baz\" is not an absolute path!", + " -> The base directory (absolute path!) for resolving the `entry` option. If `output.pathinfo` is set, the included pathinfo is shortened to this directory." ] }, { name: "missing stats option", diff --git a/test/lint-mocha.opts b/test/lint-mocha.opts new file mode 100644 index 000000000..84fc1681a --- /dev/null +++ b/test/lint-mocha.opts @@ -0,0 +1 @@ +--reporter min From 96df6aecdba4bd31cdb8c41c18350b7b05dba490 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 16 Nov 2017 09:04:21 +0100 Subject: [PATCH 41/85] fix beautify issue --- test/NodeWatchFileSystem.unittest.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/NodeWatchFileSystem.unittest.js b/test/NodeWatchFileSystem.unittest.js index a848c47f1..c992e0c4a 100644 --- a/test/NodeWatchFileSystem.unittest.js +++ b/test/NodeWatchFileSystem.unittest.js @@ -64,7 +64,7 @@ describe("NodeWatchFileSystem", function() { var wfs = new NodeWatchFileSystem(); var watcher = wfs.watch([fileDirect], [], [], startTime, { aggregateTimeout: 1000 - }, function(err, filesModified, dirsModified, missingCreated, fileTimestamps /*, dirTimestamps */) { + }, function(err, filesModified, dirsModified, missingCreated, fileTimestamps) { if(err) throw err; filesModified.should.be.eql([fileDirect]); dirsModified.should.be.eql([]); @@ -83,7 +83,7 @@ describe("NodeWatchFileSystem", function() { var wfs = new NodeWatchFileSystem(); var watcher = wfs.watch([fileDirect], [], [], startTime, { aggregateTimeout: 1000 - }, function(err, filesModified, dirsModified, missingCreated, fileTimestamps /*, dirTimestamps */) { + }, function(err, filesModified, dirsModified, missingCreated, fileTimestamps) { if(err) throw err; filesModified.should.be.eql([fileDirect]); dirsModified.should.be.eql([]); From 00a980825a658d32f89067f378471b5f46bade05 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 16 Nov 2017 13:56:34 +0100 Subject: [PATCH 42/85] Remove unneeded code lines --- lib/WebpackOptionsValidationError.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/WebpackOptionsValidationError.js b/lib/WebpackOptionsValidationError.js index 4b3e80754..2666e4b28 100644 --- a/lib/WebpackOptionsValidationError.js +++ b/lib/WebpackOptionsValidationError.js @@ -39,14 +39,7 @@ const getSchemaPartText = (schemaPart, additionalPath) => { return schemaText; }; -const getSchemaPartDescription = (schemaPart, additionalPath) => { - if(additionalPath) { - for(let i = 0; i < additionalPath.length; i++) { - const inner = schemaPart[additionalPath[i]]; - if(inner) - schemaPart = inner; - } - } +const getSchemaPartDescription = schemaPart => { while(schemaPart.$ref) schemaPart = getSchemaPart(schemaPart.$ref); if(schemaPart.description) return `\n-> ${schemaPart.description}`; From f823360910d8dbf3ac3eeeb36402fac0ca3d36a6 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 17 Nov 2017 14:16:44 +0100 Subject: [PATCH 43/85] fix testcase for windows-style paths --- test/configCases/context-replacement/d/queryloader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/configCases/context-replacement/d/queryloader.js b/test/configCases/context-replacement/d/queryloader.js index 02707b2ba..88a2fd607 100644 --- a/test/configCases/context-replacement/d/queryloader.js +++ b/test/configCases/context-replacement/d/queryloader.js @@ -2,6 +2,6 @@ module.exports = function(content) { return "module.exports = " + JSON.stringify({ resourceQuery: this.resourceQuery, query: this.query, - prev: content + prev: content.replace(/\r\n?/g, "\n") }); }; From 5e39ec46eea24a5559f159839a5b959139c437a9 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 17 Nov 2017 14:26:23 +0100 Subject: [PATCH 44/85] Allow to override resolve configuration --- lib/Compilation.js | 5 +- lib/Compiler.js | 71 +++++++++++++++++-- lib/ContextModule.js | 2 + lib/ContextModuleFactory.js | 20 ++++-- lib/Module.js | 3 + lib/NormalModule.js | 4 +- lib/NormalModuleFactory.js | 52 ++++++++------ lib/ResolverFactory.js | 37 ++++++++++ lib/WebpackOptionsApply.js | 28 ++++---- lib/WebpackOptionsDefaulter.js | 17 +++++ lib/dependencies/AMDPlugin.js | 4 +- lib/node/NodeSourcePlugin.js | 4 +- lib/util/cachedMerge.js | 27 +++++++ schemas/webpackOptionsSchema.json | 17 +++++ test/Validation.test.js | 2 +- .../configCases/rule-set/resolve-options/a.js | 1 + .../configCases/rule-set/resolve-options/b.js | 1 + .../rule-set/resolve-options/index.js | 6 ++ .../rule-set/resolve-options/ok.js | 1 + .../resolve-options/webpack.config.js | 14 ++++ .../rule-set/resolve-options/wrong.js | 1 + 21 files changed, 262 insertions(+), 55 deletions(-) create mode 100644 lib/ResolverFactory.js create mode 100644 lib/util/cachedMerge.js create mode 100644 test/configCases/rule-set/resolve-options/a.js create mode 100644 test/configCases/rule-set/resolve-options/b.js create mode 100644 test/configCases/rule-set/resolve-options/index.js create mode 100644 test/configCases/rule-set/resolve-options/ok.js create mode 100644 test/configCases/rule-set/resolve-options/webpack.config.js create mode 100644 test/configCases/rule-set/resolve-options/wrong.js diff --git a/lib/Compilation.js b/lib/Compilation.js index 405787f32..6e404855c 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -59,7 +59,7 @@ class Compilation extends Tapable { constructor(compiler) { super(); this.compiler = compiler; - this.resolvers = compiler.resolvers; + this.resolverFactory = compiler.resolverFactory; this.inputFileSystem = compiler.inputFileSystem; const options = this.options = compiler.options; @@ -176,7 +176,7 @@ class Compilation extends Tapable { callbackList.forEach(cb => cb(err)); }; - module.build(this.options, this, this.resolvers.normal, this.inputFileSystem, (error) => { + module.build(this.options, this, this.resolverFactory.get("normal", module.resolveOptions), this.inputFileSystem, (error) => { const errors = module.errors; for(let indexError = 0; indexError < errors.length; indexError++) { const err = errors[indexError]; @@ -273,6 +273,7 @@ class Compilation extends Tapable { issuer: module.nameForCondition && module.nameForCondition(), compiler: _this.compiler.name }, + resolveOptions: module.resolveOptions, context: module.context, dependencies: dependencies }, (err, dependentModule) => { diff --git a/lib/Compiler.js b/lib/Compiler.js index 2211c449d..19727ae9d 100644 --- a/lib/Compiler.js +++ b/lib/Compiler.js @@ -12,6 +12,7 @@ const Compilation = require("./Compilation"); const Stats = require("./Stats"); const NormalModuleFactory = require("./NormalModuleFactory"); const ContextModuleFactory = require("./ContextModuleFactory"); +const ResolverFactory = require("./ResolverFactory"); const makePathsRelative = require("./util/identifier").makePathsRelative; @@ -182,10 +183,68 @@ class Compiler extends Tapable { this.fileTimestamps = {}; this.contextTimestamps = {}; + this.resolverFactory = new ResolverFactory(); this.resolvers = { - normal: null, - loader: null, - context: null + normal: { + plugins: util.deprecate( + (hook, fn) => { + this.resolverFactory.plugin("resolver normal", resolver => { + resolver.plugin(hook, fn); + }); + }, + "webpack: Using compiler.resolvers.normal is deprecated.\n" + + "Use compiler.resolverFactory.plugin(\"resolver normal\", resolver => {\n resolver.plugin(/* ... */);\n}); instead." + ), + apply: util.deprecate( + (...args) => { + this.resolverFactory.plugin("resolver normal", resolver => { + resolver.apply(...args); + }); + }, + "webpack: Using compiler.resolvers.normal is deprecated.\n" + + "Use compiler.resolverFactory.plugin(\"resolver normal\", resolver => {\n resolver.apply(/* ... */);\n}); instead." + ) + }, + loader: { + plugins: util.deprecate( + (hook, fn) => { + this.resolverFactory.plugin("resolver loader", resolver => { + resolver.plugin(hook, fn); + }); + }, + "webpack: Using compiler.resolvers.loader is deprecated.\n" + + "Use compiler.resolverFactory.plugin(\"resolver loader\", resolver => {\n resolver.plugin(/* ... */);\n}); instead." + ), + apply: util.deprecate( + (...args) => { + this.resolverFactory.plugin("resolver loader", resolver => { + resolver.apply(...args); + }); + }, + "webpack: Using compiler.resolvers.loader is deprecated.\n" + + "Use compiler.resolverFactory.plugin(\"resolver loader\", resolver => {\n resolver.apply(/* ... */);\n}); instead." + ) + }, + context: { + plugins: util.deprecate( + (hook, fn) => { + this.resolverFactory.plugin("resolver context", resolver => { + resolver.plugin(hook, fn); + }); + }, + "webpack: Using compiler.resolvers.context is deprecated.\n" + + "Use compiler.resolverFactory.plugin(\"resolver context\", resolver => {\n resolver.plugin(/* ... */);\n}); instead." + ), + apply: util.deprecate( + (...args) => { + this.resolverFactory.plugin("resolver context", resolver => { + resolver.apply(...args); + }); + }, + "webpack: Using compiler.resolvers.context is deprecated.\n" + + "Use compiler.resolverFactory.plugin(\"resolver context\", resolver => {\n resolver.apply(/* ... */);\n}); instead." + ) + } }; this.parser = { plugin: util.deprecate( @@ -419,7 +478,7 @@ class Compiler extends Tapable { childCompiler.outputPath = this.outputPath; childCompiler.inputFileSystem = this.inputFileSystem; childCompiler.outputFileSystem = null; - childCompiler.resolvers = this.resolvers; + childCompiler.resolverFactory = this.resolverFactory; childCompiler.fileTimestamps = this.fileTimestamps; childCompiler.contextTimestamps = this.contextTimestamps; @@ -463,13 +522,13 @@ class Compiler extends Tapable { } createNormalModuleFactory() { - const normalModuleFactory = new NormalModuleFactory(this.options.context, this.resolvers, this.options.module || {}); + const normalModuleFactory = new NormalModuleFactory(this.options.context, this.resolverFactory, this.options.module || {}); this.applyPlugins("normal-module-factory", normalModuleFactory); return normalModuleFactory; } createContextModuleFactory() { - const contextModuleFactory = new ContextModuleFactory(this.resolvers, this.inputFileSystem); + const contextModuleFactory = new ContextModuleFactory(this.resolverFactory, this.inputFileSystem); this.applyPlugins("context-module-factory", contextModuleFactory); return contextModuleFactory; } diff --git a/lib/ContextModule.js b/lib/ContextModule.js index df54a1f10..a60db7d8c 100644 --- a/lib/ContextModule.js +++ b/lib/ContextModule.js @@ -36,6 +36,8 @@ class ContextModule extends Module { resourceQuery: resourceQuery }); this.context = this.options.resource; + if(options.resolveOptions !== undefined) + this.resolveOptions = options.resolveOptions; // Info from Build this.builtTime = undefined; diff --git a/lib/ContextModuleFactory.js b/lib/ContextModuleFactory.js index 80c742c64..8d6dcf444 100644 --- a/lib/ContextModuleFactory.js +++ b/lib/ContextModuleFactory.js @@ -11,19 +11,23 @@ const Tapable = require("tapable"); const ContextModule = require("./ContextModule"); const ContextElementDependency = require("./dependencies/ContextElementDependency"); +const EMPTY_RESOLVE_OPTIONS = {}; + module.exports = class ContextModuleFactory extends Tapable { - constructor(resolvers) { + constructor(resolverFactory) { super(); - this.resolvers = resolvers; + this.resolverFactory = resolverFactory; } create(data, callback) { const context = data.context; const dependencies = data.dependencies; + const resolveOptions = data.resolveOptions; const dependency = dependencies[0]; this.applyPluginsAsyncWaterfall("before-resolve", Object.assign({ context: context, - dependencies: dependencies + dependencies: dependencies, + resolveOptions }, dependency.options), (err, beforeResolveResult) => { if(err) return callback(err); @@ -32,6 +36,7 @@ module.exports = class ContextModuleFactory extends Tapable { const context = beforeResolveResult.context; const request = beforeResolveResult.request; + const resolveOptions = beforeResolveResult.resolveOptions; let loaders, resource, loadersPrefix = ""; const idx = request.lastIndexOf("!"); @@ -50,18 +55,19 @@ module.exports = class ContextModuleFactory extends Tapable { resource = request; } - const resolvers = this.resolvers; + const contextResolver = this.resolverFactory.get("context", resolveOptions || EMPTY_RESOLVE_OPTIONS); + const loaderResolver = this.resolverFactory.get("loader", EMPTY_RESOLVE_OPTIONS); asyncLib.parallel([ callback => { - resolvers.context.resolve({}, context, resource, (err, result) => { + contextResolver.resolve({}, context, resource, (err, result) => { if(err) return callback(err); callback(null, result); }); }, callback => { asyncLib.map(loaders, (loader, callback) => { - resolvers.loader.resolve({}, context, loader, (err, result) => { + loaderResolver.resolve({}, context, loader, (err, result) => { if(err) return callback(err); callback(null, result); }); @@ -73,7 +79,7 @@ module.exports = class ContextModuleFactory extends Tapable { this.applyPluginsAsyncWaterfall("after-resolve", Object.assign({ addon: loadersPrefix + result[1].join("!") + (result[1].length > 0 ? "!" : ""), resource: result[0], - resolveDependencies: this.resolveDependencies.bind(this), + resolveDependencies: this.resolveDependencies.bind(this) }, beforeResolveResult), (err, result) => { if(err) return callback(err); diff --git a/lib/Module.js b/lib/Module.js index e6aba1249..19f5a8206 100644 --- a/lib/Module.js +++ b/lib/Module.js @@ -11,6 +11,8 @@ const ModuleReason = require("./ModuleReason"); const SortableSet = require("./util/SortableSet"); const Template = require("./Template"); +const EMPTY_RESOLVE_OPTIONS = {}; + let debugId = 1000; const sortById = (a, b) => { @@ -52,6 +54,7 @@ class Module extends DependenciesBlock { // Info from Factory // TODO refactor: pass as constructor argument this.context = null; + this.resolveOptions = EMPTY_RESOLVE_OPTIONS; // Info from Build this.sideEffectFree = false; diff --git a/lib/NormalModule.js b/lib/NormalModule.js index fb9eb1a5c..599eb6a72 100644 --- a/lib/NormalModule.js +++ b/lib/NormalModule.js @@ -66,7 +66,7 @@ const dependencyTemplatesHashMap = new WeakMap(); class NormalModule extends Module { - constructor(type, request, userRequest, rawRequest, loaders, resource, parser) { + constructor(type, request, userRequest, rawRequest, loaders, resource, parser, resolveOptions) { super(type); // Info from Factory @@ -78,6 +78,8 @@ class NormalModule extends Module { this.resource = resource; this.context = getContext(resource); this.loaders = loaders; + if(resolveOptions !== undefined) + this.resolveOptions = resolveOptions; // Info from Build this.fileDependencies = new Set(); diff --git a/lib/NormalModuleFactory.js b/lib/NormalModuleFactory.js index d54a35f5d..db1a41219 100644 --- a/lib/NormalModuleFactory.js +++ b/lib/NormalModuleFactory.js @@ -9,6 +9,9 @@ const Tapable = require("tapable"); const NormalModule = require("./NormalModule"); const RawModule = require("./RawModule"); const RuleSet = require("./RuleSet"); +const cachedMerge = require("./util/cachedMerge"); + +const EMPTY_RESOLVE_OPTIONS = {}; const loaderToIdent = data => { if(!data.options) @@ -42,10 +45,10 @@ const identToLoaderRequest = resultString => { }; class NormalModuleFactory extends Tapable { - constructor(context, resolvers, options) { + constructor(context, resolverFactory, options) { super(); - this.resolvers = resolvers; - this.ruleSet = new RuleSet(options.rules); + this.resolverFactory = resolverFactory; + this.ruleSet = new RuleSet(options.defaultRules.concat(options.rules)); this.cachePredicate = typeof options.unsafeCache === "function" ? options.unsafeCache : Boolean.bind(null, options.unsafeCache); this.context = context || ""; this.parserCache = {}; @@ -85,7 +88,8 @@ class NormalModuleFactory extends Tapable { result.rawRequest, result.loaders, result.resource, - result.parser + result.parser, + result.resolveOptions ); } @@ -107,15 +111,19 @@ class NormalModuleFactory extends Tapable { let resource = elements.pop(); elements = elements.map(identToLoaderRequest); + const loaderResolver = this.getResolver("loader"); + const normalResolver = this.getResolver("normal", data.resolveOptions); + asyncLib.parallel([ - callback => this.resolveRequestArray(contextInfo, context, elements, this.resolvers.loader, callback), + callback => this.resolveRequestArray(contextInfo, context, elements, loaderResolver, callback), callback => { - if(resource === "" || resource[0] === "?") + if(resource === "" || resource[0] === "?") { return callback(null, { resource }); + } - this.resolvers.normal.resolve(contextInfo, context, resource, (err, resource, resourceResolveData) => { + normalResolver.resolve(contextInfo, context, resource, (err, resource, resourceResolveData) => { if(err) return callback(err); callback(null, { resourceResolveData, @@ -179,19 +187,22 @@ class NormalModuleFactory extends Tapable { useLoadersPre.push(r.value); else if(!r.enforce && !noAutoLoaders && !noPrePostAutoLoaders) useLoaders.push(r.value); + } else if(typeof r.value === "object" && r.value !== null && typeof settings[r.type] === "object" && settings[r.type] !== null) { + settings[r.type] = cachedMerge(settings[r.type], r.value); } else { settings[r.type] = r.value; } }); asyncLib.parallel([ - this.resolveRequestArray.bind(this, contextInfo, this.context, useLoadersPost, this.resolvers.loader), - this.resolveRequestArray.bind(this, contextInfo, this.context, useLoaders, this.resolvers.loader), - this.resolveRequestArray.bind(this, contextInfo, this.context, useLoadersPre, this.resolvers.loader) + this.resolveRequestArray.bind(this, contextInfo, this.context, useLoadersPost, loaderResolver), + this.resolveRequestArray.bind(this, contextInfo, this.context, useLoaders, loaderResolver), + this.resolveRequestArray.bind(this, contextInfo, this.context, useLoadersPre, loaderResolver) ], (err, results) => { if(err) return callback(err); loaders = results[0].concat(loaders, results[1], results[2]); process.nextTick(() => { - const type = settings.type || this.getDefaultType(resourcePath); + const type = settings.type; + const resolveOptions = settings.resolve; callback(null, { context: context, request: loaders.map(loaderToIdent).concat([resource]).join("!"), @@ -202,7 +213,8 @@ class NormalModuleFactory extends Tapable { resource, resourceResolveData, type, - parser: this.getParser(type, settings.parser) + parser: this.getParser(type, settings.parser), + resolveOptions }); }); }); @@ -210,25 +222,17 @@ class NormalModuleFactory extends Tapable { }); } - getDefaultType(resourcePath) { - if(/\.wasm$/.test(resourcePath)) - return "webassembly/experimental"; - if(/\.mjs$/.test(resourcePath)) - return "javascript/esm"; - if(/\.json$/.test(resourcePath)) - return "json"; - return "javascript/auto"; - } - create(data, callback) { const dependencies = data.dependencies; const cacheEntry = dependencies[0].__NormalModuleFactoryCache; if(cacheEntry) return callback(null, cacheEntry); const context = data.context || this.context; + const resolveOptions = data.resolveOptions || EMPTY_RESOLVE_OPTIONS; const request = dependencies[0].request; const contextInfo = data.contextInfo || {}; this.applyPluginsAsyncWaterfall("before-resolve", { contextInfo, + resolveOptions, context, request, dependencies @@ -307,6 +311,10 @@ class NormalModuleFactory extends Tapable { this.applyPlugins2(`parser ${type}`, parser, parserOptions); return parser; } + + getResolver(type, resolveOptions) { + return this.resolverFactory.get(type, resolveOptions || EMPTY_RESOLVE_OPTIONS); + } } module.exports = NormalModuleFactory; diff --git a/lib/ResolverFactory.js b/lib/ResolverFactory.js new file mode 100644 index 000000000..0dadc8fb6 --- /dev/null +++ b/lib/ResolverFactory.js @@ -0,0 +1,37 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra + */ +"use strict"; + +const Tapable = require("tapable"); +const Factory = require("enhanced-resolve").ResolverFactory; + +module.exports = class ResolverFactory extends Tapable { + constructor() { + super(); + this.cache1 = new WeakMap(); + this.cache2 = new Map(); + } + + get(type, resolveOptions) { + const cachedResolver = this.cache1.get(resolveOptions); + if(cachedResolver) return cachedResolver(); + const ident = `${type}|${JSON.stringify(resolveOptions)}`; + const resolver = this.cache2.get(ident); + if(resolver) return resolver; + const newResolver = this._create(type, resolveOptions); + this.cache2.set(ident, newResolver); + return newResolver; + } + + _create(type, resolveOptions) { + resolveOptions = this.applyPluginsWaterfall(`resolve-options ${type}`, resolveOptions); + const resolver = Factory.createResolver(resolveOptions); + if(!resolver) { + throw new Error("No resolver created"); + } + this.applyPlugins2(`resolver ${type}`, resolver, resolveOptions); + return resolver; + } +}; diff --git a/lib/WebpackOptionsApply.js b/lib/WebpackOptionsApply.js index eb078a3c4..0f5f3e83c 100644 --- a/lib/WebpackOptionsApply.js +++ b/lib/WebpackOptionsApply.js @@ -50,8 +50,6 @@ const FlagDependencyUsagePlugin = require("./FlagDependencyUsagePlugin"); const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin"); const SizeLimitsPlugin = require("./performance/SizeLimitsPlugin"); -const ResolverFactory = require("enhanced-resolve").ResolverFactory; - class WebpackOptionsApply extends OptionsApply { constructor() { super(); @@ -305,16 +303,22 @@ class WebpackOptionsApply extends OptionsApply { compiler.applyPlugins("after-plugins", compiler); if(!compiler.inputFileSystem) throw new Error("No input filesystem provided"); - compiler.resolvers.normal = ResolverFactory.createResolver(Object.assign({ - fileSystem: compiler.inputFileSystem - }, options.resolve)); - compiler.resolvers.context = ResolverFactory.createResolver(Object.assign({ - fileSystem: compiler.inputFileSystem, - resolveToContext: true - }, options.resolve)); - compiler.resolvers.loader = ResolverFactory.createResolver(Object.assign({ - fileSystem: compiler.inputFileSystem - }, options.resolveLoader)); + compiler.resolverFactory.plugin("resolve-options normal", resolveOptions => { + return Object.assign({ + fileSystem: compiler.inputFileSystem + }, options.resolve, resolveOptions); + }); + compiler.resolverFactory.plugin("resolve-options context", resolveOptions => { + return Object.assign({ + fileSystem: compiler.inputFileSystem, + resolveToContext: true + }, options.resolve, resolveOptions); + }); + compiler.resolverFactory.plugin("resolve-options loader", resolveOptions => { + return Object.assign({ + fileSystem: compiler.inputFileSystem + }, options.resolveLoader, resolveOptions); + }); compiler.applyPlugins("after-resolvers", compiler); return options; } diff --git a/lib/WebpackOptionsDefaulter.js b/lib/WebpackOptionsDefaulter.js index debd37b97..2e4d96237 100644 --- a/lib/WebpackOptionsDefaulter.js +++ b/lib/WebpackOptionsDefaulter.js @@ -31,6 +31,23 @@ class WebpackOptionsDefaulter extends OptionsDefaulter { this.set("module.strictExportPresence", false); this.set("module.strictThisContextOnImports", false); this.set("module.unsafeCache", true); + this.set("module.rules", []); + this.set("module.defaultRules", [{ + type: "javascript/auto", + resolve: {} + }, { + test: /\.mjs$/i, + type: "javascript/esm", + resolve: { + enforceExtension: true + } + }, { + test: /\.json$/i, + type: "json", + }, { + test: /\.wasm$/i, + type: "webassembly/experimental", + }]); this.set("output", "call", (value, options) => { if(typeof value === "string") { diff --git a/lib/dependencies/AMDPlugin.js b/lib/dependencies/AMDPlugin.js index 21f3f23e2..6669a040d 100644 --- a/lib/dependencies/AMDPlugin.js +++ b/lib/dependencies/AMDPlugin.js @@ -99,7 +99,7 @@ class AMDPlugin { }); }); compiler.plugin("after-resolvers", () => { - compiler.resolvers.normal.apply( + compiler.resolverFactory.plugin("resolver normal", resolver => resolver.apply( new AliasPlugin("described-resolve", { name: "amdefine", alias: path.join(__dirname, "..", "..", "buildin", "amd-define.js") @@ -112,7 +112,7 @@ class AMDPlugin { name: "webpack amd define", alias: path.join(__dirname, "..", "..", "buildin", "amd-define.js") }, "resolve") - ); + )); }); } } diff --git a/lib/node/NodeSourcePlugin.js b/lib/node/NodeSourcePlugin.js index 81a91b510..f36adc6fa 100644 --- a/lib/node/NodeSourcePlugin.js +++ b/lib/node/NodeSourcePlugin.js @@ -74,13 +74,13 @@ module.exports = class NodeSourcePlugin { compiler.plugin("after-resolvers", (compiler) => { Object.keys(nodeLibsBrowser).forEach((lib) => { if(options[lib] !== false) { - compiler.resolvers.normal.apply( + compiler.resolverFactory.plugin("resolver normal", resolver => resolver.apply( new AliasPlugin("described-resolve", { name: lib, onlyModule: true, alias: getPathToModule(lib, options[lib]) }, "resolve") - ); + )); } }); }); diff --git a/lib/util/cachedMerge.js b/lib/util/cachedMerge.js new file mode 100644 index 000000000..182a2aaab --- /dev/null +++ b/lib/util/cachedMerge.js @@ -0,0 +1,27 @@ +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ +"use strict"; + +const mergeCache = new WeakMap(); + +const cachedMerge = (first, ...args) => { + if(args.length === 0) return first; + if(args.length > 1) { + return cachedMerge(first, cachedMerge(...args)); + } + const second = args[0]; + let innerCache = mergeCache.get(first); + if(innerCache === undefined) { + innerCache = new WeakMap(); + mergeCache.set(first, innerCache); + } + const cachedMerge = innerCache.get(second); + if(cachedMerge !== undefined) return cachedMerge; + const newMerge = Object.assign({}, first, second); + innerCache.set(second, newMerge); + return newMerge; +}; + +module.exports = cachedMerge; diff --git a/schemas/webpackOptionsSchema.json b/schemas/webpackOptionsSchema.json index 4befdb5e0..7f1ee87bf 100644 --- a/schemas/webpackOptionsSchema.json +++ b/schemas/webpackOptionsSchema.json @@ -194,6 +194,14 @@ ], "description": "An array of rules applied for modules." }, + "defaultRules": { + "description": "An array of rules applied by default for modules.", + "anyOf": [ + { + "$ref": "#/definitions/ruleSet-rules" + } + ] + }, "unknownContextCritical": { "description": "Enable warnings when using the require function in a not statically analyse-able way", "type": "boolean" @@ -808,6 +816,15 @@ "additionalProperties": true, "type": "object" }, + "resolve": { + "description": "Options for the resolver", + "type": "object", + "anyOf": [ + { + "$ref": "#/definitions/resolve" + } + ] + }, "query": { "description": "Shortcut for use.query", "anyOf": [ diff --git a/test/Validation.test.js b/test/Validation.test.js index 7a4e32660..11d9af829 100644 --- a/test/Validation.test.js +++ b/test/Validation.test.js @@ -174,7 +174,7 @@ describe("Validation", () => { }, message: [ " - configuration.module.rules[0].oneOf[0] has an unknown property 'paser'. These properties are valid:", - " object { enforce?, exclude?, include?, issuer?, loader?, loaders?, oneOf?, options?, parser?, query?, type?, resource?, resourceQuery?, compiler?, rules?, test?, use? }", + " object { enforce?, exclude?, include?, issuer?, loader?, loaders?, oneOf?, options?, parser?, resolve?, query?, type?, resource?, resourceQuery?, compiler?, rules?, test?, use? }", " -> A rule" ] }, { diff --git a/test/configCases/rule-set/resolve-options/a.js b/test/configCases/rule-set/resolve-options/a.js new file mode 100644 index 000000000..f7293f306 --- /dev/null +++ b/test/configCases/rule-set/resolve-options/a.js @@ -0,0 +1 @@ +module.exports = require("./wrong"); diff --git a/test/configCases/rule-set/resolve-options/b.js b/test/configCases/rule-set/resolve-options/b.js new file mode 100644 index 000000000..f7293f306 --- /dev/null +++ b/test/configCases/rule-set/resolve-options/b.js @@ -0,0 +1 @@ +module.exports = require("./wrong"); diff --git a/test/configCases/rule-set/resolve-options/index.js b/test/configCases/rule-set/resolve-options/index.js new file mode 100644 index 000000000..c5da4bedd --- /dev/null +++ b/test/configCases/rule-set/resolve-options/index.js @@ -0,0 +1,6 @@ +it("should allow to set custom resolving rules", function() { + var a = require("./a"); + a.should.be.eql("ok"); + var b = require("./b"); + b.should.be.eql("wrong"); +}); diff --git a/test/configCases/rule-set/resolve-options/ok.js b/test/configCases/rule-set/resolve-options/ok.js new file mode 100644 index 000000000..f74a2f2b5 --- /dev/null +++ b/test/configCases/rule-set/resolve-options/ok.js @@ -0,0 +1 @@ +module.exports = "ok"; diff --git a/test/configCases/rule-set/resolve-options/webpack.config.js b/test/configCases/rule-set/resolve-options/webpack.config.js new file mode 100644 index 000000000..9ce4b7957 --- /dev/null +++ b/test/configCases/rule-set/resolve-options/webpack.config.js @@ -0,0 +1,14 @@ +module.exports = { + module: { + rules: [ + { + test: require.resolve("./a"), + resolve: { + alias: { + "./wrong": "./ok" + } + } + } + ] + } +}; diff --git a/test/configCases/rule-set/resolve-options/wrong.js b/test/configCases/rule-set/resolve-options/wrong.js new file mode 100644 index 000000000..774820932 --- /dev/null +++ b/test/configCases/rule-set/resolve-options/wrong.js @@ -0,0 +1 @@ +module.exports = "wrong"; From 007b14eb107b3b36316a55d4dd35e929f6b624b7 Mon Sep 17 00:00:00 2001 From: Brian Schlenker Date: Sat, 18 Nov 2017 10:33:48 -0800 Subject: [PATCH 45/85] Handle amd define with arrow function --- .../AMDDefineDependencyParserPlugin.js | 24 ++++++++++++++----- test/cases/parsing/extract-amd/index.js | 14 +++++++++++ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/lib/dependencies/AMDDefineDependencyParserPlugin.js b/lib/dependencies/AMDDefineDependencyParserPlugin.js index d7a27a7e0..63859ecea 100644 --- a/lib/dependencies/AMDDefineDependencyParserPlugin.js +++ b/lib/dependencies/AMDDefineDependencyParserPlugin.js @@ -23,6 +23,18 @@ function isBoundFunctionExpression(expr) { return true; } +function isUnboundFunctionExpression(expr) { + if(expr.type === "FunctionExpression") return true; + if(expr.type === "ArrowFunctionExpression") return true; + return false; +} + +function isCallable(expr) { + if(isUnboundFunctionExpression(expr)) return true; + if(isBoundFunctionExpression(expr)) return true; + return false; +} + class AMDDefineDependencyParserPlugin { constructor(options) { this.options = options; @@ -38,7 +50,7 @@ class AMDDefineDependencyParserPlugin { let array, fn, obj, namedModule; switch(expr.arguments.length) { case 1: - if(expr.arguments[0].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[0])) { + if(isCallable(expr.arguments[0])) { // define(f() {...}) fn = expr.arguments[0]; } else if(expr.arguments[0].type === "ObjectExpression") { @@ -54,7 +66,7 @@ class AMDDefineDependencyParserPlugin { if(expr.arguments[0].type === "Literal") { namedModule = expr.arguments[0].value; // define("...", ...) - if(expr.arguments[1].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[1])) { + if(isCallable(expr.arguments[1])) { // define("...", f() {...}) fn = expr.arguments[1]; } else if(expr.arguments[1].type === "ObjectExpression") { @@ -67,7 +79,7 @@ class AMDDefineDependencyParserPlugin { } } else { array = expr.arguments[0]; - if(expr.arguments[1].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[1])) { + if(isCallable(expr.arguments[1])) { // define([...], f() {}) fn = expr.arguments[1]; } else if(expr.arguments[1].type === "ObjectExpression") { @@ -84,7 +96,7 @@ class AMDDefineDependencyParserPlugin { // define("...", [...], f() {...}) namedModule = expr.arguments[0].value; array = expr.arguments[1]; - if(expr.arguments[2].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[2])) { + if(isCallable(expr.arguments[2])) { // define("...", [...], f() {}) fn = expr.arguments[2]; } else if(expr.arguments[2].type === "ObjectExpression") { @@ -102,7 +114,7 @@ class AMDDefineDependencyParserPlugin { let fnParams = null; let fnParamsOffset = 0; if(fn) { - if(fn.type === "FunctionExpression") fnParams = fn.params; + if(isUnboundFunctionExpression(fn)) fnParams = fn.params; else if(isBoundFunctionExpression(fn)) { fnParams = fn.callee.object.params; fnParamsOffset = fn.arguments.length - 1; @@ -134,7 +146,7 @@ class AMDDefineDependencyParserPlugin { }); } let inTry; - if(fn && fn.type === "FunctionExpression") { + if(fn && isUnboundFunctionExpression(fn)) { inTry = parser.scope.inTry; parser.inScope(fnParams, () => { parser.scope.renames = fnRenames; diff --git a/test/cases/parsing/extract-amd/index.js b/test/cases/parsing/extract-amd/index.js index 5b7738002..cb76e568b 100644 --- a/test/cases/parsing/extract-amd/index.js +++ b/test/cases/parsing/extract-amd/index.js @@ -168,6 +168,20 @@ it("should not fail #138", function(done) { }(function () { done() })); }); +it("should parse a simplified commonjs wrapping", function(done) { + define(function(require) { + require("./a").should.be.eql("a"); + done(); + }); +}); + +it("should parse a simplified commonjs wrapping arrow function", function(done) { + define((require) => { + require("./a").should.be.eql("a"); + done(); + }); +}); + it("should parse a bound function expression 1", function(done) { define(function(a, require, exports, module) { a.should.be.eql(123); From 73a4c7624633f87d3588ad7a548336c848c34385 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sat, 18 Nov 2017 21:03:45 +0100 Subject: [PATCH 46/85] fix an issue with schemas in subdirectories allow id property --- test/Schemas.lint.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Schemas.lint.js b/test/Schemas.lint.js index f40b5f99b..43648057f 100644 --- a/test/Schemas.lint.js +++ b/test/Schemas.lint.js @@ -7,7 +7,7 @@ const glob = require("glob"); const rootDir = path.resolve(__dirname, ".."); describe("Schemas", () => { - const schemas = glob.sync("schemas/**.json", { + const schemas = glob.sync("schemas/**/*.json", { cwd: rootDir }); @@ -38,6 +38,7 @@ describe("Schemas", () => { const allowedProperties = [ "definitions", "$ref", + "id", "items", "properties", "additionalProperties", From 93171b979577fb3721c318803cfea018a16d0d35 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sun, 19 Nov 2017 00:22:38 +0100 Subject: [PATCH 47/85] replace isEqualResource with more performance implementation --- lib/Compilation.js | 45 ++++++++++++++++----------- lib/Dependency.js | 4 +-- lib/dependencies/ContextDependency.js | 17 ++++------ lib/dependencies/ModuleDependency.js | 7 ++--- lib/dependencies/NullDependency.js | 4 --- 5 files changed, 37 insertions(+), 40 deletions(-) diff --git a/lib/Compilation.js b/lib/Compilation.js index 6e404855c..904cc0c29 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -206,15 +206,20 @@ class Compilation extends Tapable { } processModuleDependencies(module, callback) { - const dependencies = []; + const dependencies = new Map(); const addDependency = dep => { - for(let i = 0; i < dependencies.length; i++) { - if(dep.isEqualResource(dependencies[i][0])) { - return dependencies[i].push(dep); - } + const resourceIdent = dep.getResourceIdentifier(); + if(resourceIdent) { + const factory = this.dependencyFactories.get(dep.constructor); + let innerMap = dependencies.get(factory); + if(innerMap === undefined) + dependencies.set(factory, innerMap = new Map()); + let list = innerMap.get(resourceIdent); + if(list === undefined) + innerMap.set(resourceIdent, list = []); + list.push(dep); } - dependencies.push([dep]); }; const addDependenciesBlock = block => { @@ -230,23 +235,27 @@ class Compilation extends Tapable { }; addDependenciesBlock(module); - this.addModuleDependencies(module, dependencies, this.bail, null, true, callback); + + const sortedDependencies = []; + + for(const pair1 of dependencies) { + for(const pair2 of pair1[1]) { + sortedDependencies.push({ + factory: pair1[0], + dependencies: pair2[1] + }); + } + } + + this.addModuleDependencies(module, sortedDependencies, this.bail, null, true, callback); } addModuleDependencies(module, dependencies, bail, cacheGroup, recursive, callback) { let _this = this; const start = _this.profile && Date.now(); - const factories = []; - for(let i = 0; i < dependencies.length; i++) { - const factory = _this.dependencyFactories.get(dependencies[i][0].constructor); - if(!factory) { - return callback(new Error(`No module factory available for dependency type: ${dependencies[i][0].constructor.name}`)); - } - factories[i] = [factory, dependencies[i]]; - } - asyncLib.forEach(factories, (item, callback) => { - const dependencies = item[1]; + asyncLib.forEach(dependencies, (item, callback) => { + const dependencies = item.dependencies; const errorAndCallback = err => { err.origin = module; @@ -267,7 +276,7 @@ class Compilation extends Tapable { semaphore.acquire(() => { if(_this === null) return semaphore.release(); - const factory = item[0]; + const factory = item.factory; factory.create({ contextInfo: { issuer: module.nameForCondition && module.nameForCondition(), diff --git a/lib/Dependency.js b/lib/Dependency.js index b76b4e722..0cb59f380 100644 --- a/lib/Dependency.js +++ b/lib/Dependency.js @@ -12,8 +12,8 @@ class Dependency { this.optional = false; } - isEqualResource() { - return false; + getResourceIdentifier() { + return null; } // Returns the referenced module and export diff --git a/lib/dependencies/ContextDependency.js b/lib/dependencies/ContextDependency.js index 6d5131624..37cbf4038 100644 --- a/lib/dependencies/ContextDependency.js +++ b/lib/dependencies/ContextDependency.js @@ -12,6 +12,8 @@ const equalRegExp = (a, b) => { return a + "" === b + ""; }; +const regExpToString = r => r ? r + "" : ""; + class ContextDependency extends Dependency { // options: { request, recursive, regExp, include, exclude, mode, chunkName } constructor(options) { @@ -25,17 +27,10 @@ class ContextDependency extends Dependency { } } - isEqualResource(other) { - if(!(other instanceof ContextDependency)) - return false; - - return this.options.request === other.options.request && - this.options.recursive === other.options.recursive && - equalRegExp(this.options.regExp, other.options.regExp) && - equalRegExp(this.options.include, other.options.include) && - equalRegExp(this.options.exclude, other.options.exclude) && - this.options.mode === other.options.mode && - this.options.chunkName === other.options.chunkName; + getResourceIdentifier() { + return `context${this.options.request} ${this.options.recursive} ` + + `${regExpToString(this.options.regExp)} ${regExpToString(this.options.include)} ${regExpToString(this.options.exclude)} ` + + `${this.options.mode} ${this.options.chunkName}`; } getWarnings() { diff --git a/lib/dependencies/ModuleDependency.js b/lib/dependencies/ModuleDependency.js index 8a94afe24..992d86534 100644 --- a/lib/dependencies/ModuleDependency.js +++ b/lib/dependencies/ModuleDependency.js @@ -12,11 +12,8 @@ class ModuleDependency extends Dependency { this.userRequest = request; } - isEqualResource(other) { - if(!(other instanceof ModuleDependency)) - return false; - - return this.request === other.request; + getResourceIdentifier() { + return `module${this.request}`; } } diff --git a/lib/dependencies/NullDependency.js b/lib/dependencies/NullDependency.js index 2ffb090b5..585f5fc0c 100644 --- a/lib/dependencies/NullDependency.js +++ b/lib/dependencies/NullDependency.js @@ -10,10 +10,6 @@ class NullDependency extends Dependency { return "null"; } - isEqualResource() { - return false; - } - updateHash() {} } From 2ff9b53754305989b26735d3a57582a92e1b4586 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sun, 19 Nov 2017 00:50:10 +0100 Subject: [PATCH 48/85] Use StackedSetMap for better performance --- lib/optimize/ModuleConcatenationPlugin.js | 42 +++++++++++++---------- lib/util/StackedSetMap.js | 10 ++++++ 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/lib/optimize/ModuleConcatenationPlugin.js b/lib/optimize/ModuleConcatenationPlugin.js index 293a035cf..6543458df 100644 --- a/lib/optimize/ModuleConcatenationPlugin.js +++ b/lib/optimize/ModuleConcatenationPlugin.js @@ -9,6 +9,7 @@ const ModuleHotAcceptDependency = require("../dependencies/ModuleHotAcceptDepend const ModuleHotDeclineDependency = require("../dependencies/ModuleHotDeclineDependency"); const ConcatenatedModule = require("./ConcatenatedModule"); const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency"); +const StackedSetMap = require("../util/StackedSetMap"); const formatBailoutReason = msg => { return "ModuleConcatenation bailout: " + msg; @@ -126,7 +127,7 @@ class ModuleConcatenationPlugin { } if(!currentConfiguration.isEmpty()) { concatConfigurations.push(currentConfiguration); - for(const module of currentConfiguration.modules) { + for(const module of currentConfiguration.getModules()) { if(module !== currentConfiguration.rootModule) usedAsInner.add(module); } @@ -143,9 +144,9 @@ class ModuleConcatenationPlugin { for(const concatConfiguration of concatConfigurations) { if(usedModules.has(concatConfiguration.rootModule)) continue; - const newModule = new ConcatenatedModule(concatConfiguration.rootModule, Array.from(concatConfiguration.modules)); - concatConfiguration.sortWarnings(); - for(const warning of concatConfiguration.warnings) { + const modules = concatConfiguration.getModules(); + const newModule = new ConcatenatedModule(concatConfiguration.rootModule, modules); + for(const warning of concatConfiguration.getWarningsSorted()) { newModule.optimizationBailout.push((requestShortener) => { const reason = getBailoutReason(warning[0], requestShortener); const reasonWithPrefix = reason ? ` (<- ${reason})` : ""; @@ -156,7 +157,7 @@ class ModuleConcatenationPlugin { }); } const chunks = concatConfiguration.rootModule.getChunks(); - for(const m of concatConfiguration.modules) { + for(const m of modules) { usedModules.add(m); chunks.forEach(chunk => chunk.removeModule(m)); } @@ -259,10 +260,16 @@ class ModuleConcatenationPlugin { } class ConcatConfiguration { - constructor(rootModule) { + constructor(rootModule, cloneFrom) { this.rootModule = rootModule; - this.modules = new Set([rootModule]); - this.warnings = new Map(); + if(cloneFrom) { + this.modules = cloneFrom.modules.createChild(5); + this.warnings = cloneFrom.warnings.createChild(5); + } else { + this.modules = new StackedSetMap(); + this.modules.add(rootModule); + this.warnings = new StackedSetMap(); + } } add(module) { @@ -281,8 +288,8 @@ class ConcatConfiguration { this.warnings.set(module, problem); } - sortWarnings() { - this.warnings = new Map(Array.from(this.warnings).sort((a, b) => { + getWarningsSorted() { + return new Map(this.warnings.asPairArray().sort((a, b) => { const ai = a[0].identifier(); const bi = b[0].identifier(); if(ai < bi) return -1; @@ -291,19 +298,18 @@ class ConcatConfiguration { })); } + getModules() { + return this.modules.asArray(); + } + clone() { - const clone = new ConcatConfiguration(this.rootModule); - for(const module of this.modules) - clone.add(module); - for(const pair of this.warnings) - clone.addWarning(pair[0], pair[1]); - return clone; + return new ConcatConfiguration(this.rootModule, this); } set(config) { this.rootModule = config.rootModule; - this.modules = new Set(config.modules); - this.warnings = new Map(config.warnings); + this.modules = config.modules; + this.warnings = config.warnings; } } diff --git a/lib/util/StackedSetMap.js b/lib/util/StackedSetMap.js index 45f53a641..2043faf63 100644 --- a/lib/util/StackedSetMap.js +++ b/lib/util/StackedSetMap.js @@ -83,11 +83,21 @@ class StackedSetMap { return new Set(Array.from(this.map.entries()).map(pair => pair[0])); } + asArray() { + this._compress(); + return Array.from(this.map.entries()).map(pair => pair[0]); + } + asMap() { this._compress(); return new Map(this.map.entries()); } + asPairArray() { + this._compress(); + return Array.from(this.map.entries()); + } + createChild() { return new StackedSetMap(this.stack); } From 28f2ffe7f94de886111dbc0b45e3d9df06ae764c Mon Sep 17 00:00:00 2001 From: Brian Schlenker Date: Sat, 18 Nov 2017 22:45:00 -0800 Subject: [PATCH 49/85] Add test for all amd arrow function cases & fix errors Wrap interpolated functions in parenthesis so they work for both regular functions and arrow functions. Add amd arrow function tests and prevent from running through uglifyjs. --- lib/dependencies/AMDDefineDependency.js | 6 +- lib/dependencies/AMDRequireDependency.js | 8 +- .../cases/parsing/extract-amd.nominimize/a.js | 1 + .../extract-amd.nominimize/amdmodule.js | 3 + .../cases/parsing/extract-amd.nominimize/c.js | 1 + .../extract-amd.nominimize/circular.js | 2 + .../extract-amd.nominimize/constructor.js | 3 + .../cases/parsing/extract-amd.nominimize/d.js | 1 + .../parsing/extract-amd.nominimize/index.js | 118 ++++++++++++++++++ .../extract-amd.nominimize/optional.js | 3 + .../extract-amd.nominimize/templates/a.js | 1 + .../extract-amd.nominimize/templates/b.js | 1 + .../extract-amd.nominimize/templates/c.js | 1 + .../extract-amd.nominimize/test.filter.js | 5 + .../extract-amd.nominimize/warnings.js | 3 + test/cases/parsing/extract-amd/index.js | 14 --- 16 files changed, 150 insertions(+), 21 deletions(-) create mode 100644 test/cases/parsing/extract-amd.nominimize/a.js create mode 100644 test/cases/parsing/extract-amd.nominimize/amdmodule.js create mode 100644 test/cases/parsing/extract-amd.nominimize/c.js create mode 100644 test/cases/parsing/extract-amd.nominimize/circular.js create mode 100644 test/cases/parsing/extract-amd.nominimize/constructor.js create mode 100644 test/cases/parsing/extract-amd.nominimize/d.js create mode 100644 test/cases/parsing/extract-amd.nominimize/index.js create mode 100644 test/cases/parsing/extract-amd.nominimize/optional.js create mode 100644 test/cases/parsing/extract-amd.nominimize/templates/a.js create mode 100644 test/cases/parsing/extract-amd.nominimize/templates/b.js create mode 100644 test/cases/parsing/extract-amd.nominimize/templates/c.js create mode 100644 test/cases/parsing/extract-amd.nominimize/test.filter.js create mode 100644 test/cases/parsing/extract-amd.nominimize/warnings.js diff --git a/lib/dependencies/AMDDefineDependency.js b/lib/dependencies/AMDDefineDependency.js index 4222861b7..850fa3c7e 100644 --- a/lib/dependencies/AMDDefineDependency.js +++ b/lib/dependencies/AMDDefineDependency.js @@ -25,7 +25,7 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate { return { f: [ "var __WEBPACK_AMD_DEFINE_RESULT__;", - `!(__WEBPACK_AMD_DEFINE_RESULT__ = #.call(exports, __webpack_require__, exports, module), + `!(__WEBPACK_AMD_DEFINE_RESULT__ = (#).call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))` ], o: [ @@ -42,7 +42,7 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate { ], af: [ "var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;", - `!(__WEBPACK_AMD_DEFINE_ARRAY__ = #, __WEBPACK_AMD_DEFINE_RESULT__ = #.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), + `!(__WEBPACK_AMD_DEFINE_ARRAY__ = #, __WEBPACK_AMD_DEFINE_RESULT__ = (#).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))` ], ao: [ @@ -70,7 +70,7 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate { ], laf: [ "var __WEBPACK_AMD_DEFINE_ARRAY__, XXX;", - "!(__WEBPACK_AMD_DEFINE_ARRAY__ = #, XXX = (#.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)))" + "!(__WEBPACK_AMD_DEFINE_ARRAY__ = #, XXX = ((#).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)))" ], lao: [ "var XXX;", diff --git a/lib/dependencies/AMDRequireDependency.js b/lib/dependencies/AMDRequireDependency.js index b2c6365a8..b97c1fb4a 100644 --- a/lib/dependencies/AMDRequireDependency.js +++ b/lib/dependencies/AMDRequireDependency.js @@ -44,8 +44,8 @@ AMDRequireDependency.Template = class AMDRequireDependencyTemplate { source.replace(depBlock.outerRange[0], depBlock.arrayRange[0] - 1, startBlock); source.insert(depBlock.arrayRange[0] + 0.9, "var __WEBPACK_AMD_REQUIRE_ARRAY__ = "); - source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; ("); - source.insert(depBlock.functionRange[1], ".apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));"); + source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; (("); + source.insert(depBlock.functionRange[1], ").apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));"); source.replace(depBlock.functionRange[1], depBlock.errorCallbackRange[0] - 1, errorRangeBlock); source.replace(depBlock.errorCallbackRange[1], depBlock.outerRange[1] - 1, endBlock); return; @@ -57,8 +57,8 @@ AMDRequireDependency.Template = class AMDRequireDependencyTemplate { const endBlock = `}${depBlock.functionBindThis ? ".bind(this)" : ""}${wrapper[1]}__webpack_require__.oe${wrapper[2]}`; source.replace(depBlock.outerRange[0], depBlock.arrayRange[0] - 1, startBlock); source.insert(depBlock.arrayRange[0] + 0.9, "var __WEBPACK_AMD_REQUIRE_ARRAY__ = "); - source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; ("); - source.insert(depBlock.functionRange[1], ".apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));"); + source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; (("); + source.insert(depBlock.functionRange[1], ").apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));"); source.replace(depBlock.functionRange[1], depBlock.outerRange[1] - 1, endBlock); } } diff --git a/test/cases/parsing/extract-amd.nominimize/a.js b/test/cases/parsing/extract-amd.nominimize/a.js new file mode 100644 index 000000000..01cd3e713 --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/a.js @@ -0,0 +1 @@ +module.exports = "a"; \ No newline at end of file diff --git a/test/cases/parsing/extract-amd.nominimize/amdmodule.js b/test/cases/parsing/extract-amd.nominimize/amdmodule.js new file mode 100644 index 000000000..7a56b2832 --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/amdmodule.js @@ -0,0 +1,3 @@ +define((require) => { + return require("./a"); +}); diff --git a/test/cases/parsing/extract-amd.nominimize/c.js b/test/cases/parsing/extract-amd.nominimize/c.js new file mode 100644 index 000000000..ebaf7584d --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/c.js @@ -0,0 +1 @@ +module.exports = "c"; \ No newline at end of file diff --git a/test/cases/parsing/extract-amd.nominimize/circular.js b/test/cases/parsing/extract-amd.nominimize/circular.js new file mode 100644 index 000000000..e300eef61 --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/circular.js @@ -0,0 +1,2 @@ +module.exports = 1; +module.exports = require("./circular"); \ No newline at end of file diff --git a/test/cases/parsing/extract-amd.nominimize/constructor.js b/test/cases/parsing/extract-amd.nominimize/constructor.js new file mode 100644 index 000000000..4f37302d7 --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/constructor.js @@ -0,0 +1,3 @@ +module.exports = function(value) { + this.value = value; +} \ No newline at end of file diff --git a/test/cases/parsing/extract-amd.nominimize/d.js b/test/cases/parsing/extract-amd.nominimize/d.js new file mode 100644 index 000000000..76e86216b --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/d.js @@ -0,0 +1 @@ +module.exports = "d"; \ No newline at end of file diff --git a/test/cases/parsing/extract-amd.nominimize/index.js b/test/cases/parsing/extract-amd.nominimize/index.js new file mode 100644 index 000000000..f125efeed --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/index.js @@ -0,0 +1,118 @@ +var should = require("should"); + +it("should parse fancy function calls with arrow functions", function() { + ("function"==typeof define && define.amd ? + define : + (e,t) => {return t()} + )(["./constructor"], (c) => { + return new c(1324); + }); + module.exports.should.have.property("value").be.eql(1324); + (("function"==typeof define && define.amd ? + define : + (e,t) => {return t()} + )(["./constructor"], (c) => { + return new c(4231); + })); + module.exports.should.have.property("value").be.eql(4231); +}); + +it("should parse fancy AMD calls with arrow functions", function() { + require("./constructor ./a".split(" ")); + require("-> module module exports *constructor *a".replace("module", "require").substr(3).replace(/\*/g, "./").split(" "), (require, module, exports, constructor, a) => { + (typeof require).should.be.eql("function"); + (typeof module).should.be.eql("object"); + (typeof exports).should.be.eql("object"); + (typeof require("./constructor")).should.be.eql("function"); + (typeof constructor).should.be.eql("function"); + a.should.be.eql("a"); + }); + define("-> module module exports *constructor *a".replace("module", "require").substr(3).replace(/\*/g, "./").split(" "), (require, module, exports, constructor, a) => { + (typeof require).should.be.eql("function"); + (typeof module).should.be.eql("object"); + (typeof exports).should.be.eql("object"); + (typeof require("./constructor")).should.be.eql("function"); + (typeof constructor).should.be.eql("function"); + a.should.be.eql("a"); + }); +}); + +it("should be able to use AMD-style require with arrow functions", function(done) { + var template = "b"; + require(["./circular", "./templates/" + template, true ? "./circular" : "fail"], (circular, testTemplate, circular2) => { + circular.should.be.eql(1); + circular2.should.be.eql(1); + testTemplate.should.be.eql("b"); + done(); + }); +}); + +it("should be able to use require.js-style define with arrow functions", function(done) { + define("name", ["./circular"], (circular) => { + circular.should.be.eql(1); + done(); + }); +}); + +it("should be able to use require.js-style define, optional dependancies, not exist, with arrow function", function(done) { + define("name", ["./optional"], (optional) => { + should(optional.b).not.exist; + done(); + }); +}); + +it("should be able to use require.js-style define, special string, with arrow function", function(done) { + define(["require"], (require) => { + require("./circular").should.be.eql(1); + done(); + }); +}); + +it("should be able to use require.js-style define, without name, with arrow function", function(done) { + true && define(["./circular"], (circular) => { + circular.should.be.eql(1); + done(); + }); +}); + +it("should be able to use require.js-style define, with empty dependencies, with arrow function", function(done) { + define("name", [], () => { + done(); + }); +}); + +it("should be able to use require.js-style define, without dependencies, with arrow function", function(done) { + true && define("name", () => { + done(); + }); +}); + +it("should offer AMD-style define for CommonJs with arrow function", function(done) { + var _test_exports = exports; + var _test_module = module; + define((require, exports, module) => { + (typeof require).should.be.eql("function"); + exports.should.be.equal(_test_exports); + module.should.be.equal(_test_module); + require("./circular").should.be.eql(1); + done(); + }); +}); + +it("should pull in all dependencies of an AMD module with arrow function", function(done) { + define((require) => { + require("./amdmodule").should.be.eql("a"); + done(); + }); +}); + +it("should create a chunk for require.js require, with arrow function", function(done) { + var sameTick = true; + require(["./c"], (c) => { + sameTick.should.be.eql(false); + c.should.be.eql("c"); + require("./d").should.be.eql("d"); + done(); + }); + sameTick = false; +}); diff --git a/test/cases/parsing/extract-amd.nominimize/optional.js b/test/cases/parsing/extract-amd.nominimize/optional.js new file mode 100644 index 000000000..a80d7fa70 --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/optional.js @@ -0,0 +1,3 @@ +module.exports = 2; +try { module.exports.a = require("./a"); } catch (e) {}; +try { module.exports.b = require("./b"); } catch (e) {}; diff --git a/test/cases/parsing/extract-amd.nominimize/templates/a.js b/test/cases/parsing/extract-amd.nominimize/templates/a.js new file mode 100644 index 000000000..01cd3e713 --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/templates/a.js @@ -0,0 +1 @@ +module.exports = "a"; \ No newline at end of file diff --git a/test/cases/parsing/extract-amd.nominimize/templates/b.js b/test/cases/parsing/extract-amd.nominimize/templates/b.js new file mode 100644 index 000000000..fba3204fe --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/templates/b.js @@ -0,0 +1 @@ +module.exports = "b"; \ No newline at end of file diff --git a/test/cases/parsing/extract-amd.nominimize/templates/c.js b/test/cases/parsing/extract-amd.nominimize/templates/c.js new file mode 100644 index 000000000..ebaf7584d --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/templates/c.js @@ -0,0 +1 @@ +module.exports = "c"; \ No newline at end of file diff --git a/test/cases/parsing/extract-amd.nominimize/test.filter.js b/test/cases/parsing/extract-amd.nominimize/test.filter.js new file mode 100644 index 000000000..b4b5c4256 --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/test.filter.js @@ -0,0 +1,5 @@ +var supportsES6 = require("../../../helpers/supportsES6"); + +module.exports = function(config) { + return !config.minimize && supportsES6(); +}; diff --git a/test/cases/parsing/extract-amd.nominimize/warnings.js b/test/cases/parsing/extract-amd.nominimize/warnings.js new file mode 100644 index 000000000..f50952cb6 --- /dev/null +++ b/test/cases/parsing/extract-amd.nominimize/warnings.js @@ -0,0 +1,3 @@ +module.exports = [ + [/Module not found/, /Can't resolve '\.\/b' /, /b\.js/] +]; diff --git a/test/cases/parsing/extract-amd/index.js b/test/cases/parsing/extract-amd/index.js index cb76e568b..5b7738002 100644 --- a/test/cases/parsing/extract-amd/index.js +++ b/test/cases/parsing/extract-amd/index.js @@ -168,20 +168,6 @@ it("should not fail #138", function(done) { }(function () { done() })); }); -it("should parse a simplified commonjs wrapping", function(done) { - define(function(require) { - require("./a").should.be.eql("a"); - done(); - }); -}); - -it("should parse a simplified commonjs wrapping arrow function", function(done) { - define((require) => { - require("./a").should.be.eql("a"); - done(); - }); -}); - it("should parse a bound function expression 1", function(done) { define(function(a, require, exports, module) { a.should.be.eql(123); From 4c4121b948a8b041bdc0b4b18e9c274329498533 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sun, 19 Nov 2017 09:06:40 +0100 Subject: [PATCH 50/85] fix test and lint issues --- lib/Compilation.js | 8 +++++++- lib/dependencies/ContextDependency.js | 6 ------ lib/dependencies/LoaderPlugin.js | 10 +++++++--- lib/util/StackedSetMap.js | 24 ++++++++++++++---------- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/lib/Compilation.js b/lib/Compilation.js index 904cc0c29..2337a6a9b 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -212,6 +212,8 @@ class Compilation extends Tapable { const resourceIdent = dep.getResourceIdentifier(); if(resourceIdent) { const factory = this.dependencyFactories.get(dep.constructor); + if(factory === undefined) + throw new Error(`No module factory available for dependency type: ${dep.constructor.name}`); let innerMap = dependencies.get(factory); if(innerMap === undefined) dependencies.set(factory, innerMap = new Map()); @@ -234,7 +236,11 @@ class Compilation extends Tapable { } }; - addDependenciesBlock(module); + try { + addDependenciesBlock(module); + } catch(e) { + callback(e); + } const sortedDependencies = []; diff --git a/lib/dependencies/ContextDependency.js b/lib/dependencies/ContextDependency.js index 37cbf4038..1eebd51f4 100644 --- a/lib/dependencies/ContextDependency.js +++ b/lib/dependencies/ContextDependency.js @@ -6,12 +6,6 @@ const Dependency = require("../Dependency"); const CriticalDependencyWarning = require("./CriticalDependencyWarning"); -const equalRegExp = (a, b) => { - if(a === b) return true; - if(typeof a !== "object" || typeof b !== "object") return false; - return a + "" === b + ""; -}; - const regExpToString = r => r ? r + "" : ""; class ContextDependency extends Dependency { diff --git a/lib/dependencies/LoaderPlugin.js b/lib/dependencies/LoaderPlugin.js index a14af8c66..afc7c100e 100644 --- a/lib/dependencies/LoaderPlugin.js +++ b/lib/dependencies/LoaderPlugin.js @@ -19,9 +19,13 @@ class LoaderPlugin { loaderContext.loadModule = (request, callback) => { const dep = new LoaderDependency(request); dep.loc = request; - compilation.addModuleDependencies(module, [ - [dep] - ], true, "lm", false, err => { + const factory = compilation.dependencyFactories.get(dep.constructor); + if(factory === undefined) + return callback(new Error(`No module factory available for dependency type: ${dep.constructor.name}`)); + compilation.addModuleDependencies(module, [{ + factory, + dependencies: [dep] + }], true, "lm", false, err => { if(err) return callback(err); if(!dep.module) return callback(new Error("Cannot load the module")); diff --git a/lib/util/StackedSetMap.js b/lib/util/StackedSetMap.js index 2043faf63..a67a9e096 100644 --- a/lib/util/StackedSetMap.js +++ b/lib/util/StackedSetMap.js @@ -66,6 +66,7 @@ class StackedSetMap { } _compress() { + if(this.stack.length === 1) return; this.map = new Map(); for(const data of this.stack) { for(const pair of data) { @@ -78,24 +79,27 @@ class StackedSetMap { this.stack = [this.map]; } - asSet() { - this._compress(); - return new Set(Array.from(this.map.entries()).map(pair => pair[0])); - } - asArray() { this._compress(); - return Array.from(this.map.entries()).map(pair => pair[0]); + return Array.from(this.map.entries(), pair => pair[0]); } - asMap() { - this._compress(); - return new Map(this.map.entries()); + asSet() { + return new Set(this.asArray()); } asPairArray() { this._compress(); - return Array.from(this.map.entries()); + return Array.from(this.map.entries(), pair => pair[1] === UNDEFINED_MARKER ? [pair[0], undefined] : pair); + } + + asMap() { + return new Map(this.asPairArray()); + } + + get size() { + this._compress(); + return this.map.size; } createChild() { From 4655836ee8313bb2d582af46921986af06a449f0 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Sun, 19 Nov 2017 09:13:26 +0100 Subject: [PATCH 51/85] remove outdated unittest --- test/NullDependency.unittest.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/NullDependency.unittest.js b/test/NullDependency.unittest.js index cbdfbb0a8..5f6f1f5eb 100644 --- a/test/NullDependency.unittest.js +++ b/test/NullDependency.unittest.js @@ -16,8 +16,6 @@ describe("NullDependency", () => { it("has a null type", () => env.nullDependency.type.should.be.exactly("null")); - it("is not an equal resource", () => env.nullDependency.isEqualResource().should.be.False()); - it("has update hash function", () => env.nullDependency.updateHash.should.be.Function()); it("does not update hash", () => { From 61d91f5b75c118047e01d4cd89806bfcebe955b3 Mon Sep 17 00:00:00 2001 From: EugeneHlushko Date: Sun, 19 Nov 2017 18:58:07 +0200 Subject: [PATCH 52/85] Improvement: Ensure respect for --no-deprecation flag when adding non util.depracation warnings to console output --- lib/Compiler.js | 4 ++-- lib/NoErrorsPlugin.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Compiler.js b/lib/Compiler.js index 943ae48a6..2976317f1 100644 --- a/lib/Compiler.js +++ b/lib/Compiler.js @@ -189,7 +189,7 @@ class Compiler extends Tapable { let deprecationReported = false; this.parser = { plugin: (hook, fn) => { - if(!deprecationReported) { + if(!deprecationReported && process.noDeprecation !== true) { console.warn("webpack: Using compiler.parser is deprecated.\n" + "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.plugin(/* ... */); });\n}); instead. " + "It was called " + new Error().stack.split("\n")[2].trim() + "."); @@ -203,7 +203,7 @@ class Compiler extends Tapable { }, apply: () => { const args = arguments; - if(!deprecationReported) { + if(!deprecationReported && process.noDeprecation !== true) { console.warn("webpack: Using compiler.parser is deprecated.\n" + "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.apply(/* ... */); });\n}); instead. " + "It was called " + new Error().stack.split("\n")[2].trim() + "."); diff --git a/lib/NoErrorsPlugin.js b/lib/NoErrorsPlugin.js index fd543d250..a5ebaea86 100644 --- a/lib/NoErrorsPlugin.js +++ b/lib/NoErrorsPlugin.js @@ -9,7 +9,7 @@ let deprecationReported = false; class NoErrorsPlugin { apply(compiler) { compiler.plugin("should-emit", (compilation) => { - if(!deprecationReported) { + if(!deprecationReported && process.noDeprecation !== true) { compilation.warnings.push("webpack: Using NoErrorsPlugin is deprecated.\n" + "Use NoEmitOnErrorsPlugin instead.\n"); deprecationReported = true; From f14c301dba9300cec03b32bae67261cc3cb70270 Mon Sep 17 00:00:00 2001 From: EugeneHlushko Date: Mon, 20 Nov 2017 12:02:10 +0200 Subject: [PATCH 53/85] Improvement: Ensure util.depracation use for deprecation warnings --- lib/Compiler.js | 48 ++++++++++++++++++++----------------------- lib/NoErrorsPlugin.js | 19 ++++++++--------- test/Compiler.test.js | 8 ++++++++ test/Errors.test.js | 34 +++++++++++++++--------------- 4 files changed, 56 insertions(+), 53 deletions(-) diff --git a/lib/Compiler.js b/lib/Compiler.js index 2976317f1..1ae235973 100644 --- a/lib/Compiler.js +++ b/lib/Compiler.js @@ -6,6 +6,7 @@ const path = require("path"); const Tapable = require("tapable"); +const util = require("util"); const Compilation = require("./Compilation"); const Stats = require("./Stats"); @@ -186,35 +187,30 @@ class Compiler extends Tapable { loader: null, context: null }; - let deprecationReported = false; this.parser = { - plugin: (hook, fn) => { - if(!deprecationReported && process.noDeprecation !== true) { - console.warn("webpack: Using compiler.parser is deprecated.\n" + - "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.plugin(/* ... */); });\n}); instead. " + - "It was called " + new Error().stack.split("\n")[2].trim() + "."); - deprecationReported = true; - } - this.plugin("compilation", (compilation, data) => { - data.normalModuleFactory.plugin("parser", parser => { - parser.plugin(hook, fn); + plugin: util.deprecate( + (hook, fn) => { + this.plugin("compilation", (compilation, data) => { + data.normalModuleFactory.plugin("parser", parser => { + parser.plugin(hook, fn); + }); }); - }); - }, - apply: () => { - const args = arguments; - if(!deprecationReported && process.noDeprecation !== true) { - console.warn("webpack: Using compiler.parser is deprecated.\n" + - "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.apply(/* ... */); });\n}); instead. " + - "It was called " + new Error().stack.split("\n")[2].trim() + "."); - deprecationReported = true; - } - this.plugin("compilation", (compilation, data) => { - data.normalModuleFactory.plugin("parser", parser => { - parser.apply.apply(parser, args); + }, + "webpack: Using compiler.parser is deprecated.\n" + + "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.plugin(/* ... */); });\n}); instead. " + ), + apply: util.deprecate( + () => { + const args = arguments; + this.plugin("compilation", (compilation, data) => { + data.normalModuleFactory.plugin("parser", parser => { + parser.apply(parser, args); + }); }); - }); - } + }, + "webpack: Using compiler.parser is deprecated.\n" + + "Use compiler.plugin(\"compilation\", function(compilation, data) {\n data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.apply(/* ... */); });\n}); instead. " + ) }; this.options = {}; diff --git a/lib/NoErrorsPlugin.js b/lib/NoErrorsPlugin.js index a5ebaea86..b1f8b502b 100644 --- a/lib/NoErrorsPlugin.js +++ b/lib/NoErrorsPlugin.js @@ -4,19 +4,18 @@ */ "use strict"; -let deprecationReported = false; +const util = require("util"); class NoErrorsPlugin { apply(compiler) { - compiler.plugin("should-emit", (compilation) => { - if(!deprecationReported && process.noDeprecation !== true) { - compilation.warnings.push("webpack: Using NoErrorsPlugin is deprecated.\n" + - "Use NoEmitOnErrorsPlugin instead.\n"); - deprecationReported = true; - } - if(compilation.errors.length > 0) - return false; - }); + compiler.plugin("should-emit", util.deprecate( + (compilation) => { + if(compilation.errors.length > 0) + return false; + }, + "webpack: Using NoErrorsPlugin is deprecated.\n" + + "Use NoEmitOnErrorsPlugin instead.\n" + )); compiler.plugin("compilation", (compilation) => { compilation.plugin("should-record", () => { if(compilation.errors.length > 0) diff --git a/test/Compiler.test.js b/test/Compiler.test.js index 8a0e3c53e..766699c57 100644 --- a/test/Compiler.test.js +++ b/test/Compiler.test.js @@ -178,6 +178,14 @@ describe("Compiler", () => { }); }); describe("parser", () => { + describe("plugin", () => { + it("invokes sets a 'compilation' plugin", (done) => { + compiler.plugin = sinon.spy(); + compiler.parser.plugin(); + compiler.plugin.callCount.should.be.exactly(1); + done(); + }); + }); describe("apply", () => { it("invokes sets a 'compilation' plugin", (done) => { compiler.plugin = sinon.spy(); diff --git a/test/Errors.test.js b/test/Errors.test.js index 802aa9f73..f071868ce 100644 --- a/test/Errors.test.js +++ b/test/Errors.test.js @@ -94,23 +94,23 @@ describe("Errors", () => { done(); }); }); - it("should warn about NoErrorsPlugin being deprecated in favor of NoEmitOnErrorsPlugin", (done) => { - getErrors({ - entry: "./no-errors-deprecate", - plugins: [ - new webpack.NoErrorsPlugin() - ] - }, (errors, warnings) => { - warnings.length.should.be.eql(1); - const lines = warnings[0].split("\n"); - lines[0].should.match(/webpack/); - lines[0].should.match(/NoErrorsPlugin/); - lines[0].should.match(/deprecated/); - lines[1].should.match(/NoEmitOnErrorsPlugin/); - lines[1].should.match(/instead/); - done(); - }); - }); + // it("should warn about NoErrorsPlugin being deprecated in favor of NoEmitOnErrorsPlugin", (done) => { + // getErrors({ + // entry: "./no-errors-deprecate", + // plugins: [ + // new webpack.NoErrorsPlugin() + // ] + // }, (errors, warnings) => { + // warnings.length.should.be.eql(1); + // const lines = warnings[0].split("\n"); + // lines[0].should.match(/webpack/); + // lines[0].should.match(/NoErrorsPlugin/); + // lines[0].should.match(/deprecated/); + // lines[1].should.match(/NoEmitOnErrorsPlugin/); + // lines[1].should.match(/instead/); + // done(); + // }); + // }); it("should not warn if the NoEmitOnErrorsPlugin is used over the NoErrorsPlugin", (done) => { getErrors({ entry: "./no-errors-deprecate", From 56a4af04f5e49c921939d8beca5100a18cfbabc4 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 20 Nov 2017 12:44:00 +0100 Subject: [PATCH 54/85] use type from manifest --- lib/DllReferencePlugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/DllReferencePlugin.js b/lib/DllReferencePlugin.js index bc314250c..200b5e1c7 100644 --- a/lib/DllReferencePlugin.js +++ b/lib/DllReferencePlugin.js @@ -42,7 +42,7 @@ class DllReferencePlugin { manifest = params["dll reference " + manifest]; } const name = this.options.name || manifest.name; - const sourceType = this.options.sourceType || "var"; + const sourceType = this.options.sourceType || (manifest && manifest.type) || "var"; const externals = {}; const source = "dll-reference " + name; externals[source] = name; From 639446cc58369d1003e86fbf9b37e12f0ebd0ea0 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 20 Nov 2017 12:49:14 +0100 Subject: [PATCH 55/85] remove the NoErrorsPlugin #5985 --- lib/NoErrorsPlugin.js | 29 ----------------------------- lib/webpack.js | 1 - test/Errors.test.js | 17 ----------------- 3 files changed, 47 deletions(-) delete mode 100644 lib/NoErrorsPlugin.js diff --git a/lib/NoErrorsPlugin.js b/lib/NoErrorsPlugin.js deleted file mode 100644 index fd543d250..000000000 --- a/lib/NoErrorsPlugin.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -let deprecationReported = false; - -class NoErrorsPlugin { - apply(compiler) { - compiler.plugin("should-emit", (compilation) => { - if(!deprecationReported) { - compilation.warnings.push("webpack: Using NoErrorsPlugin is deprecated.\n" + - "Use NoEmitOnErrorsPlugin instead.\n"); - deprecationReported = true; - } - if(compilation.errors.length > 0) - return false; - }); - compiler.plugin("compilation", (compilation) => { - compilation.plugin("should-record", () => { - if(compilation.errors.length > 0) - return false; - }); - }); - } -} - -module.exports = NoErrorsPlugin; diff --git a/lib/webpack.js b/lib/webpack.js index d1fedfd2b..c1764b325 100644 --- a/lib/webpack.js +++ b/lib/webpack.js @@ -93,7 +93,6 @@ exportPlugins(exports, { "ProgressPlugin": () => require("./ProgressPlugin"), "SetVarMainTemplatePlugin": () => require("./SetVarMainTemplatePlugin"), "UmdMainTemplatePlugin": () => require("./UmdMainTemplatePlugin"), - "NoErrorsPlugin": () => require("./NoErrorsPlugin"), "NoEmitOnErrorsPlugin": () => require("./NoEmitOnErrorsPlugin"), "NewWatchingPlugin": () => require("./NewWatchingPlugin"), "EnvironmentPlugin": () => require("./EnvironmentPlugin"), diff --git a/test/Errors.test.js b/test/Errors.test.js index 802aa9f73..f2d41af3c 100644 --- a/test/Errors.test.js +++ b/test/Errors.test.js @@ -94,23 +94,6 @@ describe("Errors", () => { done(); }); }); - it("should warn about NoErrorsPlugin being deprecated in favor of NoEmitOnErrorsPlugin", (done) => { - getErrors({ - entry: "./no-errors-deprecate", - plugins: [ - new webpack.NoErrorsPlugin() - ] - }, (errors, warnings) => { - warnings.length.should.be.eql(1); - const lines = warnings[0].split("\n"); - lines[0].should.match(/webpack/); - lines[0].should.match(/NoErrorsPlugin/); - lines[0].should.match(/deprecated/); - lines[1].should.match(/NoEmitOnErrorsPlugin/); - lines[1].should.match(/instead/); - done(); - }); - }); it("should not warn if the NoEmitOnErrorsPlugin is used over the NoErrorsPlugin", (done) => { getErrors({ entry: "./no-errors-deprecate", From 6a1f4242be39cb42496390556b5105c7260fca9a Mon Sep 17 00:00:00 2001 From: EugeneHlushko Date: Mon, 20 Nov 2017 13:55:21 +0200 Subject: [PATCH 56/85] Improvement: Ensure util.depracation use for deprecation warnings: revert NoErrors plugin --- lib/NoErrorsPlugin.js | 19 ++++++++++--------- test/Errors.test.js | 34 +++++++++++++++++----------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/lib/NoErrorsPlugin.js b/lib/NoErrorsPlugin.js index b1f8b502b..fd543d250 100644 --- a/lib/NoErrorsPlugin.js +++ b/lib/NoErrorsPlugin.js @@ -4,18 +4,19 @@ */ "use strict"; -const util = require("util"); +let deprecationReported = false; class NoErrorsPlugin { apply(compiler) { - compiler.plugin("should-emit", util.deprecate( - (compilation) => { - if(compilation.errors.length > 0) - return false; - }, - "webpack: Using NoErrorsPlugin is deprecated.\n" + - "Use NoEmitOnErrorsPlugin instead.\n" - )); + compiler.plugin("should-emit", (compilation) => { + if(!deprecationReported) { + compilation.warnings.push("webpack: Using NoErrorsPlugin is deprecated.\n" + + "Use NoEmitOnErrorsPlugin instead.\n"); + deprecationReported = true; + } + if(compilation.errors.length > 0) + return false; + }); compiler.plugin("compilation", (compilation) => { compilation.plugin("should-record", () => { if(compilation.errors.length > 0) diff --git a/test/Errors.test.js b/test/Errors.test.js index f071868ce..802aa9f73 100644 --- a/test/Errors.test.js +++ b/test/Errors.test.js @@ -94,23 +94,23 @@ describe("Errors", () => { done(); }); }); - // it("should warn about NoErrorsPlugin being deprecated in favor of NoEmitOnErrorsPlugin", (done) => { - // getErrors({ - // entry: "./no-errors-deprecate", - // plugins: [ - // new webpack.NoErrorsPlugin() - // ] - // }, (errors, warnings) => { - // warnings.length.should.be.eql(1); - // const lines = warnings[0].split("\n"); - // lines[0].should.match(/webpack/); - // lines[0].should.match(/NoErrorsPlugin/); - // lines[0].should.match(/deprecated/); - // lines[1].should.match(/NoEmitOnErrorsPlugin/); - // lines[1].should.match(/instead/); - // done(); - // }); - // }); + it("should warn about NoErrorsPlugin being deprecated in favor of NoEmitOnErrorsPlugin", (done) => { + getErrors({ + entry: "./no-errors-deprecate", + plugins: [ + new webpack.NoErrorsPlugin() + ] + }, (errors, warnings) => { + warnings.length.should.be.eql(1); + const lines = warnings[0].split("\n"); + lines[0].should.match(/webpack/); + lines[0].should.match(/NoErrorsPlugin/); + lines[0].should.match(/deprecated/); + lines[1].should.match(/NoEmitOnErrorsPlugin/); + lines[1].should.match(/instead/); + done(); + }); + }); it("should not warn if the NoEmitOnErrorsPlugin is used over the NoErrorsPlugin", (done) => { getErrors({ entry: "./no-errors-deprecate", From 6051cb146ed1856d13e2e996d5f5cc6796f3b9d1 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 21 Nov 2017 10:41:15 +0100 Subject: [PATCH 57/85] remove unused MovedToPluginWarningPlugin --- lib/MovedToPluginWarningPlugin.js | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 lib/MovedToPluginWarningPlugin.js diff --git a/lib/MovedToPluginWarningPlugin.js b/lib/MovedToPluginWarningPlugin.js deleted file mode 100644 index 5dbf5cf18..000000000 --- a/lib/MovedToPluginWarningPlugin.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; -module.exports = class MovedToPluginWarningPlugin { - constructor(optionName, pluginName) { - this.optionName = optionName; - this.pluginName = pluginName; - } - apply(compiler) { - const optionName = this.optionName; - const pluginName = this.pluginName; - compiler.plugin("compilation", (compilation) => { - compilation.warnings.push(new Error `webpack options: - DEPRECATED option ${optionName} will be moved to the ${pluginName}. - Use this instead. - For more info about the usage of the ${pluginName} see https://webpack.js.org/plugins/`); - }); - } -}; From ee31dc4d29bf3c17b7116b77100d8cb5cbc76a1a Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 21 Nov 2017 10:41:32 +0100 Subject: [PATCH 58/85] removed deprecated NewWatchingPlugin --- lib/NewWatchingPlugin.js | 15 --------------- .../plugins/new-watching-plugin/index.js | 1 - .../plugins/new-watching-plugin/warnings.js | 3 --- .../plugins/new-watching-plugin/webpack.config.js | 6 ------ 4 files changed, 25 deletions(-) delete mode 100644 lib/NewWatchingPlugin.js delete mode 100644 test/configCases/plugins/new-watching-plugin/index.js delete mode 100644 test/configCases/plugins/new-watching-plugin/warnings.js delete mode 100644 test/configCases/plugins/new-watching-plugin/webpack.config.js diff --git a/lib/NewWatchingPlugin.js b/lib/NewWatchingPlugin.js deleted file mode 100644 index 330f2fbbd..000000000 --- a/lib/NewWatchingPlugin.js +++ /dev/null @@ -1,15 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -class NewWatchingPlugin { - apply(compiler) { - compiler.plugin("compilation", compilation => { - compilation.warnings.push(new Error("The 'NewWatchingPlugin' is no longer necessary (now default)")); - }); - } -} - -module.exports = NewWatchingPlugin; diff --git a/test/configCases/plugins/new-watching-plugin/index.js b/test/configCases/plugins/new-watching-plugin/index.js deleted file mode 100644 index b8411bd99..000000000 --- a/test/configCases/plugins/new-watching-plugin/index.js +++ /dev/null @@ -1 +0,0 @@ -it("should run", function() {}); \ No newline at end of file diff --git a/test/configCases/plugins/new-watching-plugin/warnings.js b/test/configCases/plugins/new-watching-plugin/warnings.js deleted file mode 100644 index f2d60392a..000000000 --- a/test/configCases/plugins/new-watching-plugin/warnings.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = [ - [/no longer necessary/], -]; diff --git a/test/configCases/plugins/new-watching-plugin/webpack.config.js b/test/configCases/plugins/new-watching-plugin/webpack.config.js deleted file mode 100644 index 630038396..000000000 --- a/test/configCases/plugins/new-watching-plugin/webpack.config.js +++ /dev/null @@ -1,6 +0,0 @@ -var webpack = require("../../../../"); -module.exports = { - plugins: [ - new webpack.NewWatchingPlugin() - ] -}; From 86c3bdc3d39fd0b3f651da33b13219acdc42d083 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 21 Nov 2017 12:55:52 +0100 Subject: [PATCH 59/85] add temporary workarounds for not-updated file-loader --- examples/code-splitted-css-bundle/webpack.config.js | 8 +++++++- examples/css-bundle/webpack.config.js | 8 +++++++- .../webpack.config.js | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/examples/code-splitted-css-bundle/webpack.config.js b/examples/code-splitted-css-bundle/webpack.config.js index a7ac661c7..446541ce3 100644 --- a/examples/code-splitted-css-bundle/webpack.config.js +++ b/examples/code-splitted-css-bundle/webpack.config.js @@ -1,4 +1,6 @@ -var ExtractTextPlugin = require("extract-text-webpack-plugin"); +const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin; + +const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { module: { rules: [ @@ -15,6 +17,10 @@ module.exports = { plugins: [ new ExtractTextPlugin({ filename: "style.css" + }), + // Temporary workaround for the file-loader + new LoaderOptionsPlugin({ + options: {} }) ] }; diff --git a/examples/css-bundle/webpack.config.js b/examples/css-bundle/webpack.config.js index 7df4e6330..3181cf355 100644 --- a/examples/css-bundle/webpack.config.js +++ b/examples/css-bundle/webpack.config.js @@ -1,4 +1,6 @@ -var ExtractTextPlugin = require("extract-text-webpack-plugin"); +const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin; + +const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { module: { rules: [ @@ -15,6 +17,10 @@ module.exports = { new ExtractTextPlugin({ filename: "style.css", allChunks: true + }), + // Temporary workaround for the file-loader + new LoaderOptionsPlugin({ + options: {} }) ] }; diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js b/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js index 64aad2871..66b72a743 100644 --- a/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js +++ b/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js @@ -1,4 +1,5 @@ var path = require("path"); +const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin; var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); var ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { @@ -32,5 +33,9 @@ module.exports = { new ExtractTextPlugin({ filename: "[name].css" }), + // Temporary workaround for the file-loader + new LoaderOptionsPlugin({ + options: {} + }) ] }; From 35d7f51b8812517728c6815cae735d685d67c17f Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 21 Nov 2017 12:56:12 +0100 Subject: [PATCH 60/85] rename side-effects to sideEffects in example --- .../side-effects/node_modules/big-module-with-flag/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/side-effects/node_modules/big-module-with-flag/package.json b/examples/side-effects/node_modules/big-module-with-flag/package.json index d6fb0331e..5f16b9c59 100644 --- a/examples/side-effects/node_modules/big-module-with-flag/package.json +++ b/examples/side-effects/node_modules/big-module-with-flag/package.json @@ -1,4 +1,4 @@ { "name": "big-module-with-flag", - "side-effects": false + "sideEffects": false } From 5d78ba9c9070a6a4206b9ec412ecb2079272c9c2 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 21 Nov 2017 12:56:33 +0100 Subject: [PATCH 61/85] fix incorrect behavior of CommonsChunkPlugin --- lib/optimize/CommonsChunkPlugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/optimize/CommonsChunkPlugin.js b/lib/optimize/CommonsChunkPlugin.js index c6b192bea..08a16be53 100644 --- a/lib/optimize/CommonsChunkPlugin.js +++ b/lib/optimize/CommonsChunkPlugin.js @@ -282,7 +282,7 @@ Take a look at the "name"/"names" or async/children option.`); return allChunks.filter((chunk) => { const found = targetChunks.indexOf(chunk); if(found >= currentIndex) return false; - return chunk.isInitial(); + return chunk.hasRuntime(); }); } From a6f0ca9c07a02d48dff86deca46d5926edbb9fc5 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 21 Nov 2017 12:56:55 +0100 Subject: [PATCH 62/85] fix incorrect update of the WebWorker Template --- lib/webworker/WebWorkerChunkTemplatePlugin.js | 2 +- lib/webworker/WebWorkerMainTemplatePlugin.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/webworker/WebWorkerChunkTemplatePlugin.js b/lib/webworker/WebWorkerChunkTemplatePlugin.js index 4a28ec0a8..5f972c8ed 100644 --- a/lib/webworker/WebWorkerChunkTemplatePlugin.js +++ b/lib/webworker/WebWorkerChunkTemplatePlugin.js @@ -13,7 +13,7 @@ class WebWorkerChunkTemplatePlugin { chunkTemplate.plugin("render", (modules, chunk) => { const chunkCallbackName = chunkTemplate.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (chunkTemplate.outputOptions.library || "")); const source = new ConcatSource(); - source.add(`${chunkCallbackName}(${JSON.stringify(chunk.ids)},`); + source.add(`self[${JSON.stringify(chunkCallbackName)}](${JSON.stringify(chunk.ids)},`); source.add(modules); source.add(")"); return source; diff --git a/lib/webworker/WebWorkerMainTemplatePlugin.js b/lib/webworker/WebWorkerMainTemplatePlugin.js index 387e73d0b..369dcea56 100644 --- a/lib/webworker/WebWorkerMainTemplatePlugin.js +++ b/lib/webworker/WebWorkerMainTemplatePlugin.js @@ -27,7 +27,7 @@ class WebWorkerMainTemplatePlugin { mainTemplate.plugin("require-ensure", (_, chunk, hash) => { const chunkFilename = mainTemplate.outputOptions.chunkFilename; return mainTemplate.asString([ - "return new Promise(function(resolve) {", + "promises.push(Promise.resolve().then(function() {", mainTemplate.indent([ "// \"1\" is the signal for \"already loaded\"", "if(!installedChunks[chunkId]) {", @@ -42,9 +42,8 @@ class WebWorkerMainTemplatePlugin { }) + ");" ]), "}", - "resolve();" ]), - "});" + "}));" ]); }); mainTemplate.plugin("bootstrap", (source, chunk, hash) => { @@ -52,7 +51,7 @@ class WebWorkerMainTemplatePlugin { const chunkCallbackName = mainTemplate.outputOptions.chunkCallbackName || Template.toIdentifier("webpackChunk" + (mainTemplate.outputOptions.library || "")); return mainTemplate.asString([ source, - `mainTemplate[${JSON.stringify(chunkCallbackName)}] = function webpackChunkCallback(chunkIds, moreModules) {`, + `self[${JSON.stringify(chunkCallbackName)}] = function webpackChunkCallback(chunkIds, moreModules) {`, mainTemplate.indent([ "for(var moduleId in moreModules) {", mainTemplate.indent(mainTemplate.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")), From 5840039701262d76dfd240abe26f09b426f829ca Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 21 Nov 2017 12:57:11 +0100 Subject: [PATCH 63/85] add chunkCallbackName from WebWorker to schema --- schemas/webpackOptionsSchema.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/schemas/webpackOptionsSchema.json b/schemas/webpackOptionsSchema.json index 7f1ee87bf..a44837a10 100644 --- a/schemas/webpackOptionsSchema.json +++ b/schemas/webpackOptionsSchema.json @@ -401,6 +401,10 @@ "description": "The JSONP function used by webpack for async loading of chunks.", "type": "string" }, + "chunkCallbackName": { + "description": "The callback function name used by webpack for loading of chunks in WebWorkers.", + "type": "string" + }, "library": { "anyOf": [ { From 8363773f3fb98b3b3e7b7c3a9ddb1d71575c0d97 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 21 Nov 2017 12:57:40 +0100 Subject: [PATCH 64/85] only emit wasm runtime code for bundles containing wasm --- lib/Chunk.js | 18 ++++++++++++++++++ lib/web/FetchCompileWasmMainTemplatePlugin.js | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/lib/Chunk.js b/lib/Chunk.js index 885d07671..0fc917fff 100644 --- a/lib/Chunk.js +++ b/lib/Chunk.js @@ -579,6 +579,24 @@ class Chunk { }; } + hasModuleInGraph(filterFn) { + const chunksProcessed = new Set(); + const queue = [this]; + + while(queue.length > 0) { + const chunk = queue.pop(); + if(chunk.getModules().some(filterFn)) + return true; + for(const next of chunk.chunksIterable) { + if(!chunksProcessed.has(next)) { + chunksProcessed.add(next); + queue.push(next); + } + } + } + return false; + } + sortModules(sortByFn) { this._modules.sortWith(sortByFn || sortById); } diff --git a/lib/web/FetchCompileWasmMainTemplatePlugin.js b/lib/web/FetchCompileWasmMainTemplatePlugin.js index 813c7b820..75c0b3326 100644 --- a/lib/web/FetchCompileWasmMainTemplatePlugin.js +++ b/lib/web/FetchCompileWasmMainTemplatePlugin.js @@ -8,6 +8,8 @@ class FetchCompileWasmMainTemplatePlugin { apply(mainTemplate) { mainTemplate.plugin("local-vars", (source, chunk) => { + if(!chunk.hasModuleInGraph(m => m.type.startsWith("webassembly"))) + return source; return mainTemplate.asString([ source, "", @@ -69,6 +71,8 @@ class FetchCompileWasmMainTemplatePlugin { ]); }); mainTemplate.plugin("require-extensions", (source, chunk) => { + if(!chunk.hasModuleInGraph(m => m.type.startsWith("webassembly"))) + return source; return mainTemplate.asString([ source, "", From ae2919d28a7d014b8b68d11c42675ef7eb4ead86 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 21 Nov 2017 12:59:14 +0100 Subject: [PATCH 65/85] update stats cases for smaller bundles --- .../aggressive-splitting-entry/expected.txt | 4 +-- .../expected.txt | 2 +- test/statsCases/chunks/expected.txt | 2 +- test/statsCases/color-disabled/expected.txt | 2 +- .../color-enabled-custom/expected.txt | 2 +- test/statsCases/color-enabled/expected.txt | 2 +- .../commons-chunk-min-size-0/expected.txt | 2 +- .../expected.txt | 4 +-- .../expected.txt | 10 +++--- .../commons-plugin-issue-4980/expected.txt | 4 +-- test/statsCases/define-plugin/expected.txt | 4 +-- .../exclude-with-loader/expected.txt | 2 +- test/statsCases/external/expected.txt | 2 +- test/statsCases/filter-warnings/expected.txt | 33 ++++++++----------- .../import-context-filter/expected.txt | 2 +- test/statsCases/import-weak/expected.txt | 2 +- .../limit-chunk-count-plugin/expected.txt | 8 ++--- .../max-modules-default/expected.txt | 2 +- test/statsCases/max-modules/expected.txt | 2 +- .../module-deduplication-named/expected.txt | 6 ++-- .../module-deduplication/expected.txt | 6 ++-- .../expected.txt | 4 +-- .../expected.txt | 4 +-- .../named-chunks-plugin-async/expected.txt | 2 +- .../named-chunks-plugin/expected.txt | 10 +++--- test/statsCases/optimize-chunks/expected.txt | 2 +- test/statsCases/parse-error/expected.txt | 2 +- .../expected.txt | 2 +- test/statsCases/preset-detailed/expected.txt | 2 +- test/statsCases/preset-normal/expected.txt | 2 +- test/statsCases/preset-verbose/expected.txt | 2 +- .../resolve-plugin-context/expected.txt | 2 +- .../reverse-sort-modules/expected.txt | 2 +- .../separate-css-bundle/expected.txt | 4 +-- test/statsCases/simple-more-info/expected.txt | 2 +- test/statsCases/simple/expected.txt | 2 +- test/statsCases/tree-shaking/expected.txt | 2 +- .../statsCases/warnings-uglifyjs/expected.txt | 2 +- 38 files changed, 72 insertions(+), 79 deletions(-) diff --git a/test/statsCases/aggressive-splitting-entry/expected.txt b/test/statsCases/aggressive-splitting-entry/expected.txt index f40997664..96d5fbc7a 100644 --- a/test/statsCases/aggressive-splitting-entry/expected.txt +++ b/test/statsCases/aggressive-splitting-entry/expected.txt @@ -5,7 +5,7 @@ Child fitting: Asset Size Chunks Chunk Names 3b0abf784cffee9cdb84.js 2.23 KiB 0 [emitted] fd43aeccca69e5179cb6.js 1.93 KiB 4 [emitted] - 0fb4d7363ffcca01b706.js 5.8 KiB 5 [emitted] + 0fb4d7363ffcca01b706.js 5.59 KiB 5 [emitted] e1f8db72211be4caf41d.js 1 KiB 6 [emitted] Entrypoint main = 0fb4d7363ffcca01b706.js e1f8db72211be4caf41d.js fd43aeccca69e5179cb6.js 3b0abf784cffee9cdb84.js chunk {0} 3b0abf784cffee9cdb84.js 1.87 KiB [initial] [rendered] @@ -30,7 +30,7 @@ Child content-change: Asset Size Chunks Chunk Names 3b0abf784cffee9cdb84.js 2.23 KiB 0 [emitted] fd43aeccca69e5179cb6.js 1.93 KiB 4 [emitted] - 0fb4d7363ffcca01b706.js 5.8 KiB 5 [emitted] + 0fb4d7363ffcca01b706.js 5.59 KiB 5 [emitted] e1f8db72211be4caf41d.js 1 KiB 6 [emitted] Entrypoint main = 0fb4d7363ffcca01b706.js e1f8db72211be4caf41d.js fd43aeccca69e5179cb6.js 3b0abf784cffee9cdb84.js chunk {0} 3b0abf784cffee9cdb84.js 1.87 KiB [initial] [rendered] diff --git a/test/statsCases/aggressive-splitting-on-demand/expected.txt b/test/statsCases/aggressive-splitting-on-demand/expected.txt index 4e9acf9eb..acc2e8bc2 100644 --- a/test/statsCases/aggressive-splitting-on-demand/expected.txt +++ b/test/statsCases/aggressive-splitting-on-demand/expected.txt @@ -8,7 +8,7 @@ fcea9401f4f21cf79d39.js 1.94 KiB 1 [emitted] c1e3d74e221cc503e2e1.js 1.94 KiB 4 [emitted] 3d41758100f56aac517e.js 1 KiB 5 [emitted] c64eeda8f0bfba682f9d.js 1.01 KiB 6 [emitted] -520c994eaddf273485ec.js 8.3 KiB 7 [emitted] main +520c994eaddf273485ec.js 8.09 KiB 7 [emitted] main Entrypoint main = 520c994eaddf273485ec.js chunk {0} 1744d4ad4296f5fa250c.js 1.76 KiB {7} [recorded] > aggressive-splitted duplicate [11] (webpack)/test/statsCases/aggressive-splitting-on-demand/index.js 4:0-51 diff --git a/test/statsCases/chunks/expected.txt b/test/statsCases/chunks/expected.txt index d1e4ee622..6420de213 100644 --- a/test/statsCases/chunks/expected.txt +++ b/test/statsCases/chunks/expected.txt @@ -4,7 +4,7 @@ Time: Xms 0.bundle.js 288 bytes 0 [emitted] 1.bundle.js 152 bytes 1 [emitted] 2.bundle.js 232 bytes 2 [emitted] - bundle.js 6.97 KiB 3 [emitted] main + bundle.js 6.76 KiB 3 [emitted] main chunk {0} 0.bundle.js 54 bytes {3} [rendered] > [0] (webpack)/test/statsCases/chunks/index.js 3:0-16 [3] (webpack)/test/statsCases/chunks/c.js 54 bytes {0} [built] diff --git a/test/statsCases/color-disabled/expected.txt b/test/statsCases/color-disabled/expected.txt index 46c85bb30..3b3cddcb8 100644 --- a/test/statsCases/color-disabled/expected.txt +++ b/test/statsCases/color-disabled/expected.txt @@ -1,5 +1,5 @@ Hash: 9b62d877d26dd61e1fb9 Time: Xms Asset Size Chunks Chunk Names -main.js 2.63 KiB 0 [emitted] main +main.js 2.42 KiB 0 [emitted] main [0] (webpack)/test/statsCases/color-disabled/index.js 0 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/color-enabled-custom/expected.txt b/test/statsCases/color-enabled-custom/expected.txt index dea3d5840..f1264fd7b 100644 --- a/test/statsCases/color-enabled-custom/expected.txt +++ b/test/statsCases/color-enabled-custom/expected.txt @@ -1,5 +1,5 @@ Hash: 9b62d877d26dd61e1fb9 Time: Xms Asset Size Chunks Chunk Names -main.js 2.63 KiB 0 [emitted] main +main.js 2.42 KiB 0 [emitted] main [0] (webpack)/test/statsCases/color-enabled-custom/index.js 0 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/color-enabled/expected.txt b/test/statsCases/color-enabled/expected.txt index b712aa646..7e4563b85 100644 --- a/test/statsCases/color-enabled/expected.txt +++ b/test/statsCases/color-enabled/expected.txt @@ -1,5 +1,5 @@ Hash: 9b62d877d26dd61e1fb9 Time: Xms Asset Size Chunks Chunk Names -main.js 2.63 KiB 0 [emitted] main +main.js 2.42 KiB 0 [emitted] main [0] (webpack)/test/statsCases/color-enabled/index.js 0 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/commons-chunk-min-size-0/expected.txt b/test/statsCases/commons-chunk-min-size-0/expected.txt index 974b8672a..6d8d33955 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: 6e3e301d55085d22e738 Time: Xms Asset Size Chunks Chunk Names entry-1.js 81 bytes 0 [emitted] entry-1 -vendor-1.js 8.02 KiB 1 [emitted] vendor-1 +vendor-1.js 7.81 KiB 1 [emitted] vendor-1 [0] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/a.js 22 bytes {1} [built] [1] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/b.js 22 bytes {1} [built] [2] (webpack)/test/statsCases/commons-chunk-min-size-0/modules/c.js 22 bytes {1} [built] diff --git a/test/statsCases/commons-chunk-min-size-Infinity/expected.txt b/test/statsCases/commons-chunk-min-size-Infinity/expected.txt index 2b531e413..e2750cb3d 100644 --- a/test/statsCases/commons-chunk-min-size-Infinity/expected.txt +++ b/test/statsCases/commons-chunk-min-size-Infinity/expected.txt @@ -1,8 +1,8 @@ Hash: 6b34e4a15d90c981775e Time: Xms Asset Size Chunks Chunk Names - entry-1.js 3.24 KiB 0 [emitted] entry-1 -vendor-1.js 3 KiB 1 [emitted] vendor-1 + entry-1.js 3.03 KiB 0 [emitted] entry-1 +vendor-1.js 2.79 KiB 1 [emitted] vendor-1 [0] (webpack)/test/statsCases/commons-chunk-min-size-Infinity/modules/a.js 22 bytes {0} {1} [built] [1] (webpack)/test/statsCases/commons-chunk-min-size-Infinity/modules/b.js 22 bytes {0} {1} [built] [2] (webpack)/test/statsCases/commons-chunk-min-size-Infinity/modules/c.js 22 bytes {0} {1} [built] diff --git a/test/statsCases/commons-chunk-plugin-children/expected.txt b/test/statsCases/commons-chunk-plugin-children/expected.txt index d84485044..eafc4070c 100644 --- a/test/statsCases/commons-chunk-plugin-children/expected.txt +++ b/test/statsCases/commons-chunk-plugin-children/expected.txt @@ -6,7 +6,7 @@ Child normal: 3.bundle.js 837 bytes 3 [emitted] x2 4.bundle.js 530 bytes 4 [emitted] x1 5.bundle.js 1.13 KiB 5 [emitted] xx5 - bundle.js 7.05 KiB 6 [emitted] main + bundle.js 6.84 KiB 6 [emitted] main chunk {0} 0.bundle.js (x4) 56 bytes {6} [rendered] > x4 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 4:0-42 [0] (webpack)/test/statsCases/commons-chunk-plugin-children/a.js 0 bytes {0} {1} {2} {3} {4} [built] @@ -51,7 +51,7 @@ Child children: 3.bundle.js 692 bytes 3 [emitted] x2 4.bundle.js 472 bytes 4 [emitted] x1 5.bundle.js 1.13 KiB 5 [emitted] xx5 - bundle.js 7.17 KiB 6 [emitted] main + bundle.js 6.96 KiB 6 [emitted] main chunk {0} 0.bundle.js (x4) 56 bytes {6} [rendered] > x4 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 4:0-42 [1] (webpack)/test/statsCases/commons-chunk-plugin-children/c.js 0 bytes {0} {1} {5} [built] @@ -90,7 +90,7 @@ Child async: 4.bundle.js 692 bytes 4 [emitted] x2 5.bundle.js 472 bytes 5 [emitted] x1 6.bundle.js 1.13 KiB 6 [emitted] xx5 - bundle.js 7.25 KiB 7 [emitted] main + bundle.js 7.04 KiB 7 [emitted] main chunk {0} 0.bundle.js 0 bytes {7} [rendered] > async commons x1 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 1:0-42 > async commons x2 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 2:0-42 @@ -134,7 +134,7 @@ Child deep-children: 3.bundle.js 912 bytes 3 [emitted] x3 4.bundle.js 692 bytes 4 [emitted] x2 5.bundle.js 472 bytes 5 [emitted] x1 - bundle.js 7.22 KiB 6 [emitted] main + bundle.js 7.01 KiB 6 [emitted] main chunk {0} 0.bundle.js (xx5) 42 bytes {6} [rendered] > xx5 [9] (webpack)/test/statsCases/commons-chunk-plugin-children/x5.js 3:0-44 [3] (webpack)/test/statsCases/commons-chunk-plugin-children/d.js 0 bytes {0} {1} [built] @@ -171,7 +171,7 @@ Child deep-async: 4.bundle.js 692 bytes 4 [emitted] x2 5.bundle.js 472 bytes 5 [emitted] x1 6.bundle.js 1.01 KiB 6 [emitted] xx5 - bundle.js 7.25 KiB 7 [emitted] main + bundle.js 7.04 KiB 7 [emitted] main chunk {0} 0.bundle.js 0 bytes {7} [rendered] > async commons x1 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 1:0-42 > async commons x2 [4] (webpack)/test/statsCases/commons-chunk-plugin-children/index.js 2:0-42 diff --git a/test/statsCases/commons-plugin-issue-4980/expected.txt b/test/statsCases/commons-plugin-issue-4980/expected.txt index b1ff70f1c..ea8024f3d 100644 --- a/test/statsCases/commons-plugin-issue-4980/expected.txt +++ b/test/statsCases/commons-plugin-issue-4980/expected.txt @@ -5,7 +5,7 @@ Child Asset Size Chunks Chunk Names app.js 1.29 KiB 0 [emitted] app vendor.3210cd7580ff3ec8d7c1.js 619 bytes 1 [emitted] vendor - runtime.js 7.06 KiB 2 [emitted] runtime + runtime.js 6.85 KiB 2 [emitted] runtime [./constants.js] (webpack)/test/statsCases/commons-plugin-issue-4980/constants.js 87 bytes {1} [built] [./entry-1.js] (webpack)/test/statsCases/commons-plugin-issue-4980/entry-1.js 67 bytes {0} [built] [./submodule-a.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-a.js 59 bytes {0} [built] @@ -16,7 +16,7 @@ Child Asset Size Chunks Chunk Names app.js 1.34 KiB 0 [emitted] app vendor.3210cd7580ff3ec8d7c1.js 619 bytes 1 [emitted] vendor - runtime.js 7.06 KiB 2 [emitted] runtime + runtime.js 6.85 KiB 2 [emitted] runtime [./constants.js] (webpack)/test/statsCases/commons-plugin-issue-4980/constants.js 87 bytes {1} [built] [./entry-2.js] (webpack)/test/statsCases/commons-plugin-issue-4980/entry-2.js 67 bytes {0} [built] [./submodule-a.js] (webpack)/test/statsCases/commons-plugin-issue-4980/submodule-a.js 59 bytes {0} [built] diff --git a/test/statsCases/define-plugin/expected.txt b/test/statsCases/define-plugin/expected.txt index af30f6780..8def40c6b 100644 --- a/test/statsCases/define-plugin/expected.txt +++ b/test/statsCases/define-plugin/expected.txt @@ -3,11 +3,11 @@ Child Hash: 591f65b34ea2fed28590 Time: Xms Asset Size Chunks Chunk Names - main.js 2.67 KiB 0 [emitted] main + main.js 2.46 KiB 0 [emitted] main [0] (webpack)/test/statsCases/define-plugin/index.js 24 bytes {0} [built] Child Hash: a2524f672c23ebaef569 Time: Xms Asset Size Chunks Chunk Names - main.js 2.67 KiB 0 [emitted] main + main.js 2.46 KiB 0 [emitted] main [0] (webpack)/test/statsCases/define-plugin/index.js 24 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/exclude-with-loader/expected.txt b/test/statsCases/exclude-with-loader/expected.txt index b5d26673f..066fb00b6 100644 --- a/test/statsCases/exclude-with-loader/expected.txt +++ b/test/statsCases/exclude-with-loader/expected.txt @@ -1,7 +1,7 @@ Hash: e2851c8d4cdd7e82ca78 Time: Xms Asset Size Chunks Chunk Names -bundle.js 3.05 KiB 0 [emitted] main +bundle.js 2.84 KiB 0 [emitted] main + 1 hidden asset [0] (webpack)/test/statsCases/exclude-with-loader/index.js 77 bytes {0} [built] [1] (webpack)/test/statsCases/exclude-with-loader/a.txt 43 bytes {0} [built] diff --git a/test/statsCases/external/expected.txt b/test/statsCases/external/expected.txt index 812e4db84..fef541dfb 100644 --- a/test/statsCases/external/expected.txt +++ b/test/statsCases/external/expected.txt @@ -1,6 +1,6 @@ Hash: 7aea3de5f4fd504d5195 Time: Xms Asset Size Chunks Chunk Names -main.js 2.76 KiB 0 [emitted] main +main.js 2.55 KiB 0 [emitted] main [0] (webpack)/test/statsCases/external/index.js 17 bytes {0} [built] [1] external "test" 42 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/filter-warnings/expected.txt b/test/statsCases/filter-warnings/expected.txt index 44a2030e7..cafb1078a 100644 --- a/test/statsCases/filter-warnings/expected.txt +++ b/test/statsCases/filter-warnings/expected.txt @@ -3,10 +3,9 @@ Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -22,40 +21,39 @@ Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -71,10 +69,9 @@ Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -90,10 +87,9 @@ Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -109,10 +105,9 @@ Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -128,10 +123,9 @@ Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] @@ -147,10 +141,9 @@ Child Hash: cd4abefb3963c61372a0 Time: Xms Asset Size Chunks Chunk Names - bundle.js 2.08 KiB 0 [emitted] main + bundle.js 2.05 KiB 0 [emitted] main WARNING in bundle.js from UglifyJs - Dropping unused variable installedWasmModules [webpack/bootstrap cd4abefb3963c61372a0:5,0] Dropping side-effect-free statement [./index.js:6,0] Dropping unused function someUnUsedFunction1 [./index.js:8,0] Dropping unused function someUnUsedFunction2 [./index.js:9,0] diff --git a/test/statsCases/import-context-filter/expected.txt b/test/statsCases/import-context-filter/expected.txt index 6bb893be1..76d7cc3bd 100644 --- a/test/statsCases/import-context-filter/expected.txt +++ b/test/statsCases/import-context-filter/expected.txt @@ -4,7 +4,7 @@ Time: Xms 0.js 339 bytes 0 [emitted] 1.js 345 bytes 1 [emitted] 2.js 336 bytes 2 [emitted] -entry.js 7.67 KiB 3 [emitted] entry +entry.js 7.46 KiB 3 [emitted] entry [0] (webpack)/test/statsCases/import-context-filter/templates/bar.js 38 bytes {2} [optional] [built] [1] (webpack)/test/statsCases/import-context-filter/templates/baz.js 38 bytes {1} [optional] [built] [2] (webpack)/test/statsCases/import-context-filter/templates/foo.js 38 bytes {0} [optional] [built] diff --git a/test/statsCases/import-weak/expected.txt b/test/statsCases/import-weak/expected.txt index 4b5ab6212..4e15b3c6b 100644 --- a/test/statsCases/import-weak/expected.txt +++ b/test/statsCases/import-weak/expected.txt @@ -2,7 +2,7 @@ Hash: 9915cc41cf8ad107ab1e Time: Xms Asset Size Chunks Chunk Names 0.js 149 bytes 0 [emitted] -entry.js 7.09 KiB 1 [emitted] entry +entry.js 6.88 KiB 1 [emitted] entry [0] (webpack)/test/statsCases/import-weak/modules/b.js 22 bytes {0} [built] [1] (webpack)/test/statsCases/import-weak/entry.js 120 bytes {1} [built] [2] (webpack)/test/statsCases/import-weak/modules/a.js 37 bytes [built] \ No newline at end of file diff --git a/test/statsCases/limit-chunk-count-plugin/expected.txt b/test/statsCases/limit-chunk-count-plugin/expected.txt index e7a26d934..95b6a3467 100644 --- a/test/statsCases/limit-chunk-count-plugin/expected.txt +++ b/test/statsCases/limit-chunk-count-plugin/expected.txt @@ -3,7 +3,7 @@ Child Hash: 8a563b80ea8746a38924 Time: Xms Asset Size Chunks Chunk Names - bundle.js 3.53 KiB 0 [emitted] main + bundle.js 3.32 KiB 0 [emitted] main chunk {0} bundle.js (main) 191 bytes [entry] [rendered] [0] (webpack)/test/statsCases/limit-chunk-count-plugin/index.js 73 bytes {0} [built] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] @@ -16,7 +16,7 @@ Child Time: Xms Asset Size Chunks Chunk Names 0.bundle.js 651 bytes 0 [emitted] - bundle.js 7 KiB 1 [emitted] main + bundle.js 6.79 KiB 1 [emitted] main chunk {0} 0.bundle.js 118 bytes {1} [rendered] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] [2] (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 504 bytes 0 [emitted] 1.bundle.js 232 bytes 1 [emitted] - bundle.js 7 KiB 2 [emitted] main + bundle.js 6.79 KiB 2 [emitted] main chunk {0} 0.bundle.js 74 bytes {2} [rendered] [1] (webpack)/test/statsCases/limit-chunk-count-plugin/a.js 22 bytes {0} [built] [3] (webpack)/test/statsCases/limit-chunk-count-plugin/c.js 30 bytes {0} [built] @@ -48,7 +48,7 @@ Child 0.bundle.js 232 bytes 0 [emitted] 1.bundle.js 254 bytes 1 [emitted] 2.bundle.js 333 bytes 2 [emitted] - bundle.js 6.99 KiB 3 [emitted] main + bundle.js 6.78 KiB 3 [emitted] main chunk {0} 0.bundle.js 44 bytes {2} {3} [rendered] [2] (webpack)/test/statsCases/limit-chunk-count-plugin/b.js 22 bytes {0} [built] [5] (webpack)/test/statsCases/limit-chunk-count-plugin/e.js 22 bytes {0} [built] diff --git a/test/statsCases/max-modules-default/expected.txt b/test/statsCases/max-modules-default/expected.txt index 3d132200d..350bdf556 100644 --- a/test/statsCases/max-modules-default/expected.txt +++ b/test/statsCases/max-modules-default/expected.txt @@ -1,7 +1,7 @@ Hash: ce34adc7e3ac058ea5f0 Time: Xms Asset Size Chunks Chunk Names -main.js 5.86 KiB 0 [emitted] main +main.js 5.65 KiB 0 [emitted] main [0] (webpack)/test/statsCases/max-modules-default/a.js?1 33 bytes {0} [built] [1] (webpack)/test/statsCases/max-modules-default/a.js?2 33 bytes {0} [built] [2] (webpack)/test/statsCases/max-modules-default/a.js?3 33 bytes {0} [built] diff --git a/test/statsCases/max-modules/expected.txt b/test/statsCases/max-modules/expected.txt index 8c36008d4..c21755796 100644 --- a/test/statsCases/max-modules/expected.txt +++ b/test/statsCases/max-modules/expected.txt @@ -1,7 +1,7 @@ Hash: ce34adc7e3ac058ea5f0 Time: Xms Asset Size Chunks Chunk Names -main.js 5.86 KiB 0 [emitted] main +main.js 5.65 KiB 0 [emitted] main [0] (webpack)/test/statsCases/max-modules/a.js?1 33 bytes {0} [built] [1] (webpack)/test/statsCases/max-modules/a.js?2 33 bytes {0} [built] [2] (webpack)/test/statsCases/max-modules/a.js?3 33 bytes {0} [built] diff --git a/test/statsCases/module-deduplication-named/expected.txt b/test/statsCases/module-deduplication-named/expected.txt index e43142b78..e17ed3cbf 100644 --- a/test/statsCases/module-deduplication-named/expected.txt +++ b/test/statsCases/module-deduplication-named/expected.txt @@ -2,9 +2,9 @@ Asset Size Chunks Chunk Names 0.js 839 bytes 0 [emitted] async3 1.js 839 bytes 1 [emitted] async2 2.js 839 bytes 2 [emitted] async1 -e3.js 8.02 KiB 3 [emitted] e3 -e2.js 8 KiB 4 [emitted] e2 -e1.js 7.98 KiB 5 [emitted] e1 +e3.js 7.81 KiB 3 [emitted] e3 +e2.js 7.79 KiB 4 [emitted] e2 +e1.js 7.77 KiB 5 [emitted] e1 chunk {0} 0.js (async3) 89 bytes {1} {3} [rendered] [4] (webpack)/test/statsCases/module-deduplication-named/h.js 9 bytes {0} {3} [built] [7] (webpack)/test/statsCases/module-deduplication-named/async3.js 80 bytes {0} [built] diff --git a/test/statsCases/module-deduplication/expected.txt b/test/statsCases/module-deduplication/expected.txt index be264f77e..d9811c542 100644 --- a/test/statsCases/module-deduplication/expected.txt +++ b/test/statsCases/module-deduplication/expected.txt @@ -5,9 +5,9 @@ Asset Size Chunks Chunk Names 3.js 692 bytes 3 [emitted] 4.js 692 bytes 4 [emitted] 5.js 692 bytes 5 [emitted] -e3.js 8.21 KiB 6 [emitted] e3 -e2.js 8.19 KiB 7 [emitted] e2 -e1.js 8.17 KiB 8 [emitted] e1 +e3.js 8 KiB 6 [emitted] e3 +e2.js 7.98 KiB 7 [emitted] e2 +e1.js 7.96 KiB 8 [emitted] e1 chunk {0} 0.js 37 bytes {7} {8} [rendered] [6] (webpack)/test/statsCases/module-deduplication/async3.js 28 bytes {0} {3} [built] [7] (webpack)/test/statsCases/module-deduplication/h.js 9 bytes {0} {6} [built] diff --git a/test/statsCases/module-trace-disabled-in-error/expected.txt b/test/statsCases/module-trace-disabled-in-error/expected.txt index 54ae0132c..eabea074b 100644 --- a/test/statsCases/module-trace-disabled-in-error/expected.txt +++ b/test/statsCases/module-trace-disabled-in-error/expected.txt @@ -1,6 +1,6 @@ Time: Xms - Asset Size Chunks Chunk Names -main.js 2.8 KiB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 2.59 KiB 0 [emitted] main [0] (webpack)/test/statsCases/module-trace-disabled-in-error/index.js 25 bytes {0} [built] ERROR in (webpack)/test/statsCases/module-trace-disabled-in-error/index.js diff --git a/test/statsCases/module-trace-enabled-in-error/expected.txt b/test/statsCases/module-trace-enabled-in-error/expected.txt index 43eccb021..02a8bf64b 100644 --- a/test/statsCases/module-trace-enabled-in-error/expected.txt +++ b/test/statsCases/module-trace-enabled-in-error/expected.txt @@ -1,6 +1,6 @@ Time: Xms - Asset Size Chunks Chunk Names -main.js 2.8 KiB 0 [emitted] main + Asset Size Chunks Chunk Names +main.js 2.59 KiB 0 [emitted] main [0] (webpack)/test/statsCases/module-trace-enabled-in-error/index.js 25 bytes {0} [built] ERROR in (webpack)/test/statsCases/module-trace-enabled-in-error/index.js diff --git a/test/statsCases/named-chunks-plugin-async/expected.txt b/test/statsCases/named-chunks-plugin-async/expected.txt index 7d31a3e18..a5f3ee4c4 100644 --- a/test/statsCases/named-chunks-plugin-async/expected.txt +++ b/test/statsCases/named-chunks-plugin-async/expected.txt @@ -3,7 +3,7 @@ Time: Xms Asset Size Chunks Chunk Names chunk-containing-__a_js.js 316 bytes chunk-containing-__a_js [emitted] chunk-containing-__b_js.js 173 bytes chunk-containing-__b_js [emitted] - entry.js 6.88 KiB entry [emitted] entry + entry.js 6.67 KiB entry [emitted] entry [0] (webpack)/test/statsCases/named-chunks-plugin-async/modules/b.js 22 bytes {chunk-containing-__b_js} [built] [1] (webpack)/test/statsCases/named-chunks-plugin-async/entry.js 47 bytes {entry} [built] [2] (webpack)/test/statsCases/named-chunks-plugin-async/modules/a.js 37 bytes {chunk-containing-__a_js} [built] \ No newline at end of file diff --git a/test/statsCases/named-chunks-plugin/expected.txt b/test/statsCases/named-chunks-plugin/expected.txt index bd35b65fe..fe5adc275 100644 --- a/test/statsCases/named-chunks-plugin/expected.txt +++ b/test/statsCases/named-chunks-plugin/expected.txt @@ -1,11 +1,11 @@ -Hash: 3e5729d50a2db92f6b0e +Hash: 3e81ada51bc03831d832 Time: Xms Asset Size Chunks Chunk Names - entry.js 615 bytes entry [emitted] entry -manifest.js 7.06 KiB manifest [emitted] manifest + entry.js 425 bytes entry [emitted] entry +manifest.js 6.85 KiB manifest [emitted] manifest vendor.js 469 bytes vendor [emitted] vendor [0] multi ./modules/a ./modules/b 40 bytes {vendor} [built] [./entry.js] (webpack)/test/statsCases/named-chunks-plugin/entry.js 72 bytes {entry} [built] -[./modules/a.js] (webpack)/test/statsCases/named-chunks-plugin/modules/a.js 22 bytes {entry} {vendor} [built] -[./modules/b.js] (webpack)/test/statsCases/named-chunks-plugin/modules/b.js 22 bytes {entry} {vendor} [built] +[./modules/a.js] (webpack)/test/statsCases/named-chunks-plugin/modules/a.js 22 bytes {vendor} [built] +[./modules/b.js] (webpack)/test/statsCases/named-chunks-plugin/modules/b.js 22 bytes {vendor} [built] [./modules/c.js] (webpack)/test/statsCases/named-chunks-plugin/modules/c.js 22 bytes {entry} [built] \ No newline at end of file diff --git a/test/statsCases/optimize-chunks/expected.txt b/test/statsCases/optimize-chunks/expected.txt index 0314419a5..655e3c1a6 100644 --- a/test/statsCases/optimize-chunks/expected.txt +++ b/test/statsCases/optimize-chunks/expected.txt @@ -8,7 +8,7 @@ Time: Xms 4.js 212 bytes 4, 6 [emitted] chunk 5.js 356 bytes 5, 3 [emitted] cir2 from cir1 6.js 130 bytes 6 [emitted] ac in ab -main.js 7.65 KiB 7 [emitted] main +main.js 7.44 KiB 7 [emitted] main chunk {0} 0.js (cir1) 81 bytes {3} {7} [rendered] > duplicate cir1 from cir2 [6] (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/parse-error/expected.txt b/test/statsCases/parse-error/expected.txt index c92ebcaa6..937ef2b30 100644 --- a/test/statsCases/parse-error/expected.txt +++ b/test/statsCases/parse-error/expected.txt @@ -1,5 +1,5 @@ Asset Size Chunks Chunk Names -main.js 3.36 KiB 0 [emitted] main +main.js 3.15 KiB 0 [emitted] main [0] (webpack)/test/statsCases/parse-error/index.js 15 bytes {0} [built] [1] (webpack)/test/statsCases/parse-error/a.js 15 bytes {0} [built] [2] (webpack)/test/statsCases/parse-error/b.js 169 bytes {0} [built] [failed] [1 error] diff --git a/test/statsCases/performance-no-async-chunks-shown/expected.txt b/test/statsCases/performance-no-async-chunks-shown/expected.txt index a093c9697..ecfae72c3 100644 --- a/test/statsCases/performance-no-async-chunks-shown/expected.txt +++ b/test/statsCases/performance-no-async-chunks-shown/expected.txt @@ -1,6 +1,6 @@ Time: Xms Asset Size Chunks Chunk Names - sec.js 2.96 KiB 0 [emitted] sec + sec.js 2.75 KiB 0 [emitted] sec main.js 296 KiB 1 [emitted] [big] main Entrypoint main [big] = main.js Entrypoint sec = sec.js diff --git a/test/statsCases/preset-detailed/expected.txt b/test/statsCases/preset-detailed/expected.txt index ad4e27703..5f0f2be80 100644 --- a/test/statsCases/preset-detailed/expected.txt +++ b/test/statsCases/preset-detailed/expected.txt @@ -4,7 +4,7 @@ Time: Xms 0.js 288 bytes 0 [emitted] 1.js 152 bytes 1 [emitted] 2.js 232 bytes 2 [emitted] -main.js 6.97 KiB 3 [emitted] main +main.js 6.76 KiB 3 [emitted] main Entrypoint main = main.js chunk {0} 0.js 54 bytes {3} [rendered] > [0] (webpack)/test/statsCases/preset-detailed/index.js 3:0-16 diff --git a/test/statsCases/preset-normal/expected.txt b/test/statsCases/preset-normal/expected.txt index 4d7f344b2..09f25225a 100644 --- a/test/statsCases/preset-normal/expected.txt +++ b/test/statsCases/preset-normal/expected.txt @@ -4,7 +4,7 @@ Time: Xms 0.js 288 bytes 0 [emitted] 1.js 152 bytes 1 [emitted] 2.js 232 bytes 2 [emitted] -main.js 6.97 KiB 3 [emitted] main +main.js 6.76 KiB 3 [emitted] main [0] (webpack)/test/statsCases/preset-normal/index.js 51 bytes {3} [built] [1] (webpack)/test/statsCases/preset-normal/a.js 22 bytes {3} [built] [2] (webpack)/test/statsCases/preset-normal/b.js 22 bytes {1} [built] diff --git a/test/statsCases/preset-verbose/expected.txt b/test/statsCases/preset-verbose/expected.txt index 65fee0d01..1c8965570 100644 --- a/test/statsCases/preset-verbose/expected.txt +++ b/test/statsCases/preset-verbose/expected.txt @@ -4,7 +4,7 @@ Time: Xms 0.js 288 bytes 0 [emitted] 1.js 152 bytes 1 [emitted] 2.js 232 bytes 2 [emitted] -main.js 6.97 KiB 3 [emitted] main +main.js 6.76 KiB 3 [emitted] main Entrypoint main = main.js chunk {0} 0.js 54 bytes {3} [rendered] > [0] (webpack)/test/statsCases/preset-verbose/index.js 3:0-16 diff --git a/test/statsCases/resolve-plugin-context/expected.txt b/test/statsCases/resolve-plugin-context/expected.txt index 6f4133f35..c588ac666 100644 --- a/test/statsCases/resolve-plugin-context/expected.txt +++ b/test/statsCases/resolve-plugin-context/expected.txt @@ -1,7 +1,7 @@ Hash: 2f10a36f9685efee695a Time: Xms Asset Size Chunks Chunk Names -bundle.js 3.02 KiB 0 [emitted] main +bundle.js 2.81 KiB 0 [emitted] main [0] (webpack)/test/statsCases/resolve-plugin-context/node_modules/xyz/index.js 0 bytes {0} [built] [1] (webpack)/test/statsCases/resolve-plugin-context/index.js 48 bytes {0} [built] [2] (webpack)/test/statsCases/resolve-plugin-context/node_modules/abc/index.js 16 bytes {0} [built] diff --git a/test/statsCases/reverse-sort-modules/expected.txt b/test/statsCases/reverse-sort-modules/expected.txt index 8b5e52a99..5f407e8d9 100644 --- a/test/statsCases/reverse-sort-modules/expected.txt +++ b/test/statsCases/reverse-sort-modules/expected.txt @@ -1,7 +1,7 @@ Hash: ce34adc7e3ac058ea5f0 Time: Xms Asset Size Chunks Chunk Names -main.js 5.86 KiB 0 [emitted] main +main.js 5.65 KiB 0 [emitted] main [29] (webpack)/test/statsCases/reverse-sort-modules/c.js?10 33 bytes {0} [built] [27] (webpack)/test/statsCases/reverse-sort-modules/c.js?9 33 bytes {0} [built] [25] (webpack)/test/statsCases/reverse-sort-modules/c.js?8 33 bytes {0} [built] diff --git a/test/statsCases/separate-css-bundle/expected.txt b/test/statsCases/separate-css-bundle/expected.txt index 841bdfca1..59cd0a2a1 100644 --- a/test/statsCases/separate-css-bundle/expected.txt +++ b/test/statsCases/separate-css-bundle/expected.txt @@ -3,7 +3,7 @@ Child Hash: 83e56382e56968147d36 Time: Xms Asset Size Chunks Chunk Names - 240942974444681d3abd.js 2.76 KiB 0 [emitted] main + 240942974444681d3abd.js 2.55 KiB 0 [emitted] main c815cf440254d4f3bba4e7041db00a28.css 26 bytes 0 [emitted] main [0] (webpack)/test/statsCases/separate-css-bundle/a/index.js 23 bytes {0} [built] [1] (webpack)/test/statsCases/separate-css-bundle/a/file.css 41 bytes {0} [built] @@ -18,7 +18,7 @@ Child Hash: dee705eb8be60b2037db Time: Xms Asset Size Chunks Chunk Names - 240942974444681d3abd.js 2.76 KiB 0 [emitted] main + 240942974444681d3abd.js 2.55 KiB 0 [emitted] main a3f385680aef7a9bb2a517699532cc34.css 28 bytes 0 [emitted] main [0] (webpack)/test/statsCases/separate-css-bundle/b/index.js 23 bytes {0} [built] [1] (webpack)/test/statsCases/separate-css-bundle/b/file.css 41 bytes {0} [built] diff --git a/test/statsCases/simple-more-info/expected.txt b/test/statsCases/simple-more-info/expected.txt index 2310cc0ac..895a2fc0c 100644 --- a/test/statsCases/simple-more-info/expected.txt +++ b/test/statsCases/simple-more-info/expected.txt @@ -1,7 +1,7 @@ Hash: 9bd1f5491993467e8b27 Time: Xms Asset Size Chunks Chunk Names -bundle.js 2.63 KiB 0 [emitted] main +bundle.js 2.42 KiB 0 [emitted] main [0] (webpack)/test/statsCases/simple-more-info/index.js 0 bytes {0} [built] single entry ./index main factory:Xms building:Xms = Xms \ No newline at end of file diff --git a/test/statsCases/simple/expected.txt b/test/statsCases/simple/expected.txt index ade523f37..c67c0c134 100644 --- a/test/statsCases/simple/expected.txt +++ b/test/statsCases/simple/expected.txt @@ -1,5 +1,5 @@ Hash: 9bd1f5491993467e8b27 Time: Xms Asset Size Chunks Chunk Names -bundle.js 2.63 KiB 0 [emitted] main +bundle.js 2.42 KiB 0 [emitted] main [0] (webpack)/test/statsCases/simple/index.js 0 bytes {0} [built] \ No newline at end of file diff --git a/test/statsCases/tree-shaking/expected.txt b/test/statsCases/tree-shaking/expected.txt index 9a9051c30..bc855bffb 100644 --- a/test/statsCases/tree-shaking/expected.txt +++ b/test/statsCases/tree-shaking/expected.txt @@ -1,7 +1,7 @@ Hash: 2500e9cab76400ff4f51 Time: Xms Asset Size Chunks Chunk Names -bundle.js 7.08 KiB 0 [emitted] main +bundle.js 6.87 KiB 0 [emitted] main [0] (webpack)/test/statsCases/tree-shaking/a.js 13 bytes {0} [built] [exports: a] [only some exports used: a] diff --git a/test/statsCases/warnings-uglifyjs/expected.txt b/test/statsCases/warnings-uglifyjs/expected.txt index 7ca625716..cfff60e80 100644 --- a/test/statsCases/warnings-uglifyjs/expected.txt +++ b/test/statsCases/warnings-uglifyjs/expected.txt @@ -1,7 +1,7 @@ Hash: 7df1195d08327e14c776 Time: Xms Asset Size Chunks Chunk Names -bundle.js 2.08 KiB 0 [emitted] main +bundle.js 2.05 KiB 0 [emitted] main [0] (webpack)/test/statsCases/warnings-uglifyjs/index.js 299 bytes {0} [built] [1] (webpack)/test/statsCases/warnings-uglifyjs/a.js 249 bytes {0} [built] [2] (webpack)/buildin/module.js 495 bytes {0} [built] From 95407047c4808e6734d80ac38da30574fc9228fc Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Mon, 20 Nov 2017 15:41:30 +0100 Subject: [PATCH 66/85] fix DllPlugin flagging --- lib/DllPlugin.js | 2 +- lib/FlagInitialModulesAsUsedPlugin.js | 5 +++++ lib/Module.js | 6 +++--- lib/ModuleReason.js | 3 ++- lib/optimize/ModuleConcatenationPlugin.js | 15 ++++++++++++--- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/DllPlugin.js b/lib/DllPlugin.js index 97a6ad31e..94893f0ff 100644 --- a/lib/DllPlugin.js +++ b/lib/DllPlugin.js @@ -31,7 +31,7 @@ class DllPlugin { return true; }); compiler.apply(new LibManifestPlugin(this.options)); - compiler.apply(new FlagInitialModulesAsUsedPlugin()); + compiler.apply(new FlagInitialModulesAsUsedPlugin("DllPlugin")); } } diff --git a/lib/FlagInitialModulesAsUsedPlugin.js b/lib/FlagInitialModulesAsUsedPlugin.js index 0bb569d3f..0f5725673 100644 --- a/lib/FlagInitialModulesAsUsedPlugin.js +++ b/lib/FlagInitialModulesAsUsedPlugin.js @@ -5,6 +5,10 @@ "use strict"; class FlagInitialModulesAsUsedPlugin { + constructor(explaination) { + this.explaination = explaination; + } + apply(compiler) { compiler.plugin("compilation", (compilation) => { compilation.plugin("after-optimize-chunks", (chunks) => { @@ -15,6 +19,7 @@ class FlagInitialModulesAsUsedPlugin { chunk.forEachModule((module) => { module.used = true; module.usedExports = true; + module.addReason(null, null, this.explaination); }); }); }); diff --git a/lib/Module.js b/lib/Module.js index 19f5a8206..4a468ca48 100644 --- a/lib/Module.js +++ b/lib/Module.js @@ -143,7 +143,7 @@ class Module extends DependenciesBlock { } get optional() { - return this.reasons.length > 0 && this.reasons.every(r => r.dependency.optional); + return this.reasons.length > 0 && this.reasons.every(r => r.dependency && r.dependency.optional); } forEachChunk(fn) { @@ -180,8 +180,8 @@ class Module extends DependenciesBlock { } } - addReason(module, dependency) { - this.reasons.push(new ModuleReason(module, dependency)); + addReason(module, dependency, explaination) { + this.reasons.push(new ModuleReason(module, dependency, explaination)); } removeReason(module, dependency) { diff --git a/lib/ModuleReason.js b/lib/ModuleReason.js index cab54df0a..dfdf28228 100644 --- a/lib/ModuleReason.js +++ b/lib/ModuleReason.js @@ -7,9 +7,10 @@ const util = require("util"); class ModuleReason { - constructor(module, dependency) { + constructor(module, dependency, explaination) { this.module = module; this.dependency = dependency; + this.explaination = explaination; this._chunks = null; } diff --git a/lib/optimize/ModuleConcatenationPlugin.js b/lib/optimize/ModuleConcatenationPlugin.js index 6543458df..78732eddd 100644 --- a/lib/optimize/ModuleConcatenationPlugin.js +++ b/lib/optimize/ModuleConcatenationPlugin.js @@ -84,13 +84,22 @@ class ModuleConcatenationPlugin { } // Module must only be used by Harmony Imports - const nonHarmonyReasons = module.reasons.filter(reason => !(reason.dependency instanceof HarmonyImportDependency)); + const nonHarmonyReasons = module.reasons.filter(reason => !reason.dependency || !(reason.dependency instanceof HarmonyImportDependency)); if(nonHarmonyReasons.length > 0) { - const importingModules = new Set(nonHarmonyReasons.map(r => r.module)); + const importingModules = new Set(nonHarmonyReasons.map(r => r.module).filter(Boolean)); + const importingExplainations = new Set(nonHarmonyReasons.map(r => r.explaination).filter(Boolean)); const importingModuleTypes = new Map(Array.from(importingModules).map(m => [m, new Set(nonHarmonyReasons.filter(r => r.module === m).map(r => r.dependency.type).sort())])); setBailoutReason(module, (requestShortener) => { const names = Array.from(importingModules).map(m => `${m.readableIdentifier(requestShortener)} (referenced with ${Array.from(importingModuleTypes.get(m)).join(", ")})`).sort(); - return `Module is referenced from these modules with unsupported syntax: ${names.join(", ")}`; + const explainations = Array.from(importingExplainations).sort(); + if(names.length > 0 && explainations.length === 0) + return `Module is referenced from these modules with unsupported syntax: ${names.join(", ")}`; + else if(names.length === 0 && explainations.length > 0) + return `Module is referenced by: ${explainations.join(", ")}`; + else if(names.length > 0 && explainations.length > 0) + return `Module is referenced from these modules with unsupported syntax: ${names.join(", ")} and by: ${explainations.join(", ")}`; + else + return "Module is referenced in a unsupported way"; }); continue; } From 8149c5e1f15dfeeb07764f4130c6bd76d6ff74de Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 21 Nov 2017 13:23:12 +0100 Subject: [PATCH 67/85] fix linting issues --- examples/code-splitted-css-bundle/webpack.config.js | 3 +-- examples/css-bundle/webpack.config.js | 3 +-- .../webpack.config.js | 8 ++++---- lib/webpack.js | 1 - 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/examples/code-splitted-css-bundle/webpack.config.js b/examples/code-splitted-css-bundle/webpack.config.js index 446541ce3..d443e0a2f 100644 --- a/examples/code-splitted-css-bundle/webpack.config.js +++ b/examples/code-splitted-css-bundle/webpack.config.js @@ -1,5 +1,4 @@ -const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin; - +const LoaderOptionsPlugin = require("../../lib/LoaderOptionsPlugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { module: { diff --git a/examples/css-bundle/webpack.config.js b/examples/css-bundle/webpack.config.js index 3181cf355..ed5279ebd 100644 --- a/examples/css-bundle/webpack.config.js +++ b/examples/css-bundle/webpack.config.js @@ -1,5 +1,4 @@ -const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin; - +const LoaderOptionsPlugin = require("../../lib/LoaderOptionsPlugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { module: { diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js b/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js index 66b72a743..270426855 100644 --- a/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js +++ b/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js @@ -1,7 +1,7 @@ -var path = require("path"); -const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin; -var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); -var ExtractTextPlugin = require("extract-text-webpack-plugin"); +const path = require("path"); +const LoaderOptionsPlugin = require("../../lib/LoaderOptionsPlugin"); +const CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); +const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { entry: { A: "./a", diff --git a/lib/webpack.js b/lib/webpack.js index c1764b325..33670925b 100644 --- a/lib/webpack.js +++ b/lib/webpack.js @@ -94,7 +94,6 @@ exportPlugins(exports, { "SetVarMainTemplatePlugin": () => require("./SetVarMainTemplatePlugin"), "UmdMainTemplatePlugin": () => require("./UmdMainTemplatePlugin"), "NoEmitOnErrorsPlugin": () => require("./NoEmitOnErrorsPlugin"), - "NewWatchingPlugin": () => require("./NewWatchingPlugin"), "EnvironmentPlugin": () => require("./EnvironmentPlugin"), "DllPlugin": () => require("./DllPlugin"), "DllReferencePlugin": () => require("./DllReferencePlugin"), From 485c1673b0dccb1ed98bdd0301a438a068c5c378 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Tue, 21 Nov 2017 18:52:35 +0100 Subject: [PATCH 68/85] fix typo: explaination -> explanation --- lib/FlagInitialModulesAsUsedPlugin.js | 6 +++--- lib/Module.js | 4 ++-- lib/ModuleReason.js | 4 ++-- lib/optimize/ModuleConcatenationPlugin.js | 14 +++++++------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/FlagInitialModulesAsUsedPlugin.js b/lib/FlagInitialModulesAsUsedPlugin.js index 0f5725673..02509db0e 100644 --- a/lib/FlagInitialModulesAsUsedPlugin.js +++ b/lib/FlagInitialModulesAsUsedPlugin.js @@ -5,8 +5,8 @@ "use strict"; class FlagInitialModulesAsUsedPlugin { - constructor(explaination) { - this.explaination = explaination; + constructor(explanation) { + this.explanation = explanation; } apply(compiler) { @@ -19,7 +19,7 @@ class FlagInitialModulesAsUsedPlugin { chunk.forEachModule((module) => { module.used = true; module.usedExports = true; - module.addReason(null, null, this.explaination); + module.addReason(null, null, this.explanation); }); }); }); diff --git a/lib/Module.js b/lib/Module.js index 4a468ca48..b130477ce 100644 --- a/lib/Module.js +++ b/lib/Module.js @@ -180,8 +180,8 @@ class Module extends DependenciesBlock { } } - addReason(module, dependency, explaination) { - this.reasons.push(new ModuleReason(module, dependency, explaination)); + addReason(module, dependency, explanation) { + this.reasons.push(new ModuleReason(module, dependency, explanation)); } removeReason(module, dependency) { diff --git a/lib/ModuleReason.js b/lib/ModuleReason.js index dfdf28228..65984c1f7 100644 --- a/lib/ModuleReason.js +++ b/lib/ModuleReason.js @@ -7,10 +7,10 @@ const util = require("util"); class ModuleReason { - constructor(module, dependency, explaination) { + constructor(module, dependency, explanation) { this.module = module; this.dependency = dependency; - this.explaination = explaination; + this.explanation = explanation; this._chunks = null; } diff --git a/lib/optimize/ModuleConcatenationPlugin.js b/lib/optimize/ModuleConcatenationPlugin.js index 78732eddd..4469b57fd 100644 --- a/lib/optimize/ModuleConcatenationPlugin.js +++ b/lib/optimize/ModuleConcatenationPlugin.js @@ -87,17 +87,17 @@ class ModuleConcatenationPlugin { const nonHarmonyReasons = module.reasons.filter(reason => !reason.dependency || !(reason.dependency instanceof HarmonyImportDependency)); if(nonHarmonyReasons.length > 0) { const importingModules = new Set(nonHarmonyReasons.map(r => r.module).filter(Boolean)); - const importingExplainations = new Set(nonHarmonyReasons.map(r => r.explaination).filter(Boolean)); + const importingExplanations = new Set(nonHarmonyReasons.map(r => r.explanation).filter(Boolean)); const importingModuleTypes = new Map(Array.from(importingModules).map(m => [m, new Set(nonHarmonyReasons.filter(r => r.module === m).map(r => r.dependency.type).sort())])); setBailoutReason(module, (requestShortener) => { const names = Array.from(importingModules).map(m => `${m.readableIdentifier(requestShortener)} (referenced with ${Array.from(importingModuleTypes.get(m)).join(", ")})`).sort(); - const explainations = Array.from(importingExplainations).sort(); - if(names.length > 0 && explainations.length === 0) + const explanations = Array.from(importingExplanations).sort(); + if(names.length > 0 && explanations.length === 0) return `Module is referenced from these modules with unsupported syntax: ${names.join(", ")}`; - else if(names.length === 0 && explainations.length > 0) - return `Module is referenced by: ${explainations.join(", ")}`; - else if(names.length > 0 && explainations.length > 0) - return `Module is referenced from these modules with unsupported syntax: ${names.join(", ")} and by: ${explainations.join(", ")}`; + else if(names.length === 0 && explanations.length > 0) + return `Module is referenced by: ${explanations.join(", ")}`; + else if(names.length > 0 && explanations.length > 0) + return `Module is referenced from these modules with unsupported syntax: ${names.join(", ")} and by: ${explanations.join(", ")}`; else return "Module is referenced in a unsupported way"; }); From b622c0103eda457083f4f6b934434779f116ba23 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 22 Nov 2017 06:34:12 +0100 Subject: [PATCH 69/85] add test case for module concatenation with dll plugin --- .../scope-hoisting/create-dll-plugin/index.js | 3 +++ .../scope-hoisting/create-dll-plugin/module.js | 1 + .../scope-hoisting/create-dll-plugin/test.config.js | 1 + .../create-dll-plugin/webpack.config.js | 11 +++++++++++ 4 files changed, 16 insertions(+) create mode 100644 test/configCases/scope-hoisting/create-dll-plugin/index.js create mode 100644 test/configCases/scope-hoisting/create-dll-plugin/module.js create mode 100644 test/configCases/scope-hoisting/create-dll-plugin/test.config.js create mode 100644 test/configCases/scope-hoisting/create-dll-plugin/webpack.config.js diff --git a/test/configCases/scope-hoisting/create-dll-plugin/index.js b/test/configCases/scope-hoisting/create-dll-plugin/index.js new file mode 100644 index 000000000..a5885c08d --- /dev/null +++ b/test/configCases/scope-hoisting/create-dll-plugin/index.js @@ -0,0 +1,3 @@ +import "./module"; + +export default 1; diff --git a/test/configCases/scope-hoisting/create-dll-plugin/module.js b/test/configCases/scope-hoisting/create-dll-plugin/module.js new file mode 100644 index 000000000..842e368a0 --- /dev/null +++ b/test/configCases/scope-hoisting/create-dll-plugin/module.js @@ -0,0 +1 @@ +export default 2; diff --git a/test/configCases/scope-hoisting/create-dll-plugin/test.config.js b/test/configCases/scope-hoisting/create-dll-plugin/test.config.js new file mode 100644 index 000000000..08ea6c319 --- /dev/null +++ b/test/configCases/scope-hoisting/create-dll-plugin/test.config.js @@ -0,0 +1 @@ +exports.noTests = true; diff --git a/test/configCases/scope-hoisting/create-dll-plugin/webpack.config.js b/test/configCases/scope-hoisting/create-dll-plugin/webpack.config.js new file mode 100644 index 000000000..f6a7ae1a0 --- /dev/null +++ b/test/configCases/scope-hoisting/create-dll-plugin/webpack.config.js @@ -0,0 +1,11 @@ +const path = require("path"); +var webpack = require("../../../../"); +module.exports = { + entry: ["./index.js"], + plugins: [ + new webpack.DllPlugin({ + path: path.resolve(__dirname, "../../../js/config/scope-hoisting/create-dll-plugin/manifest.json") + }), + new webpack.optimize.ModuleConcatenationPlugin() + ] +}; From 5a8e7673cbf4aa870a0d0e514978e0abe72fc745 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 22 Nov 2017 08:05:07 +0100 Subject: [PATCH 70/85] fix weak status of harmony accept dependency add test case for accepting default import --- lib/Compilation.js | 2 +- .../HarmonyAcceptImportDependency.js | 1 + lib/dependencies/HarmonyImportDependency.js | 3 +- .../harmony/auto-import-default/file.js | 3 + .../harmony/auto-import-default/index.js | 15 + .../harmony/auto-import-default/out/bundle.js | 784 ++++++++++++++++++ 6 files changed, 806 insertions(+), 2 deletions(-) create mode 100644 test/hotCases/harmony/auto-import-default/file.js create mode 100644 test/hotCases/harmony/auto-import-default/index.js create mode 100644 test/hotCases/harmony/auto-import-default/out/bundle.js diff --git a/lib/Compilation.js b/lib/Compilation.js index 2337a6a9b..f083138c2 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -974,7 +974,7 @@ class Compilation extends Tapable { return; } // We skip weak Dependencies - if(d.weak) { + if(ref.weak) { return; } // We connect Module and Chunk when not already done diff --git a/lib/dependencies/HarmonyAcceptImportDependency.js b/lib/dependencies/HarmonyAcceptImportDependency.js index fec796102..eefaf6596 100644 --- a/lib/dependencies/HarmonyAcceptImportDependency.js +++ b/lib/dependencies/HarmonyAcceptImportDependency.js @@ -8,6 +8,7 @@ const HarmonyImportDependency = require("./HarmonyImportDependency"); class HarmonyAcceptImportDependency extends HarmonyImportDependency { constructor(request, originModule, parserScope) { super(request, originModule, NaN, parserScope); + this.weak = true; } get type() { diff --git a/lib/dependencies/HarmonyImportDependency.js b/lib/dependencies/HarmonyImportDependency.js index 0b904f59b..f4b133a14 100644 --- a/lib/dependencies/HarmonyImportDependency.js +++ b/lib/dependencies/HarmonyImportDependency.js @@ -19,7 +19,8 @@ class HarmonyImportDependency extends ModuleDependency { return { module: this.module, - importedNames: false + importedNames: false, + weak: this.weak }; } diff --git a/test/hotCases/harmony/auto-import-default/file.js b/test/hotCases/harmony/auto-import-default/file.js new file mode 100644 index 000000000..77e3c4ea5 --- /dev/null +++ b/test/hotCases/harmony/auto-import-default/file.js @@ -0,0 +1,3 @@ +module.exports = 1; +--- +module.exports = 2; diff --git a/test/hotCases/harmony/auto-import-default/index.js b/test/hotCases/harmony/auto-import-default/index.js new file mode 100644 index 000000000..53a4b6fe0 --- /dev/null +++ b/test/hotCases/harmony/auto-import-default/index.js @@ -0,0 +1,15 @@ +import value from "./file"; + +it("should auto-import a ES6 imported default value from non-harmony module on accept", function(done) { + value.should.be.eql(1); + module.hot.accept("./file", function() { + value.should.be.eql(2); + outside(); + done(); + }); + NEXT(require("../../update")(done)); +}); + +function outside() { + value.should.be.eql(2); +} diff --git a/test/hotCases/harmony/auto-import-default/out/bundle.js b/test/hotCases/harmony/auto-import-default/out/bundle.js new file mode 100644 index 000000000..c99f1b02b --- /dev/null +++ b/test/hotCases/harmony/auto-import-default/out/bundle.js @@ -0,0 +1,784 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ function hotDisposeChunk(chunkId) { +/******/ delete installedChunks[chunkId]; +/******/ } +/******/ var parentHotUpdateCallback = this["webpackHotUpdate"]; +/******/ this["webpackHotUpdate"] = function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars +/******/ hotAddUpdateChunk(chunkId, moreModules); +/******/ if(parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules); +/******/ } ; +/******/ +/******/ function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars +/******/ var head = document.getElementsByTagName("head")[0]; +/******/ var script = document.createElement("script"); +/******/ script.charset = "utf-8"; +/******/ script.src = __webpack_require__.p + "" + chunkId + "." + hotCurrentHash + ".hot-update.js"; +/******/ ; +/******/ head.appendChild(script); +/******/ } +/******/ +/******/ function hotDownloadManifest(requestTimeout) { // eslint-disable-line no-unused-vars +/******/ requestTimeout = requestTimeout || 10000; +/******/ return new Promise(function(resolve, reject) { +/******/ if(typeof XMLHttpRequest === "undefined") +/******/ return reject(new Error("No browser support")); +/******/ try { +/******/ var request = new XMLHttpRequest(); +/******/ var requestPath = __webpack_require__.p + "" + hotCurrentHash + ".hot-update.json"; +/******/ request.open("GET", requestPath, true); +/******/ request.timeout = requestTimeout; +/******/ request.send(null); +/******/ } catch(err) { +/******/ return reject(err); +/******/ } +/******/ request.onreadystatechange = function() { +/******/ if(request.readyState !== 4) return; +/******/ if(request.status === 0) { +/******/ // timeout +/******/ reject(new Error("Manifest request to " + requestPath + " timed out.")); +/******/ } else if(request.status === 404) { +/******/ // no update available +/******/ resolve(); +/******/ } else if(request.status !== 200 && request.status !== 304) { +/******/ // other failure +/******/ reject(new Error("Manifest request to " + requestPath + " failed.")); +/******/ } else { +/******/ // success +/******/ try { +/******/ var update = JSON.parse(request.responseText); +/******/ } catch(e) { +/******/ reject(e); +/******/ return; +/******/ } +/******/ resolve(update); +/******/ } +/******/ }; +/******/ }); +/******/ } +/******/ +/******/ +/******/ var hotApplyOnUpdate = true; +/******/ var hotCurrentHash = "9e66a96510409aa06627"; // eslint-disable-line no-unused-vars +/******/ var hotRequestTimeout = 10000; +/******/ var hotCurrentModuleData = {}; +/******/ var hotCurrentChildModule; // eslint-disable-line no-unused-vars +/******/ var hotCurrentParents = []; // eslint-disable-line no-unused-vars +/******/ var hotCurrentParentsTemp = []; // eslint-disable-line no-unused-vars +/******/ +/******/ function hotCreateRequire(moduleId) { // eslint-disable-line no-unused-vars +/******/ var me = installedModules[moduleId]; +/******/ if(!me) return __webpack_require__; +/******/ var fn = function(request) { +/******/ if(me.hot.active) { +/******/ if(installedModules[request]) { +/******/ if(installedModules[request].parents.indexOf(moduleId) < 0) +/******/ installedModules[request].parents.push(moduleId); +/******/ } else { +/******/ hotCurrentParents = [moduleId]; +/******/ hotCurrentChildModule = request; +/******/ } +/******/ if(me.children.indexOf(request) < 0) +/******/ me.children.push(request); +/******/ } else { +/******/ console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); +/******/ hotCurrentParents = []; +/******/ } +/******/ return __webpack_require__(request); +/******/ }; +/******/ var ObjectFactory = function ObjectFactory(name) { +/******/ return { +/******/ configurable: true, +/******/ enumerable: true, +/******/ get: function() { +/******/ return __webpack_require__[name]; +/******/ }, +/******/ set: function(value) { +/******/ __webpack_require__[name] = value; +/******/ } +/******/ }; +/******/ }; +/******/ for(var name in __webpack_require__) { +/******/ if(Object.prototype.hasOwnProperty.call(__webpack_require__, name) && name !== "e") { +/******/ Object.defineProperty(fn, name, ObjectFactory(name)); +/******/ } +/******/ } +/******/ fn.e = function(chunkId) { +/******/ if(hotStatus === "ready") +/******/ hotSetStatus("prepare"); +/******/ hotChunksLoading++; +/******/ return __webpack_require__.e(chunkId).then(finishChunkLoading, function(err) { +/******/ finishChunkLoading(); +/******/ throw err; +/******/ }); +/******/ +/******/ function finishChunkLoading() { +/******/ hotChunksLoading--; +/******/ if(hotStatus === "prepare") { +/******/ if(!hotWaitingFilesMap[chunkId]) { +/******/ hotEnsureUpdateChunk(chunkId); +/******/ } +/******/ if(hotChunksLoading === 0 && hotWaitingFiles === 0) { +/******/ hotUpdateDownloaded(); +/******/ } +/******/ } +/******/ } +/******/ }; +/******/ return fn; +/******/ } +/******/ +/******/ function hotCreateModule(moduleId) { // eslint-disable-line no-unused-vars +/******/ var hot = { +/******/ // private stuff +/******/ _acceptedDependencies: {}, +/******/ _declinedDependencies: {}, +/******/ _selfAccepted: false, +/******/ _selfDeclined: false, +/******/ _disposeHandlers: [], +/******/ _main: hotCurrentChildModule !== moduleId, +/******/ +/******/ // Module API +/******/ active: true, +/******/ accept: function(dep, callback) { +/******/ if(typeof dep === "undefined") +/******/ hot._selfAccepted = true; +/******/ else if(typeof dep === "function") +/******/ hot._selfAccepted = dep; +/******/ else if(typeof dep === "object") +/******/ for(var i = 0; i < dep.length; i++) +/******/ hot._acceptedDependencies[dep[i]] = callback || function() {}; +/******/ else +/******/ hot._acceptedDependencies[dep] = callback || function() {}; +/******/ }, +/******/ decline: function(dep) { +/******/ if(typeof dep === "undefined") +/******/ hot._selfDeclined = true; +/******/ else if(typeof dep === "object") +/******/ for(var i = 0; i < dep.length; i++) +/******/ hot._declinedDependencies[dep[i]] = true; +/******/ else +/******/ hot._declinedDependencies[dep] = true; +/******/ }, +/******/ dispose: function(callback) { +/******/ hot._disposeHandlers.push(callback); +/******/ }, +/******/ addDisposeHandler: function(callback) { +/******/ hot._disposeHandlers.push(callback); +/******/ }, +/******/ removeDisposeHandler: function(callback) { +/******/ var idx = hot._disposeHandlers.indexOf(callback); +/******/ if(idx >= 0) hot._disposeHandlers.splice(idx, 1); +/******/ }, +/******/ +/******/ // Management API +/******/ check: hotCheck, +/******/ apply: hotApply, +/******/ status: function(l) { +/******/ if(!l) return hotStatus; +/******/ hotStatusHandlers.push(l); +/******/ }, +/******/ addStatusHandler: function(l) { +/******/ hotStatusHandlers.push(l); +/******/ }, +/******/ removeStatusHandler: function(l) { +/******/ var idx = hotStatusHandlers.indexOf(l); +/******/ if(idx >= 0) hotStatusHandlers.splice(idx, 1); +/******/ }, +/******/ +/******/ //inherit from previous dispose call +/******/ data: hotCurrentModuleData[moduleId] +/******/ }; +/******/ hotCurrentChildModule = undefined; +/******/ return hot; +/******/ } +/******/ +/******/ var hotStatusHandlers = []; +/******/ var hotStatus = "idle"; +/******/ +/******/ function hotSetStatus(newStatus) { +/******/ hotStatus = newStatus; +/******/ for(var i = 0; i < hotStatusHandlers.length; i++) +/******/ hotStatusHandlers[i].call(null, newStatus); +/******/ } +/******/ +/******/ // while downloading +/******/ var hotWaitingFiles = 0; +/******/ var hotChunksLoading = 0; +/******/ var hotWaitingFilesMap = {}; +/******/ var hotRequestedFilesMap = {}; +/******/ var hotAvailableFilesMap = {}; +/******/ var hotDeferred; +/******/ +/******/ // The update info +/******/ var hotUpdate, hotUpdateNewHash; +/******/ +/******/ function toModuleId(id) { +/******/ var isNumber = (+id) + "" === id; +/******/ return isNumber ? +id : id; +/******/ } +/******/ +/******/ function hotCheck(apply) { +/******/ if(hotStatus !== "idle") throw new Error("check() is only allowed in idle status"); +/******/ hotApplyOnUpdate = apply; +/******/ hotSetStatus("check"); +/******/ return hotDownloadManifest(hotRequestTimeout).then(function(update) { +/******/ if(!update) { +/******/ hotSetStatus("idle"); +/******/ return null; +/******/ } +/******/ hotRequestedFilesMap = {}; +/******/ hotWaitingFilesMap = {}; +/******/ hotAvailableFilesMap = update.c; +/******/ hotUpdateNewHash = update.h; +/******/ +/******/ hotSetStatus("prepare"); +/******/ var promise = new Promise(function(resolve, reject) { +/******/ hotDeferred = { +/******/ resolve: resolve, +/******/ reject: reject +/******/ }; +/******/ }); +/******/ hotUpdate = {}; +/******/ var chunkId = "main"; +/******/ { // eslint-disable-line no-lone-blocks +/******/ /*globals chunkId */ +/******/ hotEnsureUpdateChunk(chunkId); +/******/ } +/******/ if(hotStatus === "prepare" && hotChunksLoading === 0 && hotWaitingFiles === 0) { +/******/ hotUpdateDownloaded(); +/******/ } +/******/ return promise; +/******/ }); +/******/ } +/******/ +/******/ function hotAddUpdateChunk(chunkId, moreModules) { // eslint-disable-line no-unused-vars +/******/ if(!hotAvailableFilesMap[chunkId] || !hotRequestedFilesMap[chunkId]) +/******/ return; +/******/ hotRequestedFilesMap[chunkId] = false; +/******/ for(var moduleId in moreModules) { +/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) { +/******/ hotUpdate[moduleId] = moreModules[moduleId]; +/******/ } +/******/ } +/******/ if(--hotWaitingFiles === 0 && hotChunksLoading === 0) { +/******/ hotUpdateDownloaded(); +/******/ } +/******/ } +/******/ +/******/ function hotEnsureUpdateChunk(chunkId) { +/******/ if(!hotAvailableFilesMap[chunkId]) { +/******/ hotWaitingFilesMap[chunkId] = true; +/******/ } else { +/******/ hotRequestedFilesMap[chunkId] = true; +/******/ hotWaitingFiles++; +/******/ hotDownloadUpdateChunk(chunkId); +/******/ } +/******/ } +/******/ +/******/ function hotUpdateDownloaded() { +/******/ hotSetStatus("ready"); +/******/ var deferred = hotDeferred; +/******/ hotDeferred = null; +/******/ if(!deferred) return; +/******/ if(hotApplyOnUpdate) { +/******/ // Wrap deferred object in Promise to mark it as a well-handled Promise to +/******/ // avoid triggering uncaught exception warning in Chrome. +/******/ // See https://bugs.chromium.org/p/chromium/issues/detail?id=465666 +/******/ Promise.resolve().then(function() { +/******/ return hotApply(hotApplyOnUpdate); +/******/ }).then( +/******/ function(result) { +/******/ deferred.resolve(result); +/******/ }, +/******/ function(err) { +/******/ deferred.reject(err); +/******/ } +/******/ ); +/******/ } else { +/******/ var outdatedModules = []; +/******/ for(var id in hotUpdate) { +/******/ if(Object.prototype.hasOwnProperty.call(hotUpdate, id)) { +/******/ outdatedModules.push(toModuleId(id)); +/******/ } +/******/ } +/******/ deferred.resolve(outdatedModules); +/******/ } +/******/ } +/******/ +/******/ function hotApply(options) { +/******/ if(hotStatus !== "ready") throw new Error("apply() is only allowed in ready status"); +/******/ options = options || {}; +/******/ +/******/ var cb; +/******/ var i; +/******/ var j; +/******/ var module; +/******/ var moduleId; +/******/ +/******/ function getAffectedStuff(updateModuleId) { +/******/ var outdatedModules = [updateModuleId]; +/******/ var outdatedDependencies = {}; +/******/ +/******/ var queue = outdatedModules.slice().map(function(id) { +/******/ return { +/******/ chain: [id], +/******/ id: id +/******/ }; +/******/ }); +/******/ while(queue.length > 0) { +/******/ var queueItem = queue.pop(); +/******/ var moduleId = queueItem.id; +/******/ var chain = queueItem.chain; +/******/ module = installedModules[moduleId]; +/******/ if(!module || module.hot._selfAccepted) +/******/ continue; +/******/ if(module.hot._selfDeclined) { +/******/ return { +/******/ type: "self-declined", +/******/ chain: chain, +/******/ moduleId: moduleId +/******/ }; +/******/ } +/******/ if(module.hot._main) { +/******/ return { +/******/ type: "unaccepted", +/******/ chain: chain, +/******/ moduleId: moduleId +/******/ }; +/******/ } +/******/ for(var i = 0; i < module.parents.length; i++) { +/******/ var parentId = module.parents[i]; +/******/ var parent = installedModules[parentId]; +/******/ if(!parent) continue; +/******/ if(parent.hot._declinedDependencies[moduleId]) { +/******/ return { +/******/ type: "declined", +/******/ chain: chain.concat([parentId]), +/******/ moduleId: moduleId, +/******/ parentId: parentId +/******/ }; +/******/ } +/******/ if(outdatedModules.indexOf(parentId) >= 0) continue; +/******/ if(parent.hot._acceptedDependencies[moduleId]) { +/******/ if(!outdatedDependencies[parentId]) +/******/ outdatedDependencies[parentId] = []; +/******/ addAllToSet(outdatedDependencies[parentId], [moduleId]); +/******/ continue; +/******/ } +/******/ delete outdatedDependencies[parentId]; +/******/ outdatedModules.push(parentId); +/******/ queue.push({ +/******/ chain: chain.concat([parentId]), +/******/ id: parentId +/******/ }); +/******/ } +/******/ } +/******/ +/******/ return { +/******/ type: "accepted", +/******/ moduleId: updateModuleId, +/******/ outdatedModules: outdatedModules, +/******/ outdatedDependencies: outdatedDependencies +/******/ }; +/******/ } +/******/ +/******/ function addAllToSet(a, b) { +/******/ for(var i = 0; i < b.length; i++) { +/******/ var item = b[i]; +/******/ if(a.indexOf(item) < 0) +/******/ a.push(item); +/******/ } +/******/ } +/******/ +/******/ // at begin all updates modules are outdated +/******/ // the "outdated" status can propagate to parents if they don't accept the children +/******/ var outdatedDependencies = {}; +/******/ var outdatedModules = []; +/******/ var appliedUpdate = {}; +/******/ +/******/ var warnUnexpectedRequire = function warnUnexpectedRequire() { +/******/ console.warn("[HMR] unexpected require(" + result.moduleId + ") to disposed module"); +/******/ }; +/******/ +/******/ for(var id in hotUpdate) { +/******/ if(Object.prototype.hasOwnProperty.call(hotUpdate, id)) { +/******/ moduleId = toModuleId(id); +/******/ var result; +/******/ if(hotUpdate[id]) { +/******/ result = getAffectedStuff(moduleId); +/******/ } else { +/******/ result = { +/******/ type: "disposed", +/******/ moduleId: id +/******/ }; +/******/ } +/******/ var abortError = false; +/******/ var doApply = false; +/******/ var doDispose = false; +/******/ var chainInfo = ""; +/******/ if(result.chain) { +/******/ chainInfo = "\nUpdate propagation: " + result.chain.join(" -> "); +/******/ } +/******/ switch(result.type) { +/******/ case "self-declined": +/******/ if(options.onDeclined) +/******/ options.onDeclined(result); +/******/ if(!options.ignoreDeclined) +/******/ abortError = new Error("Aborted because of self decline: " + result.moduleId + chainInfo); +/******/ break; +/******/ case "declined": +/******/ if(options.onDeclined) +/******/ options.onDeclined(result); +/******/ if(!options.ignoreDeclined) +/******/ abortError = new Error("Aborted because of declined dependency: " + result.moduleId + " in " + result.parentId + chainInfo); +/******/ break; +/******/ case "unaccepted": +/******/ if(options.onUnaccepted) +/******/ options.onUnaccepted(result); +/******/ if(!options.ignoreUnaccepted) +/******/ abortError = new Error("Aborted because " + moduleId + " is not accepted" + chainInfo); +/******/ break; +/******/ case "accepted": +/******/ if(options.onAccepted) +/******/ options.onAccepted(result); +/******/ doApply = true; +/******/ break; +/******/ case "disposed": +/******/ if(options.onDisposed) +/******/ options.onDisposed(result); +/******/ doDispose = true; +/******/ break; +/******/ default: +/******/ throw new Error("Unexception type " + result.type); +/******/ } +/******/ if(abortError) { +/******/ hotSetStatus("abort"); +/******/ return Promise.reject(abortError); +/******/ } +/******/ if(doApply) { +/******/ appliedUpdate[moduleId] = hotUpdate[moduleId]; +/******/ addAllToSet(outdatedModules, result.outdatedModules); +/******/ for(moduleId in result.outdatedDependencies) { +/******/ if(Object.prototype.hasOwnProperty.call(result.outdatedDependencies, moduleId)) { +/******/ if(!outdatedDependencies[moduleId]) +/******/ outdatedDependencies[moduleId] = []; +/******/ addAllToSet(outdatedDependencies[moduleId], result.outdatedDependencies[moduleId]); +/******/ } +/******/ } +/******/ } +/******/ if(doDispose) { +/******/ addAllToSet(outdatedModules, [result.moduleId]); +/******/ appliedUpdate[moduleId] = warnUnexpectedRequire; +/******/ } +/******/ } +/******/ } +/******/ +/******/ // Store self accepted outdated modules to require them later by the module system +/******/ var outdatedSelfAcceptedModules = []; +/******/ for(i = 0; i < outdatedModules.length; i++) { +/******/ moduleId = outdatedModules[i]; +/******/ if(installedModules[moduleId] && installedModules[moduleId].hot._selfAccepted) +/******/ outdatedSelfAcceptedModules.push({ +/******/ module: moduleId, +/******/ errorHandler: installedModules[moduleId].hot._selfAccepted +/******/ }); +/******/ } +/******/ +/******/ // Now in "dispose" phase +/******/ hotSetStatus("dispose"); +/******/ Object.keys(hotAvailableFilesMap).forEach(function(chunkId) { +/******/ if(hotAvailableFilesMap[chunkId] === false) { +/******/ hotDisposeChunk(chunkId); +/******/ } +/******/ }); +/******/ +/******/ var idx; +/******/ var queue = outdatedModules.slice(); +/******/ while(queue.length > 0) { +/******/ moduleId = queue.pop(); +/******/ module = installedModules[moduleId]; +/******/ if(!module) continue; +/******/ +/******/ var data = {}; +/******/ +/******/ // Call dispose handlers +/******/ var disposeHandlers = module.hot._disposeHandlers; +/******/ for(j = 0; j < disposeHandlers.length; j++) { +/******/ cb = disposeHandlers[j]; +/******/ cb(data); +/******/ } +/******/ hotCurrentModuleData[moduleId] = data; +/******/ +/******/ // disable module (this disables requires from this module) +/******/ module.hot.active = false; +/******/ +/******/ // remove module from cache +/******/ delete installedModules[moduleId]; +/******/ +/******/ // when disposing there is no need to call dispose handler +/******/ delete outdatedDependencies[moduleId]; +/******/ +/******/ // remove "parents" references from all children +/******/ for(j = 0; j < module.children.length; j++) { +/******/ var child = installedModules[module.children[j]]; +/******/ if(!child) continue; +/******/ idx = child.parents.indexOf(moduleId); +/******/ if(idx >= 0) { +/******/ child.parents.splice(idx, 1); +/******/ } +/******/ } +/******/ } +/******/ +/******/ // remove outdated dependency from module children +/******/ var dependency; +/******/ var moduleOutdatedDependencies; +/******/ for(moduleId in outdatedDependencies) { +/******/ if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) { +/******/ module = installedModules[moduleId]; +/******/ if(module) { +/******/ moduleOutdatedDependencies = outdatedDependencies[moduleId]; +/******/ for(j = 0; j < moduleOutdatedDependencies.length; j++) { +/******/ dependency = moduleOutdatedDependencies[j]; +/******/ idx = module.children.indexOf(dependency); +/******/ if(idx >= 0) module.children.splice(idx, 1); +/******/ } +/******/ } +/******/ } +/******/ } +/******/ +/******/ // Not in "apply" phase +/******/ hotSetStatus("apply"); +/******/ +/******/ hotCurrentHash = hotUpdateNewHash; +/******/ +/******/ // insert new code +/******/ for(moduleId in appliedUpdate) { +/******/ if(Object.prototype.hasOwnProperty.call(appliedUpdate, moduleId)) { +/******/ modules[moduleId] = appliedUpdate[moduleId]; +/******/ } +/******/ } +/******/ +/******/ // call accept handlers +/******/ var error = null; +/******/ for(moduleId in outdatedDependencies) { +/******/ if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) { +/******/ module = installedModules[moduleId]; +/******/ if(module) { +/******/ moduleOutdatedDependencies = outdatedDependencies[moduleId]; +/******/ var callbacks = []; +/******/ for(i = 0; i < moduleOutdatedDependencies.length; i++) { +/******/ dependency = moduleOutdatedDependencies[i]; +/******/ cb = module.hot._acceptedDependencies[dependency]; +/******/ if(cb) { +/******/ if(callbacks.indexOf(cb) >= 0) continue; +/******/ callbacks.push(cb); +/******/ } +/******/ } +/******/ for(i = 0; i < callbacks.length; i++) { +/******/ cb = callbacks[i]; +/******/ try { +/******/ cb(moduleOutdatedDependencies); +/******/ } catch(err) { +/******/ if(options.onErrored) { +/******/ options.onErrored({ +/******/ type: "accept-errored", +/******/ moduleId: moduleId, +/******/ dependencyId: moduleOutdatedDependencies[i], +/******/ error: err +/******/ }); +/******/ } +/******/ if(!options.ignoreErrored) { +/******/ if(!error) +/******/ error = err; +/******/ } +/******/ } +/******/ } +/******/ } +/******/ } +/******/ } +/******/ +/******/ // Load self accepted modules +/******/ for(i = 0; i < outdatedSelfAcceptedModules.length; i++) { +/******/ var item = outdatedSelfAcceptedModules[i]; +/******/ moduleId = item.module; +/******/ hotCurrentParents = [moduleId]; +/******/ try { +/******/ __webpack_require__(moduleId); +/******/ } catch(err) { +/******/ if(typeof item.errorHandler === "function") { +/******/ try { +/******/ item.errorHandler(err); +/******/ } catch(err2) { +/******/ if(options.onErrored) { +/******/ options.onErrored({ +/******/ type: "self-accept-error-handler-errored", +/******/ moduleId: moduleId, +/******/ error: err2, +/******/ originalError: err +/******/ }); +/******/ } +/******/ if(!options.ignoreErrored) { +/******/ if(!error) +/******/ error = err2; +/******/ } +/******/ if(!error) +/******/ error = err; +/******/ } +/******/ } else { +/******/ if(options.onErrored) { +/******/ options.onErrored({ +/******/ type: "self-accept-errored", +/******/ moduleId: moduleId, +/******/ error: err +/******/ }); +/******/ } +/******/ if(!options.ignoreErrored) { +/******/ if(!error) +/******/ error = err; +/******/ } +/******/ } +/******/ } +/******/ } +/******/ +/******/ // handle errors in accept handlers and self accepted module load +/******/ if(error) { +/******/ hotSetStatus("fail"); +/******/ return Promise.reject(error); +/******/ } +/******/ +/******/ hotSetStatus("idle"); +/******/ return new Promise(function(resolve) { +/******/ resolve(outdatedModules); +/******/ }); +/******/ } +/******/ +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {}, +/******/ hot: hotCreateModule(moduleId), +/******/ parents: (hotCurrentParentsTemp = hotCurrentParents, hotCurrentParents = [], hotCurrentParentsTemp), +/******/ children: [] +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // __webpack_hash__ +/******/ __webpack_require__.h = function() { return hotCurrentHash; }; +/******/ +/******/ // Load entry module and return exports +/******/ return hotCreateRequire("./index.js")(__webpack_require__.s = "./index.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "../../update.js": +/*!*****************************************!*\ + !*** (webpack)/test/hotCases/update.js ***! + \*****************************************/ +/***/ (function(module, exports) { + +module.exports = function(done, options, callback) { + return function(stats) { + module.hot.check(options || true).then(function() { + if(callback) + callback(stats); + }).catch(function(err) { + done(err); + }); + } +}; + + +/***/ }), + +/***/ "./file.js": +/*!*****************!*\ + !*** ./file.js ***! + \*****************/ +/***/ (function(module, exports) { + +throw new Error("Module parse failed: Unexpected token (3:0)\nYou may need an appropriate loader to handle this file type.\n| export var value = 1;\r\n| ---\r\n| export var value = 2;\r\n| "); + +/***/ }), + +/***/ "./index.js": +/*!******************!*\ + !*** ./index.js ***! + \******************/ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony import */ var _file__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./file */"./file.js"); +/* harmony import */ var _file__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_file__WEBPACK_IMPORTED_MODULE_0__); + + +it("should auto-import a ES6 imported value on accept", function(done) { + _file__WEBPACK_IMPORTED_MODULE_0__["value"].should.be.eql(1); + module.hot.accept(/*! ./file */ "./file.js", function(__WEBPACK_OUTDATED_DEPENDENCIES__) { /* harmony import */ _file__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./file */"./file.js"); /* harmony import */ _file__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_file__WEBPACK_IMPORTED_MODULE_0__); (function() { + _file__WEBPACK_IMPORTED_MODULE_0__["value"].should.be.eql(2); + outside(); + done(); + })(__WEBPACK_OUTDATED_DEPENDENCIES__); }); + NEXT(__webpack_require__(/*! ../../update */ "../../update.js")(done)); +}); + +function outside() { + _file__WEBPACK_IMPORTED_MODULE_0__["value"].should.be.eql(2); +} + + +/***/ }) + +/******/ }); \ No newline at end of file From aef6f19a60ddea6422ba4644facd66de7bee50f5 Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Wed, 22 Nov 2017 16:14:39 +0000 Subject: [PATCH 71/85] Use shorter identifier for ConcatenatedModules See https://github.com/webpack/webpack/issues/5992#issuecomment-346384896 for rationale. Fixes #5992 --- lib/optimize/ConcatenatedModule.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/lib/optimize/ConcatenatedModule.js b/lib/optimize/ConcatenatedModule.js index bc92b069e..3d1ee0914 100644 --- a/lib/optimize/ConcatenatedModule.js +++ b/lib/optimize/ConcatenatedModule.js @@ -7,6 +7,7 @@ const Module = require("../Module"); const Template = require("../Template"); const Parser = require("../Parser"); +const crypto = require("crypto"); const acorn = require("acorn"); const escope = require("escope"); const ReplaceSource = require("webpack-sources/lib/ReplaceSource"); @@ -210,6 +211,7 @@ class ConcatenatedModule extends Module { Object.assign(this.assets, m.assets); } } + this._identifier = this._createIdentifier(); } get modules() { @@ -219,12 +221,7 @@ class ConcatenatedModule extends Module { } identifier() { - return this._orderedConcatenationList.map(info => { - switch(info.type) { - case "concatenated": - return info.module.identifier(); - } - }).filter(Boolean).join(" "); + return this._identifier; } readableIdentifier(requestShortener) { @@ -297,6 +294,18 @@ class ConcatenatedModule extends Module { return list; } + _createIdentifier() { + const orderedConcatenationListIdentifiers = this._orderedConcatenationList.map(info => { + switch(info.type) { + case "concatenated": + return info.module.identifier(); + } + }).filter(Boolean).join(" "); + const hash = crypto.createHash("md5"); + hash.update(orderedConcatenationListIdentifiers); + return this.rootModule.identifier() + " " + hash.digest("hex"); + } + source(dependencyTemplates, outputOptions, requestShortener) { // Metainfo for each module const modulesWithInfo = this._orderedConcatenationList.map((info, idx) => { From ccbc07c239a54b312189f76b0d62f5038c20fe46 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 22 Nov 2017 21:37:26 +0100 Subject: [PATCH 72/85] add wasm extensions as default --- lib/WebpackOptionsDefaulter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WebpackOptionsDefaulter.js b/lib/WebpackOptionsDefaulter.js index 2e4d96237..52baa2aac 100644 --- a/lib/WebpackOptionsDefaulter.js +++ b/lib/WebpackOptionsDefaulter.js @@ -118,7 +118,7 @@ class WebpackOptionsDefaulter extends OptionsDefaulter { this.set("resolve", "call", value => Object.assign({}, value)); this.set("resolve.unsafeCache", true); this.set("resolve.modules", ["node_modules"]); - this.set("resolve.extensions", [".mjs", ".js", ".json"]); + this.set("resolve.extensions", [".wasm", ".mjs", ".js", ".json"]); this.set("resolve.mainFiles", ["index"]); this.set("resolve.aliasFields", "make", (options) => { if(options.target === "web" || options.target === "webworker") From f9d797fb934c9a63fb27865902bd515023274ed7 Mon Sep 17 00:00:00 2001 From: Whien Date: Thu, 23 Nov 2017 16:28:12 +0800 Subject: [PATCH 73/85] fix: Compiler parser.apply bug fix parser.apply.apply instead of parser.apply in lib/Compiler.js --- lib/Compiler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Compiler.js b/lib/Compiler.js index 1ae235973..51559cdbc 100644 --- a/lib/Compiler.js +++ b/lib/Compiler.js @@ -204,7 +204,7 @@ class Compiler extends Tapable { const args = arguments; this.plugin("compilation", (compilation, data) => { data.normalModuleFactory.plugin("parser", parser => { - parser.apply(parser, args); + parser.apply.apply(parser, args); }); }); }, From 035b16aae2347b66ae032eb2283c0f70e10325ea Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Thu, 23 Nov 2017 09:47:19 +0100 Subject: [PATCH 74/85] Update examples --- examples/aggressive-merging/README.md | 44 +- examples/chunkhash/README.md | 62 +-- examples/code-splitted-css-bundle/README.md | 45 +- .../README.md | 164 ++++--- .../code-splitted-require.context/README.md | 162 ++++--- .../code-splitting-bundle-loader/README.md | 124 ++--- examples/code-splitting-harmony/README.md | 138 +++--- .../README.md | 180 +++++--- .../README.md | 132 +++--- .../README.md | 132 +++--- examples/code-splitting/README.md | 126 +++--- examples/coffee-script/README.md | 14 +- .../common-chunk-and-vendor-chunk/README.md | 169 ++++--- examples/common-chunk-grandchildren/README.md | 292 ++++++------ examples/commonjs/README.md | 14 +- examples/css-bundle/README.md | 27 +- .../dll-app-and-vendor/0-vendor/README.md | 24 +- examples/dll-app-and-vendor/1-app/README.md | 88 ++-- examples/dll-user/README.md | 76 ++-- examples/dll/README.md | 36 +- examples/explicit-vendor-chunk/README.md | 74 +-- examples/externals/README.md | 30 +- examples/extra-async-chunk-advanced/README.md | 146 +++--- examples/extra-async-chunk/README.md | 144 +++--- examples/harmony-interop/README.md | 149 +++--- examples/harmony-library/README.md | 18 +- examples/harmony-unused/README.md | 155 ++++--- examples/harmony/README.md | 216 +++++---- examples/http2-aggressive-splitting/README.md | 426 +++++++++--------- examples/hybrid-routing/README.md | 183 ++++---- examples/i18n/README.md | 28 +- examples/loader/README.md | 20 +- examples/mixed/README.md | 182 ++++---- examples/move-to-parent/README.md | 82 ++-- examples/multi-compiler/README.md | 28 +- examples/multi-part-library/README.md | 18 +- examples/multiple-commons-chunks/README.md | 187 +++++--- .../README.md | 109 +++-- examples/multiple-entry-points/README.md | 161 ++++--- examples/named-chunks/README.md | 134 +++--- examples/require.context/README.md | 54 +-- examples/require.resolve/README.md | 14 +- examples/scope-hoisting/README.md | 153 ++++--- examples/side-effects/README.md | 20 +- examples/source-map/README.md | 120 ++--- examples/two-explicit-vendor-chunks/README.md | 163 ++++--- examples/wasm-simple/README.md | 21 +- examples/web-worker/README.md | 83 ++-- 48 files changed, 2921 insertions(+), 2246 deletions(-) diff --git a/examples/aggressive-merging/README.md b/examples/aggressive-merging/README.md index 771299719..8524307e0 100644 --- a/examples/aggressive-merging/README.md +++ b/examples/aggressive-merging/README.md @@ -56,21 +56,21 @@ module.exports = { ## Uncompressed ``` -Hash: 75bcce350a8b5f748873 -Version: webpack 3.5.1 +Hash: 79ab12b0d491f1da79bf +Version: webpack next Asset Size Chunks Chunk Names - 0.chunk.js 5.76 kB 0 [emitted] - 1.chunk.js 403 bytes 1 [emitted] -pageB.bundle.js 6.42 kB 2 [emitted] pageB -pageA.bundle.js 6.39 kB 3 [emitted] pageA -pageC.bundle.js 6.18 kB 4 [emitted] pageC + 0.chunk.js 5.68 KiB 0 [emitted] + 1.chunk.js 453 bytes 1 [emitted] +pageB.bundle.js 7.08 KiB 2 [emitted] pageB +pageA.bundle.js 7.07 KiB 3 [emitted] pageA +pageC.bundle.js 6.84 KiB 4 [emitted] pageC Entrypoint pageA = pageA.bundle.js Entrypoint pageB = pageB.bundle.js Entrypoint pageC = pageC.bundle.js -chunk {0} 0.chunk.js 5.55 kB {2} {3} [rendered] +chunk {0} 0.chunk.js 5.42 KiB {2} {3} [rendered] > aggressive-merge [3] ./pageA.js 1:0-3:2 > aggressive-merge [4] ./pageB.js 1:0-3:2 - [2] ./common.js 5.55 kB {0} [built] + [2] ./common.js 5.42 KiB {0} [built] amd require ./common [3] ./pageA.js 1:0-3:2 amd require ./common [4] ./pageB.js 1:0-3:2 chunk {1} 1.chunk.js 42 bytes {4} [rendered] @@ -87,35 +87,38 @@ chunk {2} pageB.bundle.js (pageB) 92 bytes [entry] [rendered] cjs require ./b [4] ./pageB.js 2:8-22 cjs require ./b [5] ./pageC.js 2:17-31 [4] ./pageB.js 71 bytes {2} [built] + single entry ./pageB pageB chunk {3} pageA.bundle.js (pageA) 92 bytes [entry] [rendered] > pageA [3] ./pageA.js [0] ./a.js 21 bytes {1} {3} [built] cjs require ./a [3] ./pageA.js 2:8-22 amd require ./a [5] ./pageC.js 1:0-3:2 [3] ./pageA.js 71 bytes {3} [built] + single entry ./pageA pageA chunk {4} pageC.bundle.js (pageC) 70 bytes [entry] [rendered] > pageC [5] ./pageC.js [5] ./pageC.js 70 bytes {4} [built] + single entry ./pageC pageC ``` ## Minimized (uglify-js, no zip) ``` -Hash: 75bcce350a8b5f748873 -Version: webpack 3.5.1 - Asset Size Chunks Chunk Names - 0.chunk.js 75 bytes 0 [emitted] - 1.chunk.js 78 bytes 1 [emitted] -pageB.bundle.js 1.46 kB 2 [emitted] pageB -pageA.bundle.js 1.46 kB 3 [emitted] pageA -pageC.bundle.js 1.44 kB 4 [emitted] pageC +Hash: 79ab12b0d491f1da79bf +Version: webpack next + Asset Size Chunks Chunk Names + 0.chunk.js 115 bytes 0 [emitted] + 1.chunk.js 118 bytes 1 [emitted] +pageB.bundle.js 1.63 KiB 2 [emitted] pageB +pageA.bundle.js 1.63 KiB 3 [emitted] pageA +pageC.bundle.js 1.61 KiB 4 [emitted] pageC Entrypoint pageA = pageA.bundle.js Entrypoint pageB = pageB.bundle.js Entrypoint pageC = pageC.bundle.js -chunk {0} 0.chunk.js 5.55 kB {2} {3} [rendered] +chunk {0} 0.chunk.js 5.42 KiB {2} {3} [rendered] > aggressive-merge [3] ./pageA.js 1:0-3:2 > aggressive-merge [4] ./pageB.js 1:0-3:2 - [2] ./common.js 5.55 kB {0} [built] + [2] ./common.js 5.42 KiB {0} [built] amd require ./common [3] ./pageA.js 1:0-3:2 amd require ./common [4] ./pageB.js 1:0-3:2 chunk {1} 1.chunk.js 42 bytes {4} [rendered] @@ -132,13 +135,16 @@ chunk {2} pageB.bundle.js (pageB) 92 bytes [entry] [rendered] cjs require ./b [4] ./pageB.js 2:8-22 cjs require ./b [5] ./pageC.js 2:17-31 [4] ./pageB.js 71 bytes {2} [built] + single entry ./pageB pageB chunk {3} pageA.bundle.js (pageA) 92 bytes [entry] [rendered] > pageA [3] ./pageA.js [0] ./a.js 21 bytes {1} {3} [built] cjs require ./a [3] ./pageA.js 2:8-22 amd require ./a [5] ./pageC.js 1:0-3:2 [3] ./pageA.js 71 bytes {3} [built] + single entry ./pageA pageA chunk {4} pageC.bundle.js (pageC) 70 bytes [entry] [rendered] > pageC [5] ./pageC.js [5] ./pageC.js 70 bytes {4} [built] + single entry ./pageC pageC ``` diff --git a/examples/chunkhash/README.md b/examples/chunkhash/README.md index f4cdfb210..43335b9d1 100644 --- a/examples/chunkhash/README.md +++ b/examples/chunkhash/README.md @@ -62,7 +62,7 @@ module.exports = { @@ -77,7 +77,7 @@ module.exports = { # js/common.[chunkhash].js ``` javascript -webpackJsonp([2],[ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[2],[ /* 0 */ /*!*******************!*\ !*** ./vendor.js ***! @@ -106,33 +106,33 @@ module.exports = __webpack_require__(/*! ./vendor */0); /***/ }) -],[2]); +],[[2,4,2]]]); ``` # js/main.[chunkhash].js ``` javascript -webpackJsonp([3],[ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[3],[ /* 0 */, /* 1 */ /*!********************!*\ !*** ./example.js ***! \********************/ -/*! exports provided: */ +/*! no exports provided */ /*! all exports used */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__vendor__ = __webpack_require__(/*! ./vendor */ 0); +/* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor */0); // some module -__webpack_require__.e/* import() */(1).then(__webpack_require__.bind(null, /*! ./async1 */ 3)); -__webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! ./async2 */ 4)); +__webpack_require__.e/* import() */(1).then(__webpack_require__.bind(null, /*! ./async1 */3)); +__webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! ./async2 */4)); /***/ }) -],[1]); +],[[1,4,2,3]]]); ``` # Info @@ -140,21 +140,21 @@ __webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! . ## Uncompressed ``` -Hash: 49023fec553882c3285c -Version: webpack 3.5.1 +Hash: 19d389fe665472aada46 +Version: webpack next Asset Size Chunks Chunk Names -3db3fdaf96bbdadce99a.js 238 bytes 0 [emitted] -7c1138cf80dd374c367e.js 238 bytes 1 [emitted] - common.[chunkhash].js 732 bytes 2 [emitted] common - main.[chunkhash].js 656 bytes 3 [emitted] main - manifest.[chunkhash].js 5.89 kB 4 [emitted] manifest +d384ba1bbf385fcafc99.js 288 bytes 0 [emitted] +13604ac9ffd7d870f88b.js 288 bytes 1 [emitted] + common.[chunkhash].js 788 bytes 2 [emitted] common + main.[chunkhash].js 711 bytes 3 [emitted] main + manifest.[chunkhash].js 6.96 KiB 4 [emitted] manifest Entrypoint main = manifest.[chunkhash].js common.[chunkhash].js main.[chunkhash].js Entrypoint common = manifest.[chunkhash].js common.[chunkhash].js -chunk {0} 3db3fdaf96bbdadce99a.js 29 bytes {3} [rendered] +chunk {0} d384ba1bbf385fcafc99.js 29 bytes {3} [rendered] > [1] ./example.js 4:0-18 [4] ./async2.js 29 bytes {0} [built] import() ./async2 [1] ./example.js 4:0-18 -chunk {1} 7c1138cf80dd374c367e.js 29 bytes {3} [rendered] +chunk {1} 13604ac9ffd7d870f88b.js 29 bytes {3} [rendered] > [1] ./example.js 3:0-18 [3] ./async1.js 29 bytes {1} [built] import() ./async1 [1] ./example.js 3:0-18 @@ -162,34 +162,36 @@ chunk {2} common.[chunkhash].js (common) 97 bytes {4} [initial] [rendered] > common [2] multi ./vendor [0] ./vendor.js 69 bytes {2} [built] [exports: default] - harmony import ./vendor [1] ./example.js 1:0-30 + harmony side effect evaluation ./vendor [1] ./example.js 1:0-30 single entry ./vendor [2] multi ./vendor common:100000 [2] multi ./vendor 28 bytes {2} [built] + multi entry chunk {3} main.[chunkhash].js (main) 90 bytes {2} [initial] [rendered] > main [1] ./example.js [1] ./example.js 90 bytes {3} [built] [no exports] + single entry ./example main chunk {4} manifest.[chunkhash].js (manifest) 0 bytes [entry] [rendered] ``` ## Minimized (uglify-js, no zip) ``` -Hash: 49023fec553882c3285c -Version: webpack 3.5.1 +Hash: 19d389fe665472aada46 +Version: webpack next Asset Size Chunks Chunk Names -3db3fdaf96bbdadce99a.js 38 bytes 0 [emitted] -7c1138cf80dd374c367e.js 38 bytes 1 [emitted] - common.[chunkhash].js 150 bytes 2 [emitted] common - main.[chunkhash].js 165 bytes 3 [emitted] main - manifest.[chunkhash].js 1.46 kB 4 [emitted] manifest +d384ba1bbf385fcafc99.js 78 bytes 0 [emitted] +13604ac9ffd7d870f88b.js 78 bytes 1 [emitted] + common.[chunkhash].js 196 bytes 2 [emitted] common + main.[chunkhash].js 213 bytes 3 [emitted] main + manifest.[chunkhash].js 1.74 KiB 4 [emitted] manifest Entrypoint main = manifest.[chunkhash].js common.[chunkhash].js main.[chunkhash].js Entrypoint common = manifest.[chunkhash].js common.[chunkhash].js -chunk {0} 3db3fdaf96bbdadce99a.js 29 bytes {3} [rendered] +chunk {0} d384ba1bbf385fcafc99.js 29 bytes {3} [rendered] > [1] ./example.js 4:0-18 [4] ./async2.js 29 bytes {0} [built] import() ./async2 [1] ./example.js 4:0-18 -chunk {1} 7c1138cf80dd374c367e.js 29 bytes {3} [rendered] +chunk {1} 13604ac9ffd7d870f88b.js 29 bytes {3} [rendered] > [1] ./example.js 3:0-18 [3] ./async1.js 29 bytes {1} [built] import() ./async1 [1] ./example.js 3:0-18 @@ -197,12 +199,14 @@ chunk {2} common.[chunkhash].js (common) 97 bytes {4} [initial] [rendered] > common [2] multi ./vendor [0] ./vendor.js 69 bytes {2} [built] [exports: default] - harmony import ./vendor [1] ./example.js 1:0-30 + harmony side effect evaluation ./vendor [1] ./example.js 1:0-30 single entry ./vendor [2] multi ./vendor common:100000 [2] multi ./vendor 28 bytes {2} [built] + multi entry chunk {3} main.[chunkhash].js (main) 90 bytes {2} [initial] [rendered] > main [1] ./example.js [1] ./example.js 90 bytes {3} [built] [no exports] + single entry ./example main chunk {4} manifest.[chunkhash].js (manifest) 0 bytes [entry] [rendered] ``` \ No newline at end of file diff --git a/examples/code-splitted-css-bundle/README.md b/examples/code-splitted-css-bundle/README.md index 50f01bb7a..cb18abeb9 100644 --- a/examples/code-splitted-css-bundle/README.md +++ b/examples/code-splitted-css-bundle/README.md @@ -31,10 +31,11 @@ require("./style2.css"); # webpack.config.js ``` javascript -var ExtractTextPlugin = require("extract-text-webpack-plugin"); +const LoaderOptionsPlugin = require("../../lib/LoaderOptionsPlugin"); +const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { module: { - loaders: [ + rules: [ { test: /\.css$/, use: ExtractTextPlugin.extract({ @@ -48,6 +49,10 @@ module.exports = { plugins: [ new ExtractTextPlugin({ filename: "style.css" + }), + // Temporary workaround for the file-loader + new LoaderOptionsPlugin({ + options: {} }) ] }; @@ -66,36 +71,38 @@ body { ## Uncompressed ``` -Hash: 5be34b0d3c624e61c616 -Version: webpack 3.5.1 +Hash: eb83e18f883b3782ac4e +Version: webpack next Asset Size Chunks Chunk Names ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted] - 0.output.js 2.43 kB 0 [emitted] - output.js 21.2 kB 1 [emitted] main + 0.output.js 2.42 KiB 0 [emitted] + output.js 21.5 KiB 1 [emitted] main style.css 71 bytes 1 [emitted] main Entrypoint main = output.js style.css -chunk {0} 0.output.js 1.36 kB {1} [rendered] +chunk {0} 0.output.js 1.33 KiB {1} [rendered] > [0] ./example.js 2:0-20 [5] ./chunk.js 26 bytes {0} [built] amd require ./chunk [0] ./example.js 2:0-20 - [6] ./style2.css 1.01 kB {0} [built] + [6] ./style2.css 1020 bytes {0} [built] cjs require ./style2.css [5] ./chunk.js 1:0-23 [7] (webpack)/node_modules/css-loader!./style2.css 236 bytes {0} [built] cjs require !!../../node_modules/css-loader/index.js!./style2.css [6] ./style2.css 4:14-78 [8] ./image2.png 82 bytes {0} [built] cjs require ./image2.png [7] (webpack)/node_modules/css-loader!./style2.css 6:58-81 -chunk {1} output.js, style.css (main) 14.1 kB [entry] [rendered] +chunk {1} output.js, style.css (main) 13.7 KiB [entry] [rendered] > main [0] ./example.js [0] ./example.js 48 bytes {1} [built] + single entry .\example.js main [1] ./style.css 41 bytes {1} [built] cjs require ./style.css [0] ./example.js 1:0-22 + 3 hidden modules Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!style.css: 1 asset Entrypoint undefined = extract-text-webpack-plugin-output-filename - chunk {0} extract-text-webpack-plugin-output-filename 2.58 kB [entry] [rendered] + chunk {0} extract-text-webpack-plugin-output-filename 2.52 KiB [entry] [rendered] > [0] (webpack)/node_modules/css-loader!./style.css [0] (webpack)/node_modules/css-loader!./style.css 235 bytes {0} [built] + single entry !!(webpack)\node_modules\css-loader\index.js!.\style.css [2] ./image.png 82 bytes {0} [built] cjs require ./image.png [0] (webpack)/node_modules/css-loader!./style.css 6:58-80 + 1 hidden module @@ -104,36 +111,38 @@ Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin ## Minimized (uglify-js, no zip) ``` -Hash: edbe0e91ba86d814d855 -Version: webpack 3.5.1 +Hash: 3d67c808fc684d446a10 +Version: webpack next Asset Size Chunks Chunk Names ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted] - 0.output.js 343 bytes 0 [emitted] - output.js 6.58 kB 1 [emitted] main + 0.output.js 383 bytes 0 [emitted] + output.js 6.63 KiB 1 [emitted] main style.css 61 bytes 1 [emitted] main Entrypoint main = output.js style.css -chunk {0} 0.output.js 1.34 kB {1} [rendered] +chunk {0} 0.output.js 1.31 KiB {1} [rendered] > [0] ./example.js 2:0-20 [5] ./chunk.js 26 bytes {0} [built] amd require ./chunk [0] ./example.js 2:0-20 - [6] ./style2.css 1.01 kB {0} [built] + [6] ./style2.css 1020 bytes {0} [built] cjs require ./style2.css [5] ./chunk.js 1:0-23 [7] (webpack)/node_modules/css-loader!./style2.css 219 bytes {0} [built] cjs require !!../../node_modules/css-loader/index.js!./style2.css [6] ./style2.css 4:14-78 [8] ./image2.png 82 bytes {0} [built] cjs require ./image2.png [7] (webpack)/node_modules/css-loader!./style2.css 6:50-73 -chunk {1} output.js, style.css (main) 14.1 kB [entry] [rendered] +chunk {1} output.js, style.css (main) 13.7 KiB [entry] [rendered] > main [0] ./example.js [0] ./example.js 48 bytes {1} [built] + single entry .\example.js main [1] ./style.css 41 bytes {1} [built] cjs require ./style.css [0] ./example.js 1:0-22 + 3 hidden modules Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!style.css: 1 asset Entrypoint undefined = extract-text-webpack-plugin-output-filename - chunk {0} extract-text-webpack-plugin-output-filename 2.56 kB [entry] [rendered] + chunk {0} extract-text-webpack-plugin-output-filename 2.5 KiB [entry] [rendered] > [0] (webpack)/node_modules/css-loader!./style.css [0] (webpack)/node_modules/css-loader!./style.css 218 bytes {0} [built] + single entry !!(webpack)\node_modules\css-loader\index.js!.\style.css [2] ./image.png 82 bytes {0} [built] cjs require ./image.png [0] (webpack)/node_modules/css-loader!./style.css 6:50-72 + 1 hidden module diff --git a/examples/code-splitted-require.context-amd/README.md b/examples/code-splitted-require.context-amd/README.md index 918be881b..87c108c8d 100644 --- a/examples/code-splitted-require.context-amd/README.md +++ b/examples/code-splitted-require.context-amd/README.md @@ -21,8 +21,8 @@ getTemplate("b", function(b) { ``` javascript /******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading -/******/ var parentJsonpFunction = window["webpackJsonp"]; -/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0], moreModules = data[1], executeModules = data[2]; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = [], result; @@ -38,7 +38,7 @@ getTemplate("b", function(b) { /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); +/******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } @@ -48,11 +48,13 @@ getTemplate("b", function(b) { /******/ // The module cache /******/ var installedModules = {}; /******/ -/******/ // objects to store loaded and loading chunks +/******/ // object to store loaded and loading chunks /******/ var installedChunks = { /******/ 1: 0 /******/ }; /******/ +/******/ var scheduledModules = []; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ @@ -80,51 +82,59 @@ getTemplate("b", function(b) { /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // JSONP chunk loading for javascript +/******/ /******/ var installedChunkData = installedChunks[chunkId]; -/******/ if(installedChunkData === 0) { -/******/ return new Promise(function(resolve) { resolve(); }); -/******/ } +/******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ -/******/ // a Promise means "currently loading". -/******/ if(installedChunkData) { -/******/ return installedChunkData[2]; -/******/ } +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); /******/ -/******/ // setup Promise in chunk cache -/******/ var promise = new Promise(function(resolve, reject) { -/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; -/******/ }); -/******/ installedChunkData[2] = promise; +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120000; /******/ -/******/ // start chunk loading -/******/ var head = document.getElementsByTagName('head')[0]; -/******/ var script = document.createElement('script'); -/******/ script.type = 'text/javascript'; -/******/ script.charset = 'utf-8'; -/******/ script.async = true; -/******/ script.timeout = 120000; -/******/ -/******/ if (__webpack_require__.nc) { -/******/ script.setAttribute("nonce", __webpack_require__.nc); -/******/ } -/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; -/******/ var timeout = setTimeout(onScriptComplete, 120000); -/******/ script.onerror = script.onload = onScriptComplete; -/******/ function onScriptComplete() { -/******/ // avoid mem leaks in IE. -/******/ script.onerror = script.onload = null; -/******/ clearTimeout(timeout); -/******/ var chunk = installedChunks[chunkId]; -/******/ if(chunk !== 0) { -/******/ if(chunk) { -/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ installedChunks[chunkId] = undefined; +/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ function onScriptComplete(event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ head.appendChild(script); /******/ } -/******/ }; -/******/ head.appendChild(script); -/******/ -/******/ return promise; +/******/ } +/******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) @@ -162,6 +172,12 @@ getTemplate("b", function(b) { /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var parentJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) @@ -181,9 +197,9 @@ getTemplate("b", function(b) { /***/ (function(module, exports, __webpack_require__) { function getTemplate(templateName, callback) { - __webpack_require__.e/* require */(0).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ../require.context/templates */ 1)("./"+templateName)]; (function(tmpl) { + __webpack_require__.e/* require */(0).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__( 1)("./"+templateName)]; ((function(tmpl) { callback(tmpl()); - }.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}).catch(__webpack_require__.oe); + }).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}).catch(__webpack_require__.oe); } getTemplate("a", function(a) { console.log(a); @@ -199,12 +215,12 @@ getTemplate("b", function(b) { # js/0.output.js ``` javascript -webpackJsonp([0],[ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[ /* 0 */, /* 1 */ -/*!*********************************************!*\ - !*** ../require.context/templates ^\.\/.*$ ***! - \*********************************************/ +/*!**************************************************!*\ + !*** ../require.context/templates sync ^\.\/.*$ ***! + \**************************************************/ /*! no static exports found */ /*! all exports used */ /***/ (function(module, exports, __webpack_require__) { @@ -273,7 +289,7 @@ module.exports = function() { } /***/ }) -]); +]]); ``` # Info @@ -281,53 +297,55 @@ module.exports = function() { ## Uncompressed ``` -Hash: 1c46bbe47e8b8a0ee8e2 -Version: webpack 3.5.1 - Asset Size Chunks Chunk Names -0.output.js 1.85 kB 0 [emitted] - output.js 6.37 kB 1 [emitted] main +Hash: 3742c378c8642182b6b1 +Version: webpack next + Asset Size Chunks Chunk Names +0.output.js 1.87 KiB 0 [emitted] + output.js 6.99 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 463 bytes {1} [rendered] > [0] ./example.js 2:1-4:3 - [1] ../require.context/templates ^\.\/.*$ 217 bytes {0} [built] + [1] ../require.context/templates sync ^\.\/.*$ 217 bytes {0} [built] amd require context ../require.context/templates [0] ./example.js 2:1-4:3 [2] ../require.context/templates/a.js 82 bytes {0} [optional] [built] - context element ./a.js [1] ../require.context/templates ^\.\/.*$ ./a.js - context element ./a [1] ../require.context/templates ^\.\/.*$ ./a + context element ./a.js [1] ../require.context/templates sync ^\.\/.*$ ./a.js + context element ./a [1] ../require.context/templates sync ^\.\/.*$ ./a [3] ../require.context/templates/b.js 82 bytes {0} [optional] [built] - context element ./b.js [1] ../require.context/templates ^\.\/.*$ ./b.js - context element ./b [1] ../require.context/templates ^\.\/.*$ ./b + context element ./b.js [1] ../require.context/templates sync ^\.\/.*$ ./b.js + context element ./b [1] ../require.context/templates sync ^\.\/.*$ ./b [4] ../require.context/templates/c.js 82 bytes {0} [optional] [built] - context element ./c.js [1] ../require.context/templates ^\.\/.*$ ./c.js - context element ./c [1] ../require.context/templates ^\.\/.*$ ./c + context element ./c.js [1] ../require.context/templates sync ^\.\/.*$ ./c.js + context element ./c [1] ../require.context/templates sync ^\.\/.*$ ./c chunk {1} output.js (main) 261 bytes [entry] [rendered] > main [0] ./example.js [0] ./example.js 261 bytes {1} [built] + single entry .\example.js main ``` ## Minimized (uglify-js, no zip) ``` -Hash: 1c46bbe47e8b8a0ee8e2 -Version: webpack 3.5.1 +Hash: 3742c378c8642182b6b1 +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 544 bytes 0 [emitted] - output.js 1.52 kB 1 [emitted] main +0.output.js 584 bytes 0 [emitted] + output.js 1.69 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 463 bytes {1} [rendered] > [0] ./example.js 2:1-4:3 - [1] ../require.context/templates ^\.\/.*$ 217 bytes {0} [built] + [1] ../require.context/templates sync ^\.\/.*$ 217 bytes {0} [built] amd require context ../require.context/templates [0] ./example.js 2:1-4:3 [2] ../require.context/templates/a.js 82 bytes {0} [optional] [built] - context element ./a.js [1] ../require.context/templates ^\.\/.*$ ./a.js - context element ./a [1] ../require.context/templates ^\.\/.*$ ./a + context element ./a.js [1] ../require.context/templates sync ^\.\/.*$ ./a.js + context element ./a [1] ../require.context/templates sync ^\.\/.*$ ./a [3] ../require.context/templates/b.js 82 bytes {0} [optional] [built] - context element ./b.js [1] ../require.context/templates ^\.\/.*$ ./b.js - context element ./b [1] ../require.context/templates ^\.\/.*$ ./b + context element ./b.js [1] ../require.context/templates sync ^\.\/.*$ ./b.js + context element ./b [1] ../require.context/templates sync ^\.\/.*$ ./b [4] ../require.context/templates/c.js 82 bytes {0} [optional] [built] - context element ./c.js [1] ../require.context/templates ^\.\/.*$ ./c.js - context element ./c [1] ../require.context/templates ^\.\/.*$ ./c + context element ./c.js [1] ../require.context/templates sync ^\.\/.*$ ./c.js + context element ./c [1] ../require.context/templates sync ^\.\/.*$ ./c chunk {1} output.js (main) 261 bytes [entry] [rendered] > main [0] ./example.js [0] ./example.js 261 bytes {1} [built] + single entry .\example.js main ``` diff --git a/examples/code-splitted-require.context/README.md b/examples/code-splitted-require.context/README.md index 3c431704d..3a477604e 100644 --- a/examples/code-splitted-require.context/README.md +++ b/examples/code-splitted-require.context/README.md @@ -21,8 +21,8 @@ getTemplate("b", function(b) { ``` javascript /******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading -/******/ var parentJsonpFunction = window["webpackJsonp"]; -/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0], moreModules = data[1], executeModules = data[2]; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = [], result; @@ -38,7 +38,7 @@ getTemplate("b", function(b) { /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); +/******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } @@ -48,11 +48,13 @@ getTemplate("b", function(b) { /******/ // The module cache /******/ var installedModules = {}; /******/ -/******/ // objects to store loaded and loading chunks +/******/ // object to store loaded and loading chunks /******/ var installedChunks = { /******/ 1: 0 /******/ }; /******/ +/******/ var scheduledModules = []; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ @@ -80,51 +82,59 @@ getTemplate("b", function(b) { /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // JSONP chunk loading for javascript +/******/ /******/ var installedChunkData = installedChunks[chunkId]; -/******/ if(installedChunkData === 0) { -/******/ return new Promise(function(resolve) { resolve(); }); -/******/ } +/******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ -/******/ // a Promise means "currently loading". -/******/ if(installedChunkData) { -/******/ return installedChunkData[2]; -/******/ } +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); /******/ -/******/ // setup Promise in chunk cache -/******/ var promise = new Promise(function(resolve, reject) { -/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; -/******/ }); -/******/ installedChunkData[2] = promise; +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120000; /******/ -/******/ // start chunk loading -/******/ var head = document.getElementsByTagName('head')[0]; -/******/ var script = document.createElement('script'); -/******/ script.type = 'text/javascript'; -/******/ script.charset = 'utf-8'; -/******/ script.async = true; -/******/ script.timeout = 120000; -/******/ -/******/ if (__webpack_require__.nc) { -/******/ script.setAttribute("nonce", __webpack_require__.nc); -/******/ } -/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; -/******/ var timeout = setTimeout(onScriptComplete, 120000); -/******/ script.onerror = script.onload = onScriptComplete; -/******/ function onScriptComplete() { -/******/ // avoid mem leaks in IE. -/******/ script.onerror = script.onload = null; -/******/ clearTimeout(timeout); -/******/ var chunk = installedChunks[chunkId]; -/******/ if(chunk !== 0) { -/******/ if(chunk) { -/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ installedChunks[chunkId] = undefined; +/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ function onScriptComplete(event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ head.appendChild(script); /******/ } -/******/ }; -/******/ head.appendChild(script); -/******/ -/******/ return promise; +/******/ } +/******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) @@ -162,6 +172,12 @@ getTemplate("b", function(b) { /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var parentJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) @@ -182,7 +198,7 @@ getTemplate("b", function(b) { function getTemplate(templateName, callback) { __webpack_require__.e/* require.ensure */(0).then((function(require) { - callback(__webpack_require__(/*! ../require.context/templates */ 1)("./"+templateName)()); + callback(__webpack_require__( 1)("./"+templateName)()); }).bind(null, __webpack_require__)).catch(__webpack_require__.oe); } getTemplate("a", function(a) { @@ -199,12 +215,12 @@ getTemplate("b", function(b) { # js/0.output.js ``` javascript -webpackJsonp([0],[ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[ /* 0 */, /* 1 */ -/*!*********************************************!*\ - !*** ../require.context/templates ^\.\/.*$ ***! - \*********************************************/ +/*!**************************************************!*\ + !*** ../require.context/templates sync ^\.\/.*$ ***! + \**************************************************/ /*! no static exports found */ /*! all exports used */ /***/ (function(module, exports, __webpack_require__) { @@ -273,7 +289,7 @@ module.exports = function() { } /***/ }) -]); +]]); ``` # Info @@ -281,53 +297,55 @@ module.exports = function() { ## Uncompressed ``` -Hash: f67ab883501eec17d2fb -Version: webpack 3.5.1 - Asset Size Chunks Chunk Names -0.output.js 1.85 kB 0 [emitted] - output.js 6.3 kB 1 [emitted] main +Hash: 71a61aeef010cd2fd50d +Version: webpack next + Asset Size Chunks Chunk Names +0.output.js 1.87 KiB 0 [emitted] + output.js 6.93 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 463 bytes {1} [rendered] > [0] ./example.js 2:1-4:3 - [1] ../require.context/templates ^\.\/.*$ 217 bytes {0} [built] + [1] ../require.context/templates sync ^\.\/.*$ 217 bytes {0} [built] cjs require context ../require.context/templates [0] ./example.js 3:11-64 [2] ../require.context/templates/a.js 82 bytes {0} [optional] [built] - context element ./a.js [1] ../require.context/templates ^\.\/.*$ ./a.js - context element ./a [1] ../require.context/templates ^\.\/.*$ ./a + context element ./a.js [1] ../require.context/templates sync ^\.\/.*$ ./a.js + context element ./a [1] ../require.context/templates sync ^\.\/.*$ ./a [3] ../require.context/templates/b.js 82 bytes {0} [optional] [built] - context element ./b.js [1] ../require.context/templates ^\.\/.*$ ./b.js - context element ./b [1] ../require.context/templates ^\.\/.*$ ./b + context element ./b.js [1] ../require.context/templates sync ^\.\/.*$ ./b.js + context element ./b [1] ../require.context/templates sync ^\.\/.*$ ./b [4] ../require.context/templates/c.js 82 bytes {0} [optional] [built] - context element ./c.js [1] ../require.context/templates ^\.\/.*$ ./c.js - context element ./c [1] ../require.context/templates ^\.\/.*$ ./c + context element ./c.js [1] ../require.context/templates sync ^\.\/.*$ ./c.js + context element ./c [1] ../require.context/templates sync ^\.\/.*$ ./c chunk {1} output.js (main) 276 bytes [entry] [rendered] > main [0] ./example.js [0] ./example.js 276 bytes {1} [built] + single entry .\example.js main ``` ## Minimized (uglify-js, no zip) ``` -Hash: f67ab883501eec17d2fb -Version: webpack 3.5.1 +Hash: 71a61aeef010cd2fd50d +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 544 bytes 0 [emitted] - output.js 1.49 kB 1 [emitted] main +0.output.js 584 bytes 0 [emitted] + output.js 1.66 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 463 bytes {1} [rendered] > [0] ./example.js 2:1-4:3 - [1] ../require.context/templates ^\.\/.*$ 217 bytes {0} [built] + [1] ../require.context/templates sync ^\.\/.*$ 217 bytes {0} [built] cjs require context ../require.context/templates [0] ./example.js 3:11-64 [2] ../require.context/templates/a.js 82 bytes {0} [optional] [built] - context element ./a.js [1] ../require.context/templates ^\.\/.*$ ./a.js - context element ./a [1] ../require.context/templates ^\.\/.*$ ./a + context element ./a.js [1] ../require.context/templates sync ^\.\/.*$ ./a.js + context element ./a [1] ../require.context/templates sync ^\.\/.*$ ./a [3] ../require.context/templates/b.js 82 bytes {0} [optional] [built] - context element ./b.js [1] ../require.context/templates ^\.\/.*$ ./b.js - context element ./b [1] ../require.context/templates ^\.\/.*$ ./b + context element ./b.js [1] ../require.context/templates sync ^\.\/.*$ ./b.js + context element ./b [1] ../require.context/templates sync ^\.\/.*$ ./b [4] ../require.context/templates/c.js 82 bytes {0} [optional] [built] - context element ./c.js [1] ../require.context/templates ^\.\/.*$ ./c.js - context element ./c [1] ../require.context/templates ^\.\/.*$ ./c + context element ./c.js [1] ../require.context/templates sync ^\.\/.*$ ./c.js + context element ./c [1] ../require.context/templates sync ^\.\/.*$ ./c chunk {1} output.js (main) 276 bytes [entry] [rendered] > main [0] ./example.js [0] ./example.js 276 bytes {1} [built] + single entry .\example.js main ``` diff --git a/examples/code-splitting-bundle-loader/README.md b/examples/code-splitting-bundle-loader/README.md index 8d19cbc4b..4f4a75c84 100644 --- a/examples/code-splitting-bundle-loader/README.md +++ b/examples/code-splitting-bundle-loader/README.md @@ -24,8 +24,8 @@ module.exports = "It works"; ``` javascript /******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading -/******/ var parentJsonpFunction = window["webpackJsonp"]; -/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0], moreModules = data[1], executeModules = data[2]; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = [], result; @@ -41,7 +41,7 @@ module.exports = "It works"; /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); +/******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } @@ -51,11 +51,13 @@ module.exports = "It works"; /******/ // The module cache /******/ var installedModules = {}; /******/ -/******/ // objects to store loaded and loading chunks +/******/ // object to store loaded and loading chunks /******/ var installedChunks = { /******/ 1: 0 /******/ }; /******/ +/******/ var scheduledModules = []; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ @@ -83,51 +85,59 @@ module.exports = "It works"; /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // JSONP chunk loading for javascript +/******/ /******/ var installedChunkData = installedChunks[chunkId]; -/******/ if(installedChunkData === 0) { -/******/ return new Promise(function(resolve) { resolve(); }); -/******/ } +/******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ -/******/ // a Promise means "currently loading". -/******/ if(installedChunkData) { -/******/ return installedChunkData[2]; -/******/ } +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); /******/ -/******/ // setup Promise in chunk cache -/******/ var promise = new Promise(function(resolve, reject) { -/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; -/******/ }); -/******/ installedChunkData[2] = promise; +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120000; /******/ -/******/ // start chunk loading -/******/ var head = document.getElementsByTagName('head')[0]; -/******/ var script = document.createElement('script'); -/******/ script.type = 'text/javascript'; -/******/ script.charset = 'utf-8'; -/******/ script.async = true; -/******/ script.timeout = 120000; -/******/ -/******/ if (__webpack_require__.nc) { -/******/ script.setAttribute("nonce", __webpack_require__.nc); -/******/ } -/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; -/******/ var timeout = setTimeout(onScriptComplete, 120000); -/******/ script.onerror = script.onload = onScriptComplete; -/******/ function onScriptComplete() { -/******/ // avoid mem leaks in IE. -/******/ script.onerror = script.onload = null; -/******/ clearTimeout(timeout); -/******/ var chunk = installedChunks[chunkId]; -/******/ if(chunk !== 0) { -/******/ if(chunk) { -/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ installedChunks[chunkId] = undefined; +/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ function onScriptComplete(event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ head.appendChild(script); /******/ } -/******/ }; -/******/ head.appendChild(script); -/******/ -/******/ return promise; +/******/ } +/******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) @@ -165,6 +175,12 @@ module.exports = "It works"; /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var parentJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) @@ -219,7 +235,7 @@ __webpack_require__.e/* require.ensure */(0).then((function(require) { # js/0.output.js ``` javascript -webpackJsonp([0],{ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],{ /***/ 2: /*!*****************!*\ @@ -233,7 +249,7 @@ module.exports = "It works"; /***/ }) -}); +}]); ``` # Info @@ -241,11 +257,11 @@ module.exports = "It works"; ## Uncompressed ``` -Hash: 0f292e2adbe6929efd48 -Version: webpack 3.5.1 +Hash: 18d3b0908ee42d7ec955 +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 231 bytes 0 [emitted] - output.js 6.73 kB 1 [emitted] main +0.output.js 281 bytes 0 [emitted] + output.js 7.38 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 28 bytes {1} [rendered] > [1] (webpack)/node_modules/bundle-loader!./file.js 7:0-14:2 @@ -254,6 +270,7 @@ chunk {0} 0.output.js 28 bytes {1} [rendered] chunk {1} output.js (main) 378 bytes [entry] [rendered] > main [0] ./example.js [0] ./example.js 97 bytes {1} [built] + single entry .\example.js main [1] (webpack)/node_modules/bundle-loader!./file.js 281 bytes {1} [built] cjs require bundle-loader!./file.js [0] ./example.js 1:0-34 ``` @@ -261,11 +278,11 @@ chunk {1} output.js (main) 378 bytes [entry] [rendered] ## Minimized (uglify-js, no zip) ``` -Hash: 0f292e2adbe6929efd48 -Version: webpack 3.5.1 +Hash: 18d3b0908ee42d7ec955 +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 58 bytes 0 [emitted] - output.js 1.55 kB 1 [emitted] main +0.output.js 98 bytes 0 [emitted] + output.js 1.72 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 28 bytes {1} [rendered] > [1] (webpack)/node_modules/bundle-loader!./file.js 7:0-14:2 @@ -274,6 +291,7 @@ chunk {0} 0.output.js 28 bytes {1} [rendered] chunk {1} output.js (main) 378 bytes [entry] [rendered] > main [0] ./example.js [0] ./example.js 97 bytes {1} [built] + single entry .\example.js main [1] (webpack)/node_modules/bundle-loader!./file.js 281 bytes {1} [built] cjs require bundle-loader!./file.js [0] ./example.js 1:0-34 ``` diff --git a/examples/code-splitting-harmony/README.md b/examples/code-splitting-harmony/README.md index 4c03bc9ec..117636a61 100644 --- a/examples/code-splitting-harmony/README.md +++ b/examples/code-splitting-harmony/README.md @@ -32,8 +32,8 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) { ``` javascript /******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading -/******/ var parentJsonpFunction = window["webpackJsonp"]; -/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0], moreModules = data[1], executeModules = data[2]; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = [], result; @@ -49,7 +49,7 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) { /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); +/******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } @@ -59,11 +59,13 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) { /******/ // The module cache /******/ var installedModules = {}; /******/ -/******/ // objects to store loaded and loading chunks +/******/ // object to store loaded and loading chunks /******/ var installedChunks = { /******/ 3: 0 /******/ }; /******/ +/******/ var scheduledModules = []; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ @@ -91,51 +93,59 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) { /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // JSONP chunk loading for javascript +/******/ /******/ var installedChunkData = installedChunks[chunkId]; -/******/ if(installedChunkData === 0) { -/******/ return new Promise(function(resolve) { resolve(); }); -/******/ } +/******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ -/******/ // a Promise means "currently loading". -/******/ if(installedChunkData) { -/******/ return installedChunkData[2]; -/******/ } +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); /******/ -/******/ // setup Promise in chunk cache -/******/ var promise = new Promise(function(resolve, reject) { -/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; -/******/ }); -/******/ installedChunkData[2] = promise; +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120000; /******/ -/******/ // start chunk loading -/******/ var head = document.getElementsByTagName('head')[0]; -/******/ var script = document.createElement('script'); -/******/ script.type = 'text/javascript'; -/******/ script.charset = 'utf-8'; -/******/ script.async = true; -/******/ script.timeout = 120000; -/******/ -/******/ if (__webpack_require__.nc) { -/******/ script.setAttribute("nonce", __webpack_require__.nc); -/******/ } -/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; -/******/ var timeout = setTimeout(onScriptComplete, 120000); -/******/ script.onerror = script.onload = onScriptComplete; -/******/ function onScriptComplete() { -/******/ // avoid mem leaks in IE. -/******/ script.onerror = script.onload = null; -/******/ clearTimeout(timeout); -/******/ var chunk = installedChunks[chunkId]; -/******/ if(chunk !== 0) { -/******/ if(chunk) { -/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ installedChunks[chunkId] = undefined; +/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ function onScriptComplete(event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ head.appendChild(script); /******/ } -/******/ }; -/******/ head.appendChild(script); -/******/ -/******/ return promise; +/******/ } +/******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) @@ -173,6 +183,12 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) { /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var parentJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 2); /******/ }) @@ -189,22 +205,22 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) { /*!********************!*\ !*** ./example.js ***! \********************/ -/*! exports provided: */ +/*! no exports provided */ /*! all exports used */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_a__ = __webpack_require__(/*! a */ 3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_a___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_a__); +/* harmony import */ var a__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! a */3); +/* harmony import */ var a__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(a__WEBPACK_IMPORTED_MODULE_0__); -__webpack_require__.e/* import() */(2).then(__webpack_require__.bind(null, /*! b */ 5)).then(function(b) { +__webpack_require__.e/* import() */(2).then(__webpack_require__.bind(null, /*! b */5)).then(function(b) { console.log("b loaded", b); }) function loadC(name) { - return __webpack_require__(/*! c */ 4)("./" + name); + return __webpack_require__( 4)("./" + name); } Promise.all([loadC("1"), loadC("2")]).then(function(arr) { @@ -273,13 +289,13 @@ module.exports = webpackAsyncContext; ## Uncompressed ``` -Hash: f2701c90a6d1597932b5 -Version: webpack 3.5.1 +Hash: 99774db1d98bb53fa195 +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 258 bytes 0 [emitted] -1.output.js 249 bytes 1 [emitted] -2.output.js 244 bytes 2 [emitted] - output.js 7.55 kB 3 [emitted] main +0.output.js 308 bytes 0 [emitted] +1.output.js 299 bytes 1 [emitted] +2.output.js 294 bytes 2 [emitted] + output.js 8.18 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 13 bytes {3} [rendered] 1 module @@ -292,6 +308,7 @@ chunk {3} output.js (main) 427 bytes [entry] [rendered] > main [2] ./example.js [2] ./example.js 256 bytes {3} [built] [no exports] + single entry .\example.js main [4] ./node_modules/c lazy ^\.\/.*$ 160 bytes {3} [built] import() context lazy c [2] ./example.js 8:8-27 + 1 hidden module @@ -300,13 +317,13 @@ chunk {3} output.js (main) 427 bytes [entry] [rendered] ## Minimized (uglify-js, no zip) ``` -Hash: f2701c90a6d1597932b5 -Version: webpack 3.5.1 +Hash: 99774db1d98bb53fa195 +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 37 bytes 0 [emitted] -1.output.js 36 bytes 1 [emitted] -2.output.js 38 bytes 2 [emitted] - output.js 1.9 kB 3 [emitted] main +0.output.js 77 bytes 0 [emitted] +1.output.js 76 bytes 1 [emitted] +2.output.js 78 bytes 2 [emitted] + output.js 2.05 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 13 bytes {3} [rendered] 1 module @@ -319,6 +336,7 @@ chunk {3} output.js (main) 427 bytes [entry] [rendered] > main [2] ./example.js [2] ./example.js 256 bytes {3} [built] [no exports] + single entry .\example.js main [4] ./node_modules/c lazy ^\.\/.*$ 160 bytes {3} [built] import() context lazy c [2] ./example.js 8:8-27 + 1 hidden module diff --git a/examples/code-splitting-native-import-context-filter/README.md b/examples/code-splitting-native-import-context-filter/README.md index a95103d25..c9e3136ed 100644 --- a/examples/code-splitting-native-import-context-filter/README.md +++ b/examples/code-splitting-native-import-context-filter/README.md @@ -7,8 +7,8 @@ end in `.noimport.js` within the `templates` folder will be bundled. async function getTemplate(templateName) { try { let template = await import( - /* webpackFilter: "\\.js$" */ - /* webpackExclude: "\\.noimport\\.js$" */ + /* webpackInclude: /\.js$/ */ + /* webpackExclude: /\.noimport\.js$/ */ `./templates/${templateName}` ); console.log(template); @@ -50,8 +50,8 @@ export default foo; ``` javascript /******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading -/******/ var parentJsonpFunction = window["webpackJsonp"]; -/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0], moreModules = data[1], executeModules = data[2]; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = [], result; @@ -67,7 +67,7 @@ export default foo; /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); +/******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } @@ -77,11 +77,13 @@ export default foo; /******/ // The module cache /******/ var installedModules = {}; /******/ -/******/ // objects to store loaded and loading chunks +/******/ // object to store loaded and loading chunks /******/ var installedChunks = { /******/ 3: 0 /******/ }; /******/ +/******/ var scheduledModules = []; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ @@ -109,51 +111,59 @@ export default foo; /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // JSONP chunk loading for javascript +/******/ /******/ var installedChunkData = installedChunks[chunkId]; -/******/ if(installedChunkData === 0) { -/******/ return new Promise(function(resolve) { resolve(); }); -/******/ } +/******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ -/******/ // a Promise means "currently loading". -/******/ if(installedChunkData) { -/******/ return installedChunkData[2]; -/******/ } +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); /******/ -/******/ // setup Promise in chunk cache -/******/ var promise = new Promise(function(resolve, reject) { -/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; -/******/ }); -/******/ installedChunkData[2] = promise; +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120000; /******/ -/******/ // start chunk loading -/******/ var head = document.getElementsByTagName('head')[0]; -/******/ var script = document.createElement('script'); -/******/ script.type = 'text/javascript'; -/******/ script.charset = 'utf-8'; -/******/ script.async = true; -/******/ script.timeout = 120000; -/******/ -/******/ if (__webpack_require__.nc) { -/******/ script.setAttribute("nonce", __webpack_require__.nc); -/******/ } -/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; -/******/ var timeout = setTimeout(onScriptComplete, 120000); -/******/ script.onerror = script.onload = onScriptComplete; -/******/ function onScriptComplete() { -/******/ // avoid mem leaks in IE. -/******/ script.onerror = script.onload = null; -/******/ clearTimeout(timeout); -/******/ var chunk = installedChunks[chunkId]; -/******/ if(chunk !== 0) { -/******/ if(chunk) { -/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ installedChunks[chunkId] = undefined; +/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ function onScriptComplete(event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ head.appendChild(script); /******/ } -/******/ }; -/******/ head.appendChild(script); -/******/ -/******/ return promise; +/******/ } +/******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) @@ -191,6 +201,12 @@ export default foo; /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var parentJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 3); /******/ }) @@ -208,13 +224,13 @@ export default foo; /*!********************!*\ !*** ./example.js ***! \********************/ -/*! dynamic exports provided */ +/*! no static exports found */ /*! all exports used */ /***/ (function(module, exports, __webpack_require__) { async function getTemplate(templateName) { try { - let template = await __webpack_require__(/*! ./templates */ 4)(`./${templateName}`); + let template = await __webpack_require__( 4)(`./${templateName}`); console.log(template); } catch(err) { console.error(err); @@ -233,10 +249,10 @@ getTemplate("baz.noimport"); /***/ }), /* 4 */ -/*!*********************************!*\ - !*** ./templates lazy ^\.\/.*$ ***! - \*********************************/ -/*! dynamic exports provided */ +/*!*************************************************************************!*\ + !*** ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ***! + \*************************************************************************/ +/*! no static exports found */ /*! all exports used */ /***/ (function(module, exports, __webpack_require__) { @@ -289,38 +305,70 @@ module.exports = webpackAsyncContext; ## Uncompressed ``` -Hash: 82fef985d9d62b89692a -Version: webpack 3.6.0 +Hash: c26be64a30f40e562b8c +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 444 bytes 0 [emitted] -1.output.js 450 bytes 1 [emitted] -2.output.js 441 bytes 2 [emitted] - output.js 7.16 kB 3 [emitted] main +0.output.js 494 bytes 0 [emitted] +1.output.js 500 bytes 1 [emitted] +2.output.js 491 bytes 2 [emitted] + output.js 7.89 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 41 bytes {3} [rendered] [2] ./templates/foo.js 41 bytes {0} [optional] [built] [exports: default] - context element ./foo.js [4] ./templates lazy ^\.\/.*$ ./foo.js - context element ./foo [4] ./templates lazy ^\.\/.*$ ./foo + context element ./foo.js [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ./foo.js + context element ./foo [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ./foo chunk {1} 1.output.js 41 bytes {3} [rendered] [1] ./templates/baz.js 41 bytes {1} [optional] [built] [exports: default] - context element ./baz.js [4] ./templates lazy ^\.\/.*$ ./baz.js - context element ./baz [4] ./templates lazy ^\.\/.*$ ./baz + context element ./baz.js [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ./baz.js + context element ./baz [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ./baz chunk {2} 2.output.js 41 bytes {3} [rendered] [0] ./templates/bar.js 41 bytes {2} [optional] [built] [exports: default] - context element ./bar.js [4] ./templates lazy ^\.\/.*$ ./bar.js - context element ./bar [4] ./templates lazy ^\.\/.*$ ./bar -chunk {3} output.js (main) 620 bytes [entry] [rendered] + context element ./bar.js [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ./bar.js + context element ./bar [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ./bar +chunk {3} output.js (main) 618 bytes [entry] [rendered] > main [3] ./example.js - [3] ./example.js 460 bytes {3} [built] - [4] ./templates lazy ^\.\/.*$ 160 bytes {3} [optional] [built] + [3] ./example.js 458 bytes {3} [built] + single entry .\example.js main + [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ 160 bytes {3} [optional] [built] import() context lazy ./templates [3] ./example.js 3:23-7:3 ``` ## Minimized (uglify-js, no zip) ``` +Hash: c26be64a30f40e562b8c +Version: webpack next + Asset Size Chunks Chunk Names +0.output.js 157 bytes 0 [emitted] +1.output.js 156 bytes 1 [emitted] +2.output.js 155 bytes 2 [emitted] + output.js 7.47 KiB 3 [emitted] main +Entrypoint main = output.js +chunk {0} 0.output.js 41 bytes {3} [rendered] + [2] ./templates/foo.js 41 bytes {0} [optional] [built] + [exports: default] + context element ./foo.js [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ./foo.js + context element ./foo [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ./foo +chunk {1} 1.output.js 41 bytes {3} [rendered] + [1] ./templates/baz.js 41 bytes {1} [optional] [built] + [exports: default] + context element ./baz.js [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ./baz.js + context element ./baz [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ./baz +chunk {2} 2.output.js 41 bytes {3} [rendered] + [0] ./templates/bar.js 41 bytes {2} [optional] [built] + [exports: default] + context element ./bar.js [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ./bar.js + context element ./bar [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ ./bar +chunk {3} output.js (main) 618 bytes [entry] [rendered] + > main [3] ./example.js + [3] ./example.js 458 bytes {3} [built] + single entry .\example.js main + [4] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ 160 bytes {3} [optional] [built] + import() context lazy ./templates [3] ./example.js 3:23-7:3 +ERROR in output.js from UglifyJs +Unexpected token: keyword (function) [output.js:171,6] ``` diff --git a/examples/code-splitting-native-import-context/README.md b/examples/code-splitting-native-import-context/README.md index e7786bcfa..19443c910 100644 --- a/examples/code-splitting-native-import-context/README.md +++ b/examples/code-splitting-native-import-context/README.md @@ -39,8 +39,8 @@ export default foo; ``` javascript /******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading -/******/ var parentJsonpFunction = window["webpackJsonp"]; -/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0], moreModules = data[1], executeModules = data[2]; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = [], result; @@ -56,7 +56,7 @@ export default foo; /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); +/******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } @@ -66,11 +66,13 @@ export default foo; /******/ // The module cache /******/ var installedModules = {}; /******/ -/******/ // objects to store loaded and loading chunks +/******/ // object to store loaded and loading chunks /******/ var installedChunks = { /******/ 3: 0 /******/ }; /******/ +/******/ var scheduledModules = []; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ @@ -98,51 +100,59 @@ export default foo; /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // JSONP chunk loading for javascript +/******/ /******/ var installedChunkData = installedChunks[chunkId]; -/******/ if(installedChunkData === 0) { -/******/ return new Promise(function(resolve) { resolve(); }); -/******/ } +/******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ -/******/ // a Promise means "currently loading". -/******/ if(installedChunkData) { -/******/ return installedChunkData[2]; -/******/ } +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); /******/ -/******/ // setup Promise in chunk cache -/******/ var promise = new Promise(function(resolve, reject) { -/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; -/******/ }); -/******/ installedChunkData[2] = promise; +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120000; /******/ -/******/ // start chunk loading -/******/ var head = document.getElementsByTagName('head')[0]; -/******/ var script = document.createElement('script'); -/******/ script.type = 'text/javascript'; -/******/ script.charset = 'utf-8'; -/******/ script.async = true; -/******/ script.timeout = 120000; -/******/ -/******/ if (__webpack_require__.nc) { -/******/ script.setAttribute("nonce", __webpack_require__.nc); -/******/ } -/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; -/******/ var timeout = setTimeout(onScriptComplete, 120000); -/******/ script.onerror = script.onload = onScriptComplete; -/******/ function onScriptComplete() { -/******/ // avoid mem leaks in IE. -/******/ script.onerror = script.onload = null; -/******/ clearTimeout(timeout); -/******/ var chunk = installedChunks[chunkId]; -/******/ if(chunk !== 0) { -/******/ if(chunk) { -/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ installedChunks[chunkId] = undefined; +/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ function onScriptComplete(event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ head.appendChild(script); /******/ } -/******/ }; -/******/ head.appendChild(script); -/******/ -/******/ return promise; +/******/ } +/******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) @@ -180,6 +190,12 @@ export default foo; /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var parentJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 3); /******/ }) @@ -203,7 +219,7 @@ export default foo; async function getTemplate(templateName) { try { - let template = await __webpack_require__(/*! ./templates */ 4)(`./${templateName}`); + let template = await __webpack_require__( 4)(`./${templateName}`); console.log(template); } catch(err) { console.error("template error"); @@ -276,13 +292,13 @@ module.exports = webpackAsyncContext; ## Uncompressed ``` -Hash: 6f07710827408f86ab81 -Version: webpack 3.5.1 +Hash: c0e9c43fa1cecd7aab21 +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 444 bytes 0 [emitted] -1.output.js 450 bytes 1 [emitted] -2.output.js 441 bytes 2 [emitted] - output.js 7.08 kB 3 [emitted] main +0.output.js 494 bytes 0 [emitted] +1.output.js 500 bytes 1 [emitted] +2.output.js 491 bytes 2 [emitted] + output.js 7.7 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 41 bytes {3} [rendered] [2] ./templates/foo.js 41 bytes {0} [optional] [built] @@ -302,6 +318,7 @@ chunk {2} 2.output.js 41 bytes {3} [rendered] chunk {3} output.js (main) 456 bytes [entry] [rendered] > main [3] ./example.js [3] ./example.js 296 bytes {3} [built] + single entry .\example.js main [4] ./templates lazy ^\.\/.*$ 160 bytes {3} [optional] [built] import() context lazy ./templates [3] ./example.js 3:23-60 ``` @@ -309,13 +326,13 @@ chunk {3} output.js (main) 456 bytes [entry] [rendered] ## Minimized (uglify-js, no zip) ``` -Hash: 6f07710827408f86ab81 -Version: webpack 3.5.1 +Hash: c0e9c43fa1cecd7aab21 +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 117 bytes 0 [emitted] -1.output.js 116 bytes 1 [emitted] -2.output.js 115 bytes 2 [emitted] - output.js 6.76 kB 3 [emitted] main +0.output.js 157 bytes 0 [emitted] +1.output.js 156 bytes 1 [emitted] +2.output.js 155 bytes 2 [emitted] + output.js 7.4 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 41 bytes {3} [rendered] [2] ./templates/foo.js 41 bytes {0} [optional] [built] @@ -335,9 +352,10 @@ chunk {2} 2.output.js 41 bytes {3} [rendered] chunk {3} output.js (main) 456 bytes [entry] [rendered] > main [3] ./example.js [3] ./example.js 296 bytes {3} [built] + single entry .\example.js main [4] ./templates lazy ^\.\/.*$ 160 bytes {3} [optional] [built] import() context lazy ./templates [3] ./example.js 3:23-60 ERROR in output.js from UglifyJs -Unexpected token: keyword (function) [output.js:155,6] +Unexpected token: keyword (function) [output.js:171,6] ``` diff --git a/examples/code-splitting-specify-chunk-name/README.md b/examples/code-splitting-specify-chunk-name/README.md index 8b2fc93cf..2254415ef 100644 --- a/examples/code-splitting-specify-chunk-name/README.md +++ b/examples/code-splitting-specify-chunk-name/README.md @@ -39,8 +39,8 @@ export default foo; ``` javascript /******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading -/******/ var parentJsonpFunction = window["webpackJsonp"]; -/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0], moreModules = data[1], executeModules = data[2]; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = [], result; @@ -56,7 +56,7 @@ export default foo; /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); +/******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } @@ -66,11 +66,13 @@ export default foo; /******/ // The module cache /******/ var installedModules = {}; /******/ -/******/ // objects to store loaded and loading chunks +/******/ // object to store loaded and loading chunks /******/ var installedChunks = { /******/ 3: 0 /******/ }; /******/ +/******/ var scheduledModules = []; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ @@ -98,51 +100,59 @@ export default foo; /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // JSONP chunk loading for javascript +/******/ /******/ var installedChunkData = installedChunks[chunkId]; -/******/ if(installedChunkData === 0) { -/******/ return new Promise(function(resolve) { resolve(); }); -/******/ } +/******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ -/******/ // a Promise means "currently loading". -/******/ if(installedChunkData) { -/******/ return installedChunkData[2]; -/******/ } +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); /******/ -/******/ // setup Promise in chunk cache -/******/ var promise = new Promise(function(resolve, reject) { -/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; -/******/ }); -/******/ installedChunkData[2] = promise; +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120000; /******/ -/******/ // start chunk loading -/******/ var head = document.getElementsByTagName('head')[0]; -/******/ var script = document.createElement('script'); -/******/ script.type = 'text/javascript'; -/******/ script.charset = 'utf-8'; -/******/ script.async = true; -/******/ script.timeout = 120000; -/******/ -/******/ if (__webpack_require__.nc) { -/******/ script.setAttribute("nonce", __webpack_require__.nc); -/******/ } -/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; -/******/ var timeout = setTimeout(onScriptComplete, 120000); -/******/ script.onerror = script.onload = onScriptComplete; -/******/ function onScriptComplete() { -/******/ // avoid mem leaks in IE. -/******/ script.onerror = script.onload = null; -/******/ clearTimeout(timeout); -/******/ var chunk = installedChunks[chunkId]; -/******/ if(chunk !== 0) { -/******/ if(chunk) { -/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ installedChunks[chunkId] = undefined; +/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ function onScriptComplete(event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ head.appendChild(script); /******/ } -/******/ }; -/******/ head.appendChild(script); -/******/ -/******/ return promise; +/******/ } +/******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) @@ -180,6 +190,12 @@ export default foo; /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var parentJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 3); /******/ }) @@ -201,7 +217,7 @@ export default foo; /*! all exports used */ /***/ (function(module, exports, __webpack_require__) { -__webpack_require__.e/* import() */(0/*! chunk-foo */).then(__webpack_require__.bind(null, /*! ./templates/foo */ 2)).then(function(foo) { +__webpack_require__.e/* import() */(0/*! chunk-foo *//* duplicate */).then(__webpack_require__.bind(null, /*! ./templates/foo */2)).then(function(foo) { console.log('foo:', foo); }) @@ -211,7 +227,7 @@ __webpack_require__.e/* require.ensure */(0/*! chunk-foo1 *//* duplicate */).the }).bind(null, __webpack_require__)).catch(__webpack_require__.oe); var createContextVar = "r"; -__webpack_require__(/*! ./templates */ 4)("./ba" + createContextVar).then(function(bar) { +__webpack_require__( 4)("./ba" + createContextVar).then(function(bar) { console.log('bar:', bar); }) @@ -268,13 +284,13 @@ module.exports = webpackAsyncContext; ## Uncompressed ``` -Hash: 9d034b3ada38a1291aa9 -Version: webpack 3.5.1 +Hash: b9593814353293fefda9 +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 444 bytes 0 [emitted] chunk-foo -1.output.js 450 bytes 1 [emitted] chunk-bar-baz2 -2.output.js 441 bytes 2 [emitted] chunk-bar-baz0 - output.js 7.3 kB 3 [emitted] main +0.output.js 494 bytes 0 [emitted] chunk-foo +1.output.js 500 bytes 1 [emitted] chunk-bar-baz2 +2.output.js 491 bytes 2 [emitted] chunk-bar-baz0 + output.js 7.93 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js (chunk-foo) 41 bytes {3} [rendered] > duplicate chunk-foo [3] ./example.js 1:0-62 @@ -296,6 +312,7 @@ chunk {2} 2.output.js (chunk-bar-baz0) 41 bytes {3} [rendered] chunk {3} output.js (main) 580 bytes [entry] [rendered] > main [3] ./example.js [3] ./example.js 420 bytes {3} [built] + single entry .\example.js main [4] ./templates lazy ^\.\/ba.*$ 160 bytes {3} [built] import() context lazy ./templates [3] ./example.js 11:0-84 ``` @@ -303,13 +320,13 @@ chunk {3} output.js (main) 580 bytes [entry] [rendered] ## Minimized (uglify-js, no zip) ``` -Hash: 9d034b3ada38a1291aa9 -Version: webpack 3.5.1 +Hash: b9593814353293fefda9 +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 117 bytes 0 [emitted] chunk-foo -1.output.js 116 bytes 1 [emitted] chunk-bar-baz2 -2.output.js 115 bytes 2 [emitted] chunk-bar-baz0 - output.js 1.83 kB 3 [emitted] main +0.output.js 157 bytes 0 [emitted] chunk-foo +1.output.js 156 bytes 1 [emitted] chunk-bar-baz2 +2.output.js 155 bytes 2 [emitted] chunk-bar-baz0 + output.js 1.99 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js (chunk-foo) 41 bytes {3} [rendered] > duplicate chunk-foo [3] ./example.js 1:0-62 @@ -331,6 +348,7 @@ chunk {2} 2.output.js (chunk-bar-baz0) 41 bytes {3} [rendered] chunk {3} output.js (main) 580 bytes [entry] [rendered] > main [3] ./example.js [3] ./example.js 420 bytes {3} [built] + single entry .\example.js main [4] ./templates lazy ^\.\/ba.*$ 160 bytes {3} [built] import() context lazy ./templates [3] ./example.js 11:0-84 ``` diff --git a/examples/code-splitting/README.md b/examples/code-splitting/README.md index ea56da7dd..9d337c680 100644 --- a/examples/code-splitting/README.md +++ b/examples/code-splitting/README.md @@ -43,8 +43,8 @@ require.ensure(["c"], function(require) { ``` javascript /******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading -/******/ var parentJsonpFunction = window["webpackJsonp"]; -/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0], moreModules = data[1], executeModules = data[2]; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = [], result; @@ -60,7 +60,7 @@ require.ensure(["c"], function(require) { /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); +/******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } @@ -70,11 +70,13 @@ require.ensure(["c"], function(require) { /******/ // The module cache /******/ var installedModules = {}; /******/ -/******/ // objects to store loaded and loading chunks +/******/ // object to store loaded and loading chunks /******/ var installedChunks = { /******/ 1: 0 /******/ }; /******/ +/******/ var scheduledModules = []; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ @@ -102,51 +104,59 @@ require.ensure(["c"], function(require) { /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // JSONP chunk loading for javascript +/******/ /******/ var installedChunkData = installedChunks[chunkId]; -/******/ if(installedChunkData === 0) { -/******/ return new Promise(function(resolve) { resolve(); }); -/******/ } +/******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ -/******/ // a Promise means "currently loading". -/******/ if(installedChunkData) { -/******/ return installedChunkData[2]; -/******/ } +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); /******/ -/******/ // setup Promise in chunk cache -/******/ var promise = new Promise(function(resolve, reject) { -/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; -/******/ }); -/******/ installedChunkData[2] = promise; +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120000; /******/ -/******/ // start chunk loading -/******/ var head = document.getElementsByTagName('head')[0]; -/******/ var script = document.createElement('script'); -/******/ script.type = 'text/javascript'; -/******/ script.charset = 'utf-8'; -/******/ script.async = true; -/******/ script.timeout = 120000; -/******/ -/******/ if (__webpack_require__.nc) { -/******/ script.setAttribute("nonce", __webpack_require__.nc); -/******/ } -/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; -/******/ var timeout = setTimeout(onScriptComplete, 120000); -/******/ script.onerror = script.onload = onScriptComplete; -/******/ function onScriptComplete() { -/******/ // avoid mem leaks in IE. -/******/ script.onerror = script.onload = null; -/******/ clearTimeout(timeout); -/******/ var chunk = installedChunks[chunkId]; -/******/ if(chunk !== 0) { -/******/ if(chunk) { -/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ installedChunks[chunkId] = undefined; +/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ function onScriptComplete(event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ head.appendChild(script); /******/ } -/******/ }; -/******/ head.appendChild(script); -/******/ -/******/ return promise; +/******/ } +/******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) @@ -184,6 +194,12 @@ require.ensure(["c"], function(require) { /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var parentJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 1); /******/ }) @@ -238,7 +254,7 @@ __webpack_require__.e/* require.ensure */(0).then((function(require) { # js/0.output.js ``` javascript -webpackJsonp([0],[ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[ /* 0 */, /* 1 */, /* 2 */, @@ -264,13 +280,13 @@ webpackJsonp([0],[ // module d /***/ }) -]); +]]); ``` Minimized ``` javascript -webpackJsonp([0],[,,,function(n,c){},function(n,c){}]); +(window.webpackJsonp=window.webpackJsonp||[]).push([[0],[,,,function(n,o){},function(n,o){}]]); ``` # Info @@ -278,11 +294,11 @@ webpackJsonp([0],[,,,function(n,c){},function(n,c){}]); ## Uncompressed ``` -Hash: 6a2e963878a958fd1aca -Version: webpack 3.5.1 +Hash: 23b9593edef76f47cb63 +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 488 bytes 0 [emitted] - output.js 6.66 kB 1 [emitted] main +0.output.js 538 bytes 0 [emitted] + output.js 7.31 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 22 bytes {1} [rendered] > [1] ./example.js 3:0-6:2 @@ -290,17 +306,18 @@ chunk {0} 0.output.js 22 bytes {1} [rendered] chunk {1} output.js (main) 166 bytes [entry] [rendered] > main [1] ./example.js [1] ./example.js 144 bytes {1} [built] + single entry .\example.js main + 2 hidden modules ``` ## Minimized (uglify-js, no zip) ``` -Hash: 6a2e963878a958fd1aca -Version: webpack 3.5.1 +Hash: 23b9593edef76f47cb63 +Version: webpack next Asset Size Chunks Chunk Names -0.output.js 55 bytes 0 [emitted] - output.js 1.45 kB 1 [emitted] main +0.output.js 95 bytes 0 [emitted] + output.js 1.62 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 22 bytes {1} [rendered] > [1] ./example.js 3:0-6:2 @@ -308,5 +325,6 @@ chunk {0} 0.output.js 22 bytes {1} [rendered] chunk {1} output.js (main) 166 bytes [entry] [rendered] > main [1] ./example.js [1] ./example.js 144 bytes {1} [built] + single entry .\example.js main + 2 hidden modules ``` diff --git a/examples/coffee-script/README.md b/examples/coffee-script/README.md index be118ac76..345deb399 100644 --- a/examples/coffee-script/README.md +++ b/examples/coffee-script/README.md @@ -149,10 +149,10 @@ module.exports = { ## Uncompressed ``` -Hash: 22e68923dcce75e38966 -Version: webpack 3.5.1 - Asset Size Chunks Chunk Names -output.js 3.29 kB 0 [emitted] main +Hash: 0a5ced711d4abc81fdd4 +Version: webpack next + Asset Size Chunks Chunk Names +output.js 3.22 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 206 bytes [entry] [rendered] > main [1] ./example.js @@ -160,6 +160,7 @@ chunk {0} output.js (main) 206 bytes [entry] [rendered] cjs require ./cup2.coffee [2] ./cup1.coffee 4:12-36 cjs require ./cup2 [2] ./cup1.coffee 5:9-26 [1] ./example.js 31 bytes {0} [built] + single entry .\example.js main [2] ./cup1.coffee 118 bytes {0} [built] cjs require ./cup1 [1] ./example.js 1:12-29 ``` @@ -167,8 +168,8 @@ chunk {0} output.js (main) 206 bytes [entry] [rendered] ## Minimized (uglify-js, no zip) ``` -Hash: 22e68923dcce75e38966 -Version: webpack 3.5.1 +Hash: 0a5ced711d4abc81fdd4 +Version: webpack next Asset Size Chunks Chunk Names output.js 640 bytes 0 [emitted] main Entrypoint main = output.js @@ -178,6 +179,7 @@ chunk {0} output.js (main) 206 bytes [entry] [rendered] cjs require ./cup2.coffee [2] ./cup1.coffee 4:12-36 cjs require ./cup2 [2] ./cup1.coffee 5:9-26 [1] ./example.js 31 bytes {0} [built] + single entry .\example.js main [2] ./cup1.coffee 118 bytes {0} [built] cjs require ./cup1 [1] ./example.js 1:12-29 ``` \ No newline at end of file diff --git a/examples/common-chunk-and-vendor-chunk/README.md b/examples/common-chunk-and-vendor-chunk/README.md index 5166915d6..4cba9f3db 100644 --- a/examples/common-chunk-and-vendor-chunk/README.md +++ b/examples/common-chunk-and-vendor-chunk/README.md @@ -67,8 +67,8 @@ module.exports = { ``` javascript /******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading -/******/ var parentJsonpFunction = window["webpackJsonp"]; -/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0], moreModules = data[1], executeModules = data[2]; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = [], result; @@ -84,13 +84,22 @@ module.exports = { /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); +/******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } -/******/ if(executeModules) { -/******/ for(i=0; i < executeModules.length; i++) { -/******/ result = __webpack_require__(__webpack_require__.s = executeModules[i]); +/******/ scheduledModules.push.apply(scheduledModules, executeModules || []); +/******/ +/******/ for(i = 0; i < scheduledModules.length; i++) { +/******/ var scheduledModule = scheduledModules[i]; +/******/ var fullfilled = true; +/******/ for(var j = 1; j < scheduledModule.length; j++) { +/******/ var depId = scheduledModule[j]; +/******/ if(installedChunks[depId] !== 0) fullfilled = false; +/******/ } +/******/ if(fullfilled) { +/******/ scheduledModules.splice(i--, 1); +/******/ result = __webpack_require__(__webpack_require__.s = scheduledModule[0]); /******/ } /******/ } /******/ return result; @@ -99,11 +108,13 @@ module.exports = { /******/ // The module cache /******/ var installedModules = {}; /******/ -/******/ // objects to store loaded and loading chunks +/******/ // object to store loaded and loading chunks /******/ var installedChunks = { /******/ 4: 0 /******/ }; /******/ +/******/ var scheduledModules = []; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ @@ -131,51 +142,59 @@ module.exports = { /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // JSONP chunk loading for javascript +/******/ /******/ var installedChunkData = installedChunks[chunkId]; -/******/ if(installedChunkData === 0) { -/******/ return new Promise(function(resolve) { resolve(); }); -/******/ } +/******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ -/******/ // a Promise means "currently loading". -/******/ if(installedChunkData) { -/******/ return installedChunkData[2]; -/******/ } +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); /******/ -/******/ // setup Promise in chunk cache -/******/ var promise = new Promise(function(resolve, reject) { -/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; -/******/ }); -/******/ installedChunkData[2] = promise; +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120000; /******/ -/******/ // start chunk loading -/******/ var head = document.getElementsByTagName('head')[0]; -/******/ var script = document.createElement('script'); -/******/ script.type = 'text/javascript'; -/******/ script.charset = 'utf-8'; -/******/ script.async = true; -/******/ script.timeout = 120000; -/******/ -/******/ if (__webpack_require__.nc) { -/******/ script.setAttribute("nonce", __webpack_require__.nc); -/******/ } -/******/ script.src = __webpack_require__.p + "" + chunkId + ".js"; -/******/ var timeout = setTimeout(onScriptComplete, 120000); -/******/ script.onerror = script.onload = onScriptComplete; -/******/ function onScriptComplete() { -/******/ // avoid mem leaks in IE. -/******/ script.onerror = script.onload = null; -/******/ clearTimeout(timeout); -/******/ var chunk = installedChunks[chunkId]; -/******/ if(chunk !== 0) { -/******/ if(chunk) { -/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ installedChunks[chunkId] = undefined; +/******/ script.src = __webpack_require__.p + "" + chunkId + ".js"; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ function onScriptComplete(event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ head.appendChild(script); /******/ } -/******/ }; -/******/ head.appendChild(script); -/******/ -/******/ return promise; +/******/ } +/******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) @@ -213,6 +232,12 @@ module.exports = { /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var parentJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 2); /******/ }) @@ -266,7 +291,7 @@ module.exports = "vendor2"; # js/common.js ``` javascript -webpackJsonp([0],[ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[ /* 0 */ /*!*********************!*\ !*** ./utility2.js ***! @@ -289,13 +314,13 @@ module.exports = "utility2"; module.exports = "utility3"; /***/ }) -]); +]]); ``` # js/pageA.js ``` javascript -webpackJsonp([1],{ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],{ /***/ 5: /*!******************!*\ @@ -324,13 +349,13 @@ module.exports = "utility1"; /***/ }) -},[5]); +},[[5,4,0,1]]]); ``` # js/pageB.js ``` javascript -webpackJsonp([3],{ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[3],{ /***/ 7: /*!******************!*\ @@ -347,13 +372,13 @@ module.exports = "pageB"; /***/ }) -},[7]); +},[[7,4,0,3]]]); ``` # js/pageC.js ``` javascript -webpackJsonp([2],{ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[2],{ /***/ 8: /*!******************!*\ @@ -370,7 +395,7 @@ module.exports = "pageC"; /***/ }) -},[8]); +},[[8,4,0,2]]]); ``` # Info @@ -378,14 +403,14 @@ module.exports = "pageC"; ## Uncompressed ``` -Hash: 3b80b7c17398c31e4705 -Version: webpack 3.5.1 +Hash: 4b8ef245065d9c193fc3 +Version: webpack next Asset Size Chunks Chunk Names -common.js 459 bytes 0 [emitted] common - pageA.js 595 bytes 1 [emitted] pageA - pageC.js 374 bytes 2 [emitted] pageC - pageB.js 374 bytes 3 [emitted] pageB -vendor.js 6.7 kB 4 [emitted] vendor +common.js 509 bytes 0 [emitted] common + pageA.js 653 bytes 1 [emitted] pageA + pageC.js 432 bytes 2 [emitted] pageC + pageB.js 432 bytes 3 [emitted] pageB +vendor.js 7.75 KiB 4 [emitted] vendor Entrypoint vendor = vendor.js Entrypoint pageA = vendor.js common.js pageA.js Entrypoint pageB = vendor.js common.js pageB.js @@ -401,17 +426,21 @@ chunk {0} common.js (common) 56 bytes {4} [initial] [rendered] chunk {1} pageA.js (pageA) 133 bytes {0} [initial] [rendered] > pageA [5] ./pageA.js [5] ./pageA.js 105 bytes {1} [built] + single entry ./pageA pageA [6] ./utility1.js 28 bytes {1} [built] cjs require ./utility1 [5] ./pageA.js 1:15-36 chunk {2} pageC.js (pageC) 105 bytes {0} [initial] [rendered] > pageC [8] ./pageC.js [8] ./pageC.js 105 bytes {2} [built] + single entry ./pageC pageC chunk {3} pageB.js (pageB) 105 bytes {0} [initial] [rendered] > pageB [7] ./pageB.js [7] ./pageB.js 105 bytes {3} [built] + single entry ./pageB pageB chunk {4} vendor.js (vendor) 94 bytes [entry] [rendered] > vendor [2] multi ./vendor1 ./vendor2 [2] multi ./vendor1 ./vendor2 40 bytes {4} [built] + multi entry [3] ./vendor1.js 27 bytes {4} [built] single entry ./vendor1 [2] multi ./vendor1 ./vendor2 vendor:100000 [4] ./vendor2.js 27 bytes {4} [built] @@ -421,14 +450,14 @@ chunk {4} vendor.js (vendor) 94 bytes [entry] [rendered] ## Minimized (uglify-js, no zip) ``` -Hash: 3b80b7c17398c31e4705 -Version: webpack 3.5.1 +Hash: 4b8ef245065d9c193fc3 +Version: webpack next Asset Size Chunks Chunk Names -common.js 92 bytes 0 [emitted] common - pageA.js 109 bytes 1 [emitted] pageA - pageC.js 71 bytes 2 [emitted] pageC - pageB.js 71 bytes 3 [emitted] pageB -vendor.js 1.48 kB 4 [emitted] vendor +common.js 132 bytes 0 [emitted] common + pageA.js 157 bytes 1 [emitted] pageA + pageC.js 119 bytes 2 [emitted] pageC + pageB.js 119 bytes 3 [emitted] pageB +vendor.js 1.75 KiB 4 [emitted] vendor Entrypoint vendor = vendor.js Entrypoint pageA = vendor.js common.js pageA.js Entrypoint pageB = vendor.js common.js pageB.js @@ -444,17 +473,21 @@ chunk {0} common.js (common) 56 bytes {4} [initial] [rendered] chunk {1} pageA.js (pageA) 133 bytes {0} [initial] [rendered] > pageA [5] ./pageA.js [5] ./pageA.js 105 bytes {1} [built] + single entry ./pageA pageA [6] ./utility1.js 28 bytes {1} [built] cjs require ./utility1 [5] ./pageA.js 1:15-36 chunk {2} pageC.js (pageC) 105 bytes {0} [initial] [rendered] > pageC [8] ./pageC.js [8] ./pageC.js 105 bytes {2} [built] + single entry ./pageC pageC chunk {3} pageB.js (pageB) 105 bytes {0} [initial] [rendered] > pageB [7] ./pageB.js [7] ./pageB.js 105 bytes {3} [built] + single entry ./pageB pageB chunk {4} vendor.js (vendor) 94 bytes [entry] [rendered] > vendor [2] multi ./vendor1 ./vendor2 [2] multi ./vendor1 ./vendor2 40 bytes {4} [built] + multi entry [3] ./vendor1.js 27 bytes {4} [built] single entry ./vendor1 [2] multi ./vendor1 ./vendor2 vendor:100000 [4] ./vendor2.js 27 bytes {4} [built] diff --git a/examples/common-chunk-grandchildren/README.md b/examples/common-chunk-grandchildren/README.md index 3ee56bfb6..7073b5490 100644 --- a/examples/common-chunk-grandchildren/README.md +++ b/examples/common-chunk-grandchildren/README.md @@ -132,8 +132,8 @@ module.exports = [ ``` javascript /******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading -/******/ var parentJsonpFunction = window["webpackJsonp"]; -/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0], moreModules = data[1], executeModules = data[2]; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = [], result; @@ -149,7 +149,7 @@ module.exports = [ /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); +/******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } @@ -159,11 +159,13 @@ module.exports = [ /******/ // The module cache /******/ var installedModules = {}; /******/ -/******/ // objects to store loaded and loading chunks +/******/ // object to store loaded and loading chunks /******/ var installedChunks = { /******/ 3: 0 /******/ }; /******/ +/******/ var scheduledModules = []; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ @@ -191,51 +193,59 @@ module.exports = [ /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // JSONP chunk loading for javascript +/******/ /******/ var installedChunkData = installedChunks[chunkId]; -/******/ if(installedChunkData === 0) { -/******/ return new Promise(function(resolve) { resolve(); }); -/******/ } +/******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ -/******/ // a Promise means "currently loading". -/******/ if(installedChunkData) { -/******/ return installedChunkData[2]; -/******/ } +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); /******/ -/******/ // setup Promise in chunk cache -/******/ var promise = new Promise(function(resolve, reject) { -/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; -/******/ }); -/******/ installedChunkData[2] = promise; +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120000; /******/ -/******/ // start chunk loading -/******/ var head = document.getElementsByTagName('head')[0]; -/******/ var script = document.createElement('script'); -/******/ script.type = 'text/javascript'; -/******/ script.charset = 'utf-8'; -/******/ script.async = true; -/******/ script.timeout = 120000; -/******/ -/******/ if (__webpack_require__.nc) { -/******/ script.setAttribute("nonce", __webpack_require__.nc); -/******/ } -/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; -/******/ var timeout = setTimeout(onScriptComplete, 120000); -/******/ script.onerror = script.onload = onScriptComplete; -/******/ function onScriptComplete() { -/******/ // avoid mem leaks in IE. -/******/ script.onerror = script.onload = null; -/******/ clearTimeout(timeout); -/******/ var chunk = installedChunks[chunkId]; -/******/ if(chunk !== 0) { -/******/ if(chunk) { -/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ installedChunks[chunkId] = undefined; +/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js"; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ function onScriptComplete(event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ head.appendChild(script); /******/ } -/******/ }; -/******/ head.appendChild(script); -/******/ -/******/ return promise; +/******/ } +/******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) @@ -273,6 +283,12 @@ module.exports = [ /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var parentJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) @@ -339,7 +355,7 @@ module.exports = function() { # js/0.output.js ``` javascript -webpackJsonp([0],{ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],{ /***/ 5: /*!******************!*\ @@ -359,13 +375,13 @@ module.exports = function() { /***/ }) -}); +}]); ``` # js/1.output.js ``` javascript -webpackJsonp([1],{ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],{ /***/ 4: /*!******************!*\ @@ -386,13 +402,13 @@ module.exports = function() { /***/ }) -}); +}]); ``` # js/2.output.js ``` javascript -webpackJsonp([2],{ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[2],{ /***/ 3: /*!******************!*\ @@ -412,7 +428,7 @@ module.exports = function() { /***/ }) -}); +}]); ``` # js/asyncoutput.js @@ -420,8 +436,8 @@ module.exports = function() { ``` javascript /******/ (function(modules) { // webpackBootstrap /******/ // install a JSONP callback for chunk loading -/******/ var parentJsonpFunction = window["webpackJsonp"]; -/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) { +/******/ function webpackJsonpCallback(data) { +/******/ var chunkIds = data[0], moreModules = data[1], executeModules = data[2]; /******/ // add "moreModules" to the modules object, /******/ // then flag all "chunkIds" as loaded and fire callback /******/ var moduleId, chunkId, i = 0, resolves = [], result; @@ -437,7 +453,7 @@ module.exports = function() { /******/ modules[moduleId] = moreModules[moduleId]; /******/ } /******/ } -/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules); +/******/ if(parentJsonpFunction) parentJsonpFunction(data); /******/ while(resolves.length) { /******/ resolves.shift()(); /******/ } @@ -447,11 +463,13 @@ module.exports = function() { /******/ // The module cache /******/ var installedModules = {}; /******/ -/******/ // objects to store loaded and loading chunks +/******/ // object to store loaded and loading chunks /******/ var installedChunks = { /******/ 4: 0 /******/ }; /******/ +/******/ var scheduledModules = []; +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ @@ -479,51 +497,59 @@ module.exports = function() { /******/ // This file contains only the entry chunk. /******/ // The chunk loading function for additional chunks /******/ __webpack_require__.e = function requireEnsure(chunkId) { +/******/ var promises = []; +/******/ +/******/ +/******/ // JSONP chunk loading for javascript +/******/ /******/ var installedChunkData = installedChunks[chunkId]; -/******/ if(installedChunkData === 0) { -/******/ return new Promise(function(resolve) { resolve(); }); -/******/ } +/******/ if(installedChunkData !== 0) { // 0 means "already installed". /******/ -/******/ // a Promise means "currently loading". -/******/ if(installedChunkData) { -/******/ return installedChunkData[2]; -/******/ } +/******/ // a Promise means "currently loading". +/******/ if(installedChunkData) { +/******/ promises.push(installedChunkData[2]); +/******/ } else { +/******/ // setup Promise in chunk cache +/******/ var promise = new Promise(function(resolve, reject) { +/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; +/******/ }); +/******/ promises.push(installedChunkData[2] = promise); /******/ -/******/ // setup Promise in chunk cache -/******/ var promise = new Promise(function(resolve, reject) { -/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject]; -/******/ }); -/******/ installedChunkData[2] = promise; +/******/ // start chunk loading +/******/ var head = document.getElementsByTagName('head')[0]; +/******/ var script = document.createElement('script'); +/******/ script.charset = 'utf-8'; +/******/ script.timeout = 120000; /******/ -/******/ // start chunk loading -/******/ var head = document.getElementsByTagName('head')[0]; -/******/ var script = document.createElement('script'); -/******/ script.type = 'text/javascript'; -/******/ script.charset = 'utf-8'; -/******/ script.async = true; -/******/ script.timeout = 120000; -/******/ -/******/ if (__webpack_require__.nc) { -/******/ script.setAttribute("nonce", __webpack_require__.nc); -/******/ } -/******/ script.src = __webpack_require__.p + "" + chunkId + ".asyncoutput.js"; -/******/ var timeout = setTimeout(onScriptComplete, 120000); -/******/ script.onerror = script.onload = onScriptComplete; -/******/ function onScriptComplete() { -/******/ // avoid mem leaks in IE. -/******/ script.onerror = script.onload = null; -/******/ clearTimeout(timeout); -/******/ var chunk = installedChunks[chunkId]; -/******/ if(chunk !== 0) { -/******/ if(chunk) { -/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.')); +/******/ if (__webpack_require__.nc) { +/******/ script.setAttribute("nonce", __webpack_require__.nc); /******/ } -/******/ installedChunks[chunkId] = undefined; +/******/ script.src = __webpack_require__.p + "" + chunkId + ".asyncoutput.js"; +/******/ var timeout = setTimeout(function(){ +/******/ onScriptComplete({ type: 'timeout', target: script }); +/******/ }, 120000); +/******/ script.onerror = script.onload = onScriptComplete; +/******/ function onScriptComplete(event) { +/******/ // avoid mem leaks in IE. +/******/ script.onerror = script.onload = null; +/******/ clearTimeout(timeout); +/******/ var chunk = installedChunks[chunkId]; +/******/ if(chunk !== 0) { +/******/ if(chunk) { +/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type); +/******/ var realSrc = event && event.target && event.target.src; +/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')'); +/******/ error.type = errorType; +/******/ error.request = realSrc; +/******/ chunk[1](error); +/******/ } +/******/ installedChunks[chunkId] = undefined; +/******/ } +/******/ }; +/******/ head.appendChild(script); /******/ } -/******/ }; -/******/ head.appendChild(script); -/******/ -/******/ return promise; +/******/ } +/******/ return Promise.all(promises); /******/ }; /******/ /******/ // expose the modules object (__webpack_modules__) @@ -561,6 +587,12 @@ module.exports = function() { /******/ // on error function for async loading /******/ __webpack_require__.oe = function(err) { console.error(err); throw err; }; /******/ +/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || []; +/******/ var parentJsonpFunction = jsonpArray.push.bind(jsonpArray); +/******/ jsonpArray.push = webpackJsonpCallback; +/******/ jsonpArray = jsonpArray.slice(); +/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); +/******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) @@ -608,7 +640,7 @@ main(); # js/0.asyncoutput.js ``` javascript -webpackJsonp([0],{ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],{ /***/ 4: /*!******************************!*\ @@ -625,13 +657,13 @@ module.exports = function() { /***/ }) -}); +}]); ``` # js/1.asyncoutput.js ``` javascript -webpackJsonp([1],{ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],{ /***/ 3: /*!******************!*\ @@ -652,13 +684,13 @@ module.exports = function() { /***/ }) -}); +}]); ``` # js/2.asyncoutput.js ``` javascript -webpackJsonp([2],{ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[2],{ /***/ 2: /*!******************!*\ @@ -678,13 +710,13 @@ module.exports = function() { /***/ }) -}); +}]); ``` # js/3.asyncoutput.js ``` javascript -webpackJsonp([3],{ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[3],{ /***/ 5: /*!******************!*\ @@ -704,7 +736,7 @@ module.exports = function() { /***/ }) -}); +}]); ``` # Info @@ -712,15 +744,15 @@ module.exports = function() { ## Uncompressed ``` -Hash: 777f989f517d7831d56f1d268f47bc8703ad9f73 -Version: webpack 3.6.0 +Hash: 3d3c887e038c22d66243e918fbcaa3ff1f847528 +Version: webpack next Child - Hash: 777f989f517d7831d56f + Hash: 3d3c887e038c22d66243 Asset Size Chunks Chunk Names - 0.output.js 388 bytes 0 [emitted] - 1.output.js 481 bytes 1 [emitted] - 2.output.js 388 bytes 2 [emitted] - output.js 6.95 kB 3 [emitted] main + 0.output.js 438 bytes 0 [emitted] + 1.output.js 531 bytes 1 [emitted] + 2.output.js 438 bytes 2 [emitted] + output.js 7.59 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 142 bytes {3} [rendered] > [4] ./pageB.js 3:1-6:3 @@ -737,19 +769,20 @@ Child chunk {3} output.js (main) 333 bytes [entry] [rendered] > main [0] multi ./example.js [0] multi ./example.js 28 bytes {3} [built] + multi entry [1] ./example.js 233 bytes {3} [built] single entry ./example.js [0] multi ./example.js main:100000 [2] ./reusableComponent.js 72 bytes {3} [built] cjs require ./reusableComponent [3] ./pageA.js 1:24-54 cjs require ./reusableComponent [5] ./pageC.js 1:24-54 Child - Hash: 1d268f47bc8703ad9f73 + Hash: e918fbcaa3ff1f847528 Asset Size Chunks Chunk Names - 0.asyncoutput.js 314 bytes 0 [emitted] - 1.asyncoutput.js 522 bytes 1 [emitted] - 2.asyncoutput.js 388 bytes 2 [emitted] - 3.asyncoutput.js 388 bytes 3 [emitted] - asyncoutput.js 6.7 kB 4 [emitted] main + 0.asyncoutput.js 364 bytes 0 [emitted] + 1.asyncoutput.js 572 bytes 1 [emitted] + 2.asyncoutput.js 438 bytes 2 [emitted] + 3.asyncoutput.js 438 bytes 3 [emitted] + asyncoutput.js 7.35 KiB 4 [emitted] main Entrypoint main = asyncoutput.js chunk {0} 0.asyncoutput.js 72 bytes {4} [rendered] > async commons [1] ./example.js 3:1-6:3 @@ -772,6 +805,7 @@ Child chunk {4} asyncoutput.js (main) 261 bytes [entry] [rendered] > main [0] multi ./example.js [0] multi ./example.js 28 bytes {4} [built] + multi entry [1] ./example.js 233 bytes {4} [built] single entry ./example.js [0] multi ./example.js main:100000 ``` @@ -779,15 +813,15 @@ Child ## Minimized (uglify-js, no zip) ``` -Hash: 777f989f517d7831d56f1d268f47bc8703ad9f73 -Version: webpack 3.6.0 +Hash: 3d3c887e038c22d66243e918fbcaa3ff1f847528 +Version: webpack next Child - Hash: 777f989f517d7831d56f + Hash: 3d3c887e038c22d66243 Asset Size Chunks Chunk Names - 0.output.js 98 bytes 0 [emitted] - 1.output.js 340 bytes 1 [emitted] - 2.output.js 98 bytes 2 [emitted] - output.js 6.46 kB 3 [emitted] main + 0.output.js 138 bytes 0 [emitted] + 1.output.js 390 bytes 1 [emitted] + 2.output.js 138 bytes 2 [emitted] + output.js 7.11 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 142 bytes {3} [rendered] > [4] ./pageB.js 3:1-6:3 @@ -804,6 +838,7 @@ Child chunk {3} output.js (main) 333 bytes [entry] [rendered] > main [0] multi ./example.js [0] multi ./example.js 28 bytes {3} [built] + multi entry [1] ./example.js 233 bytes {3} [built] single entry ./example.js [0] multi ./example.js main:100000 [2] ./reusableComponent.js 72 bytes {3} [built] @@ -814,15 +849,15 @@ Child Unexpected token: punc ()) [1.output.js:8,53] ERROR in output.js from UglifyJs - Unexpected token: punc ()) [output.js:161,53] + Unexpected token: punc ()) [output.js:177,53] Child - Hash: 1d268f47bc8703ad9f73 + Hash: e918fbcaa3ff1f847528 Asset Size Chunks Chunk Names - 0.asyncoutput.js 93 bytes 0 [emitted] - 1.asyncoutput.js 381 bytes 1 [emitted] - 2.asyncoutput.js 98 bytes 2 [emitted] - 3.asyncoutput.js 98 bytes 3 [emitted] - asyncoutput.js 6.37 kB 4 [emitted] main + 0.asyncoutput.js 133 bytes 0 [emitted] + 1.asyncoutput.js 431 bytes 1 [emitted] + 2.asyncoutput.js 138 bytes 2 [emitted] + 3.asyncoutput.js 138 bytes 3 [emitted] + asyncoutput.js 7.03 KiB 4 [emitted] main Entrypoint main = asyncoutput.js chunk {0} 0.asyncoutput.js 72 bytes {4} [rendered] > async commons [1] ./example.js 3:1-6:3 @@ -845,6 +880,7 @@ Child chunk {4} asyncoutput.js (main) 261 bytes [entry] [rendered] > main [0] multi ./example.js [0] multi ./example.js 28 bytes {4} [built] + multi entry [1] ./example.js 233 bytes {4} [built] single entry ./example.js [0] multi ./example.js main:100000 @@ -852,5 +888,5 @@ Child Unexpected token: punc ()) [1.asyncoutput.js:8,94] ERROR in asyncoutput.js from UglifyJs - Unexpected token: punc ()) [asyncoutput.js:161,94] + Unexpected token: punc ()) [asyncoutput.js:177,94] ``` diff --git a/examples/commonjs/README.md b/examples/commonjs/README.md index 46766fcd7..c6d07e349 100644 --- a/examples/commonjs/README.md +++ b/examples/commonjs/README.md @@ -163,14 +163,15 @@ exports.add = function() { ## Uncompressed ``` -Hash: 9407d8cd068b1845b368 -Version: webpack 3.5.1 - Asset Size Chunks Chunk Names -output.js 3.39 kB 0 [emitted] main +Hash: ae7172392c4d0e31a2b7 +Version: webpack next + Asset Size Chunks Chunk Names +output.js 3.31 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 329 bytes [entry] [rendered] > main [0] ./example.js [0] ./example.js 69 bytes {0} [built] + single entry .\example.js main [1] ./increment.js 98 bytes {0} [built] cjs require ./increment [0] ./example.js 1:10-32 [2] ./math.js 162 bytes {0} [built] @@ -180,14 +181,15 @@ chunk {0} output.js (main) 329 bytes [entry] [rendered] ## Minimized (uglify-js, no zip) ``` -Hash: 9407d8cd068b1845b368 -Version: webpack 3.5.1 +Hash: ae7172392c4d0e31a2b7 +Version: webpack next Asset Size Chunks Chunk Names output.js 672 bytes 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 329 bytes [entry] [rendered] > main [0] ./example.js [0] ./example.js 69 bytes {0} [built] + single entry .\example.js main [1] ./increment.js 98 bytes {0} [built] cjs require ./increment [0] ./example.js 1:10-32 [2] ./math.js 162 bytes {0} [built] diff --git a/examples/css-bundle/README.md b/examples/css-bundle/README.md index 565abb02f..28431ed37 100644 --- a/examples/css-bundle/README.md +++ b/examples/css-bundle/README.md @@ -16,10 +16,11 @@ body { # webpack.config.js ``` javascript -var ExtractTextPlugin = require("extract-text-webpack-plugin"); +const LoaderOptionsPlugin = require("../../lib/LoaderOptionsPlugin"); +const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { module: { - loaders: [ + rules: [ { test: /\.css$/, use: ExtractTextPlugin.extract({ @@ -33,6 +34,10 @@ module.exports = { new ExtractTextPlugin({ filename: "style.css", allChunks: true + }), + // Temporary workaround for the file-loader + new LoaderOptionsPlugin({ + options: {} }) ] }; @@ -152,25 +157,27 @@ body { ## Uncompressed ``` -Hash: d3955970c7b0655c299a -Version: webpack 3.5.1 +Hash: da73f4cbdaa662283746 +Version: webpack next Asset Size Chunks Chunk Names ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted] - output.js 2.9 kB 0 [emitted] main + output.js 2.83 KiB 0 [emitted] main style.css 69 bytes 0 [emitted] main Entrypoint main = output.js style.css chunk {0} output.js, style.css (main) 64 bytes [entry] [rendered] > main [0] ./example.js [0] ./example.js 23 bytes {0} [built] + single entry .\example.js main [1] ./style.css 41 bytes {0} [built] cjs require ./style.css [0] ./example.js 1:0-22 Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!style.css: Asset Size Chunks Chunk Names ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted] Entrypoint undefined = extract-text-webpack-plugin-output-filename - chunk {0} extract-text-webpack-plugin-output-filename 2.57 kB [entry] [rendered] + chunk {0} extract-text-webpack-plugin-output-filename 2.51 KiB [entry] [rendered] > [0] (webpack)/node_modules/css-loader!./style.css [0] (webpack)/node_modules/css-loader!./style.css 231 bytes {0} [built] + single entry !!(webpack)\node_modules\css-loader\index.js!.\style.css [2] ./image.png 82 bytes {0} [built] cjs require ./image.png [0] (webpack)/node_modules/css-loader!./style.css 6:58-80 + 1 hidden module @@ -179,8 +186,8 @@ Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin ## Minimized (uglify-js, no zip) ``` -Hash: 7e35402b768b90e83df1 -Version: webpack 3.5.1 +Hash: 9369d8f65a2a0dbd9c43 +Version: webpack next Asset Size Chunks Chunk Names ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted] output.js 504 bytes 0 [emitted] main @@ -189,15 +196,17 @@ Entrypoint main = output.js style.css chunk {0} output.js, style.css (main) 64 bytes [entry] [rendered] > main [0] ./example.js [0] ./example.js 23 bytes {0} [built] + single entry .\example.js main [1] ./style.css 41 bytes {0} [built] cjs require ./style.css [0] ./example.js 1:0-22 Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!style.css: Asset Size Chunks Chunk Names ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted] Entrypoint undefined = extract-text-webpack-plugin-output-filename - chunk {0} extract-text-webpack-plugin-output-filename 2.56 kB [entry] [rendered] + chunk {0} extract-text-webpack-plugin-output-filename 2.5 KiB [entry] [rendered] > [0] (webpack)/node_modules/css-loader!./style.css [0] (webpack)/node_modules/css-loader!./style.css 218 bytes {0} [built] + single entry !!(webpack)\node_modules\css-loader\index.js!.\style.css [2] ./image.png 82 bytes {0} [built] cjs require ./image.png [0] (webpack)/node_modules/css-loader!./style.css 6:50-72 + 1 hidden module diff --git a/examples/dll-app-and-vendor/0-vendor/README.md b/examples/dll-app-and-vendor/0-vendor/README.md index 1331b6b14..b0e2ba6ce 100644 --- a/examples/dll-app-and-vendor/0-vendor/README.md +++ b/examples/dll-app-and-vendor/0-vendor/README.md @@ -40,7 +40,7 @@ export function square(n) { # js/vendor.js ``` javascript -var vendor_lib_6b1edee0549eb5092709 = +var vendor_lib_668eb208c131c5341859 = ```
/******/ (function(modules) { /* webpackBootstrap */ }) @@ -137,7 +137,7 @@ module.exports = __webpack_require__; "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony export (immutable) */ __webpack_exports__["square"] = square; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "square", function() { return square; }); function square(n) { return n * n; } @@ -150,7 +150,7 @@ function square(n) { # js/vendor-manifest.json ``` javascript -{"name":"vendor_lib_6b1edee0549eb5092709","content":{"../node_modules/example-vendor.js":{"id":1,"meta":{"harmonyModule":true},"exports":["square"]}}} +{"name":"vendor_lib_668eb208c131c5341859","content":{"../node_modules/example-vendor.js":{"id":1,"meta":{"harmonyModule":true},"exports":["square"]}}} ``` # Info @@ -158,28 +158,32 @@ function square(n) { ## Uncompressed ``` -Hash: 6b1edee0549eb5092709 -Version: webpack 3.5.1 - Asset Size Chunks Chunk Names -vendor.js 3.18 kB 0 [emitted] main +Hash: 668eb208c131c5341859 +Version: webpack next + Asset Size Chunks Chunk Names +vendor.js 3.15 KiB 0 [emitted] main Entrypoint main = vendor.js chunk {0} vendor.js (main) 60 bytes [entry] [rendered] > main [0] dll main [0] dll main 12 bytes {0} [built] + dll entry + + 1 hidden module ``` ## Minimized (uglify-js, no zip) ``` -Hash: 6b1edee0549eb5092709 -Version: webpack 3.5.1 +Hash: 668eb208c131c5341859 +Version: webpack next Asset Size Chunks Chunk Names -vendor.js 652 bytes 0 [emitted] main +vendor.js 678 bytes 0 [emitted] main Entrypoint main = vendor.js chunk {0} vendor.js (main) 60 bytes [entry] [rendered] > main [0] dll main [0] dll main 12 bytes {0} [built] + dll entry + + 1 hidden module ``` diff --git a/examples/dll-app-and-vendor/1-app/README.md b/examples/dll-app-and-vendor/1-app/README.md index 3a77b1ae7..33a56b81d 100644 --- a/examples/dll-app-and-vendor/1-app/README.md +++ b/examples/dll-app-and-vendor/1-app/README.md @@ -112,7 +112,7 @@ console.log(new square(7)); /******/ __webpack_require__.p = "js/"; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 0); +/******/ return __webpack_require__(__webpack_require__.s = 1); /******/ }) /************************************************************************/ ``` @@ -122,26 +122,8 @@ console.log(new square(7)); ``` javascript /******/ ([ /* 0 */ -/*!************************!*\ - !*** ./example-app.js ***! - \************************/ -/*! exports provided: */ -/*! all exports used */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_example_vendor__ = __webpack_require__(/*! example-vendor */ 1); - - -console.log(Object(__WEBPACK_IMPORTED_MODULE_0_example_vendor__["square"])(7)); -console.log(new __WEBPACK_IMPORTED_MODULE_0_example_vendor__["square"](7)); - - -/***/ }), -/* 1 */ /*!******************************************************************************************************!*\ - !*** delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_6b1edee0549eb5092709 ***! + !*** delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_668eb208c131c5341859 ***! \******************************************************************************************************/ /*! exports provided: square */ /*! all exports used */ @@ -149,16 +131,34 @@ console.log(new __WEBPACK_IMPORTED_MODULE_0_example_vendor__["square"](7)); module.exports = (__webpack_require__(2))(1); +/***/ }), +/* 1 */ +/*!************************!*\ + !*** ./example-app.js ***! + \************************/ +/*! no exports provided */ +/*! all exports used */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony import */ var example_vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! example-vendor */0); + + +console.log(Object(example_vendor__WEBPACK_IMPORTED_MODULE_0__["square"])(7)); +console.log(new example_vendor__WEBPACK_IMPORTED_MODULE_0__["square"](7)); + + /***/ }), /* 2 */ /*!**************************************************!*\ - !*** external "vendor_lib_6b1edee0549eb5092709" ***! + !*** external "vendor_lib_668eb208c131c5341859" ***! \**************************************************/ /*! no static exports found */ /*! all exports used */ /***/ (function(module, exports) { -module.exports = vendor_lib_6b1edee0549eb5092709; +module.exports = vendor_lib_668eb208c131c5341859; /***/ }) /******/ ]); @@ -169,37 +169,45 @@ module.exports = vendor_lib_6b1edee0549eb5092709; ## Uncompressed ``` -Hash: 26778169dabaf1f3965d -Version: webpack 3.5.1 - Asset Size Chunks Chunk Names -app.js 3.85 kB 0 [emitted] main +Hash: 04a51b52310382404203 +Version: webpack next + Asset Size Chunks Chunk Names +app.js 3.75 KiB 0 [emitted] main Entrypoint main = app.js chunk {0} app.js (main) 182 bytes [entry] [rendered] - > main [0] ./example-app.js - [0] ./example-app.js 98 bytes {0} [built] - [no exports] - [1] delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_6b1edee0549eb5092709 42 bytes {0} [built] + > main [1] ./example-app.js + [0] delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_668eb208c131c5341859 42 bytes {0} [built] [exports: square] - harmony import example-vendor [0] ./example-app.js 1:0-40 - + 1 hidden module + harmony side effect evaluation example-vendor [1] ./example-app.js 1:0-40 + harmony import specifier example-vendor [1] ./example-app.js 3:12-18 + harmony import specifier example-vendor [1] ./example-app.js 4:16-22 + [1] ./example-app.js 98 bytes {0} [built] + [no exports] + single entry ./example-app main + [2] external "vendor_lib_668eb208c131c5341859" 42 bytes {0} [built] + delegated source dll-reference vendor_lib_668eb208c131c5341859 [0] delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_668eb208c131c5341859 ``` ## Minimized (uglify-js, no zip) ``` -Hash: 26778169dabaf1f3965d -Version: webpack 3.5.1 +Hash: 04a51b52310382404203 +Version: webpack next Asset Size Chunks Chunk Names app.js 710 bytes 0 [emitted] main Entrypoint main = app.js chunk {0} app.js (main) 182 bytes [entry] [rendered] - > main [0] ./example-app.js - [0] ./example-app.js 98 bytes {0} [built] - [no exports] - [1] delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_6b1edee0549eb5092709 42 bytes {0} [built] + > main [1] ./example-app.js + [0] delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_668eb208c131c5341859 42 bytes {0} [built] [exports: square] - harmony import example-vendor [0] ./example-app.js 1:0-40 - + 1 hidden module + harmony side effect evaluation example-vendor [1] ./example-app.js 1:0-40 + harmony import specifier example-vendor [1] ./example-app.js 3:12-18 + harmony import specifier example-vendor [1] ./example-app.js 4:16-22 + [1] ./example-app.js 98 bytes {0} [built] + [no exports] + single entry ./example-app main + [2] external "vendor_lib_668eb208c131c5341859" 42 bytes {0} [built] + delegated source dll-reference vendor_lib_668eb208c131c5341859 [0] delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_668eb208c131c5341859 ``` @@ -84,10 +85,11 @@ module.exports = { \*******************/ /*! exports provided: default */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: multi ./vendor (referenced with single entry) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +__webpack_require__.r(__webpack_exports__); // some vendor lib (should be in common chunk) /* harmony default export */ __webpack_exports__["default"] = (123); @@ -100,6 +102,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); \**********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(/*! ./vendor */0); @@ -120,10 +123,11 @@ module.exports = __webpack_require__(/*! ./vendor */0); \********************/ /*! no exports provided */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is an entry point */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +__webpack_require__.r(__webpack_exports__); /* harmony import */ var _vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vendor */0); // some module @@ -143,11 +147,11 @@ __webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! . Hash: 19d389fe665472aada46 Version: webpack next Asset Size Chunks Chunk Names -d384ba1bbf385fcafc99.js 288 bytes 0 [emitted] -13604ac9ffd7d870f88b.js 288 bytes 1 [emitted] - common.[chunkhash].js 788 bytes 2 [emitted] common - main.[chunkhash].js 711 bytes 3 [emitted] main - manifest.[chunkhash].js 6.96 KiB 4 [emitted] manifest +d384ba1bbf385fcafc99.js 359 bytes 0 [emitted] +13604ac9ffd7d870f88b.js 359 bytes 1 [emitted] + common.[chunkhash].js 975 bytes 2 [emitted] common + main.[chunkhash].js 741 bytes 3 [emitted] main + manifest.[chunkhash].js 7.14 KiB 4 [emitted] manifest Entrypoint main = manifest.[chunkhash].js common.[chunkhash].js main.[chunkhash].js Entrypoint common = manifest.[chunkhash].js common.[chunkhash].js chunk {0} d384ba1bbf385fcafc99.js 29 bytes {3} [rendered] @@ -182,9 +186,9 @@ Version: webpack next Asset Size Chunks Chunk Names d384ba1bbf385fcafc99.js 78 bytes 0 [emitted] 13604ac9ffd7d870f88b.js 78 bytes 1 [emitted] - common.[chunkhash].js 196 bytes 2 [emitted] common - main.[chunkhash].js 213 bytes 3 [emitted] main - manifest.[chunkhash].js 1.74 KiB 4 [emitted] manifest + common.[chunkhash].js 154 bytes 2 [emitted] common + main.[chunkhash].js 171 bytes 3 [emitted] main + manifest.[chunkhash].js 1.81 KiB 4 [emitted] manifest Entrypoint main = manifest.[chunkhash].js common.[chunkhash].js main.[chunkhash].js Entrypoint common = manifest.[chunkhash].js common.[chunkhash].js chunk {0} d384ba1bbf385fcafc99.js 29 bytes {3} [rendered] diff --git a/examples/code-splitted-css-bundle/README.md b/examples/code-splitted-css-bundle/README.md index cb18abeb9..097019cc1 100644 --- a/examples/code-splitted-css-bundle/README.md +++ b/examples/code-splitted-css-bundle/README.md @@ -34,6 +34,7 @@ require("./style2.css"); const LoaderOptionsPlugin = require("../../lib/LoaderOptionsPlugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { + mode: "production", module: { rules: [ { @@ -75,8 +76,8 @@ Hash: eb83e18f883b3782ac4e Version: webpack next Asset Size Chunks Chunk Names ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted] - 0.output.js 2.42 KiB 0 [emitted] - output.js 21.5 KiB 1 [emitted] main + 0.output.js 2.7 KiB 0 [emitted] + output.js 22.1 KiB 1 [emitted] main style.css 71 bytes 1 [emitted] main Entrypoint main = output.js style.css chunk {0} 0.output.js 1.33 KiB {1} [rendered] @@ -116,7 +117,7 @@ Version: webpack next Asset Size Chunks Chunk Names ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted] 0.output.js 383 bytes 0 [emitted] - output.js 6.63 KiB 1 [emitted] main + output.js 6.7 KiB 1 [emitted] main style.css 61 bytes 1 [emitted] main Entrypoint main = output.js style.css chunk {0} 0.output.js 1.31 KiB {1} [rendered] diff --git a/examples/code-splitted-require.context-amd/README.md b/examples/code-splitted-require.context-amd/README.md index 87c108c8d..93bfe9b2d 100644 --- a/examples/code-splitted-require.context-amd/README.md +++ b/examples/code-splitted-require.context-amd/README.md @@ -154,6 +154,11 @@ getTemplate("b", function(b) { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -194,6 +199,7 @@ getTemplate("b", function(b) { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { function getTemplate(templateName, callback) { @@ -223,6 +229,7 @@ getTemplate("b", function(b) { \**************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var map = { @@ -256,6 +263,7 @@ webpackContext.id = 1; \*****************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -269,6 +277,7 @@ module.exports = function() { \*****************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -282,6 +291,7 @@ module.exports = function() { \*****************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -300,8 +310,8 @@ module.exports = function() { Hash: 3742c378c8642182b6b1 Version: webpack next Asset Size Chunks Chunk Names -0.output.js 1.87 KiB 0 [emitted] - output.js 6.99 KiB 1 [emitted] main +0.output.js 2.15 KiB 0 [emitted] + output.js 7.24 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 463 bytes {1} [rendered] > [0] ./example.js 2:1-4:3 @@ -329,7 +339,7 @@ Hash: 3742c378c8642182b6b1 Version: webpack next Asset Size Chunks Chunk Names 0.output.js 584 bytes 0 [emitted] - output.js 1.69 KiB 1 [emitted] main + output.js 1.75 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 463 bytes {1} [rendered] > [0] ./example.js 2:1-4:3 diff --git a/examples/code-splitted-require.context/README.md b/examples/code-splitted-require.context/README.md index 3a477604e..53e682b25 100644 --- a/examples/code-splitted-require.context/README.md +++ b/examples/code-splitted-require.context/README.md @@ -154,6 +154,11 @@ getTemplate("b", function(b) { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -194,6 +199,7 @@ getTemplate("b", function(b) { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { function getTemplate(templateName, callback) { @@ -223,6 +229,7 @@ getTemplate("b", function(b) { \**************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var map = { @@ -256,6 +263,7 @@ webpackContext.id = 1; \*****************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -269,6 +277,7 @@ module.exports = function() { \*****************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -282,6 +291,7 @@ module.exports = function() { \*****************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -300,8 +310,8 @@ module.exports = function() { Hash: 71a61aeef010cd2fd50d Version: webpack next Asset Size Chunks Chunk Names -0.output.js 1.87 KiB 0 [emitted] - output.js 6.93 KiB 1 [emitted] main +0.output.js 2.15 KiB 0 [emitted] + output.js 7.18 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 463 bytes {1} [rendered] > [0] ./example.js 2:1-4:3 @@ -329,7 +339,7 @@ Hash: 71a61aeef010cd2fd50d Version: webpack next Asset Size Chunks Chunk Names 0.output.js 584 bytes 0 [emitted] - output.js 1.66 KiB 1 [emitted] main + output.js 1.73 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 463 bytes {1} [rendered] > [0] ./example.js 2:1-4:3 diff --git a/examples/code-splitting-bundle-loader/README.md b/examples/code-splitting-bundle-loader/README.md index 4f4a75c84..e22ac8fac 100644 --- a/examples/code-splitting-bundle-loader/README.md +++ b/examples/code-splitting-bundle-loader/README.md @@ -157,6 +157,11 @@ module.exports = "It works"; /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -197,6 +202,7 @@ module.exports = "It works"; \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(/*! bundle-loader!./file.js */ 1)(function(fileJsExports) { @@ -211,6 +217,7 @@ __webpack_require__(/*! bundle-loader!./file.js */ 1)(function(fileJsExports) { \******************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var cbs = [], @@ -243,6 +250,7 @@ __webpack_require__.e/* require.ensure */(0).then((function(require) { \*****************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "It works"; @@ -260,8 +268,8 @@ module.exports = "It works"; Hash: 18d3b0908ee42d7ec955 Version: webpack next Asset Size Chunks Chunk Names -0.output.js 281 bytes 0 [emitted] - output.js 7.38 KiB 1 [emitted] main +0.output.js 352 bytes 0 [emitted] + output.js 7.7 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 28 bytes {1} [rendered] > [1] (webpack)/node_modules/bundle-loader!./file.js 7:0-14:2 @@ -282,7 +290,7 @@ Hash: 18d3b0908ee42d7ec955 Version: webpack next Asset Size Chunks Chunk Names 0.output.js 98 bytes 0 [emitted] - output.js 1.72 KiB 1 [emitted] main + output.js 1.78 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 28 bytes {1} [rendered] > [1] (webpack)/node_modules/bundle-loader!./file.js 7:0-14:2 diff --git a/examples/code-splitting-harmony/README.md b/examples/code-splitting-harmony/README.md index 117636a61..82a0f3b54 100644 --- a/examples/code-splitting-harmony/README.md +++ b/examples/code-splitting-harmony/README.md @@ -165,6 +165,11 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -207,10 +212,11 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) { \********************/ /*! no exports provided */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is an entry point */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +__webpack_require__.r(__webpack_exports__); /* harmony import */ var a__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! a */3); /* harmony import */ var a__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(a__WEBPACK_IMPORTED_MODULE_0__); @@ -234,6 +240,7 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) { !*** ./node_modules/a.js ***! \***************************/ /*! no static exports found */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // module a @@ -245,6 +252,7 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) { \**************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var map = { @@ -292,10 +300,10 @@ module.exports = webpackAsyncContext; Hash: 99774db1d98bb53fa195 Version: webpack next Asset Size Chunks Chunk Names -0.output.js 308 bytes 0 [emitted] -1.output.js 299 bytes 1 [emitted] -2.output.js 294 bytes 2 [emitted] - output.js 8.18 KiB 3 [emitted] main +0.output.js 379 bytes 0 [emitted] +1.output.js 370 bytes 1 [emitted] +2.output.js 365 bytes 2 [emitted] + output.js 8.53 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 13 bytes {3} [rendered] 1 module @@ -323,7 +331,7 @@ Version: webpack next 0.output.js 77 bytes 0 [emitted] 1.output.js 76 bytes 1 [emitted] 2.output.js 78 bytes 2 [emitted] - output.js 2.05 KiB 3 [emitted] main + output.js 2.07 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 13 bytes {3} [rendered] 1 module diff --git a/examples/code-splitting-native-import-context-filter/README.md b/examples/code-splitting-native-import-context-filter/README.md index c9e3136ed..29763aead 100644 --- a/examples/code-splitting-native-import-context-filter/README.md +++ b/examples/code-splitting-native-import-context-filter/README.md @@ -183,6 +183,11 @@ export default foo; /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -226,6 +231,7 @@ export default foo; \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { async function getTemplate(templateName) { @@ -254,6 +260,7 @@ getTemplate("baz.noimport"); \*************************************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var map = { @@ -308,10 +315,10 @@ module.exports = webpackAsyncContext; Hash: c26be64a30f40e562b8c Version: webpack next Asset Size Chunks Chunk Names -0.output.js 494 bytes 0 [emitted] -1.output.js 500 bytes 1 [emitted] -2.output.js 491 bytes 2 [emitted] - output.js 7.89 KiB 3 [emitted] main +0.output.js 664 bytes 0 [emitted] +1.output.js 670 bytes 1 [emitted] +2.output.js 661 bytes 2 [emitted] + output.js 8.21 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 41 bytes {3} [rendered] [2] ./templates/foo.js 41 bytes {0} [optional] [built] @@ -341,11 +348,7 @@ chunk {3} output.js (main) 618 bytes [entry] [rendered] ``` Hash: c26be64a30f40e562b8c Version: webpack next - Asset Size Chunks Chunk Names -0.output.js 157 bytes 0 [emitted] -1.output.js 156 bytes 1 [emitted] -2.output.js 155 bytes 2 [emitted] - output.js 7.47 KiB 3 [emitted] main + 4 assets Entrypoint main = output.js chunk {0} 0.output.js 41 bytes {3} [rendered] [2] ./templates/foo.js 41 bytes {0} [optional] [built] @@ -370,5 +373,5 @@ chunk {3} output.js (main) 618 bytes [entry] [rendered] import() context lazy ./templates [3] ./example.js 3:23-7:3 ERROR in output.js from UglifyJs -Unexpected token: keyword (function) [output.js:171,6] +Unexpected token: keyword (function) [output.js:176,6] ``` diff --git a/examples/code-splitting-native-import-context/README.md b/examples/code-splitting-native-import-context/README.md index 19443c910..1e1564dcb 100644 --- a/examples/code-splitting-native-import-context/README.md +++ b/examples/code-splitting-native-import-context/README.md @@ -172,6 +172,11 @@ export default foo; /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -215,6 +220,7 @@ export default foo; \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { async function getTemplate(templateName) { @@ -241,6 +247,7 @@ getTemplate("baz"); \*********************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var map = { @@ -295,10 +302,10 @@ module.exports = webpackAsyncContext; Hash: c0e9c43fa1cecd7aab21 Version: webpack next Asset Size Chunks Chunk Names -0.output.js 494 bytes 0 [emitted] -1.output.js 500 bytes 1 [emitted] -2.output.js 491 bytes 2 [emitted] - output.js 7.7 KiB 3 [emitted] main +0.output.js 624 bytes 0 [emitted] +1.output.js 630 bytes 1 [emitted] +2.output.js 621 bytes 2 [emitted] + output.js 8.02 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 41 bytes {3} [rendered] [2] ./templates/foo.js 41 bytes {0} [optional] [built] @@ -328,11 +335,7 @@ chunk {3} output.js (main) 456 bytes [entry] [rendered] ``` Hash: c0e9c43fa1cecd7aab21 Version: webpack next - Asset Size Chunks Chunk Names -0.output.js 157 bytes 0 [emitted] -1.output.js 156 bytes 1 [emitted] -2.output.js 155 bytes 2 [emitted] - output.js 7.4 KiB 3 [emitted] main + 4 assets Entrypoint main = output.js chunk {0} 0.output.js 41 bytes {3} [rendered] [2] ./templates/foo.js 41 bytes {0} [optional] [built] @@ -357,5 +360,5 @@ chunk {3} output.js (main) 456 bytes [entry] [rendered] import() context lazy ./templates [3] ./example.js 3:23-60 ERROR in output.js from UglifyJs -Unexpected token: keyword (function) [output.js:171,6] +Unexpected token: keyword (function) [output.js:176,6] ``` diff --git a/examples/code-splitting-specify-chunk-name/README.md b/examples/code-splitting-specify-chunk-name/README.md index 2254415ef..a7d4237c5 100644 --- a/examples/code-splitting-specify-chunk-name/README.md +++ b/examples/code-splitting-specify-chunk-name/README.md @@ -172,6 +172,11 @@ export default foo; /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -215,6 +220,7 @@ export default foo; \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__.e/* import() */(0/*! chunk-foo *//* duplicate */).then(__webpack_require__.bind(null, /*! ./templates/foo */2)).then(function(foo) { @@ -241,6 +247,7 @@ __webpack_require__( 4)("./ba" + createContextVar).then(function(bar) { \***********************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var map = { @@ -287,10 +294,10 @@ module.exports = webpackAsyncContext; Hash: b9593814353293fefda9 Version: webpack next Asset Size Chunks Chunk Names -0.output.js 494 bytes 0 [emitted] chunk-foo -1.output.js 500 bytes 1 [emitted] chunk-bar-baz2 -2.output.js 491 bytes 2 [emitted] chunk-bar-baz0 - output.js 7.93 KiB 3 [emitted] main +0.output.js 617 bytes 0 [emitted] chunk-foo +1.output.js 632 bytes 1 [emitted] chunk-bar-baz2 +2.output.js 623 bytes 2 [emitted] chunk-bar-baz0 + output.js 8.26 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js (chunk-foo) 41 bytes {3} [rendered] > duplicate chunk-foo [3] ./example.js 1:0-62 @@ -323,10 +330,10 @@ chunk {3} output.js (main) 580 bytes [entry] [rendered] Hash: b9593814353293fefda9 Version: webpack next Asset Size Chunks Chunk Names -0.output.js 157 bytes 0 [emitted] chunk-foo -1.output.js 156 bytes 1 [emitted] chunk-bar-baz2 -2.output.js 155 bytes 2 [emitted] chunk-bar-baz0 - output.js 1.99 KiB 3 [emitted] main +0.output.js 115 bytes 0 [emitted] chunk-foo +1.output.js 114 bytes 1 [emitted] chunk-bar-baz2 +2.output.js 113 bytes 2 [emitted] chunk-bar-baz0 + output.js 2.06 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js (chunk-foo) 41 bytes {3} [rendered] > duplicate chunk-foo [3] ./example.js 1:0-62 diff --git a/examples/code-splitting/README.md b/examples/code-splitting/README.md index 9d337c680..06b2ddaf9 100644 --- a/examples/code-splitting/README.md +++ b/examples/code-splitting/README.md @@ -176,6 +176,11 @@ require.ensure(["c"], function(require) { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -216,6 +221,7 @@ require.ensure(["c"], function(require) { \***************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // module b @@ -227,6 +233,7 @@ require.ensure(["c"], function(require) { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var a = __webpack_require__(/*! a */ 2); @@ -243,6 +250,7 @@ __webpack_require__.e/* require.ensure */(0).then((function(require) { \***************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // module a @@ -264,6 +272,7 @@ __webpack_require__.e/* require.ensure */(0).then((function(require) { \***************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // module c @@ -275,6 +284,7 @@ __webpack_require__.e/* require.ensure */(0).then((function(require) { \***************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // module d @@ -297,8 +307,8 @@ Minimized Hash: 23b9593edef76f47cb63 Version: webpack next Asset Size Chunks Chunk Names -0.output.js 538 bytes 0 [emitted] - output.js 7.31 KiB 1 [emitted] main +0.output.js 680 bytes 0 [emitted] + output.js 7.7 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 22 bytes {1} [rendered] > [1] ./example.js 3:0-6:2 @@ -317,7 +327,7 @@ Hash: 23b9593edef76f47cb63 Version: webpack next Asset Size Chunks Chunk Names 0.output.js 95 bytes 0 [emitted] - output.js 1.62 KiB 1 [emitted] main + output.js 1.68 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 22 bytes {1} [rendered] > [1] ./example.js 3:0-6:2 diff --git a/examples/coffee-script/README.md b/examples/coffee-script/README.md index 345deb399..e40850a1f 100644 --- a/examples/coffee-script/README.md +++ b/examples/coffee-script/README.md @@ -74,6 +74,11 @@ module.exports = 42 /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -105,6 +110,7 @@ module.exports = 42 \*********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { console.log("yeah coffee-script"); @@ -119,6 +125,7 @@ module.exports = 42; \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { console.log(__webpack_require__(/*! ./cup1 */ 2)); @@ -130,6 +137,7 @@ console.log(__webpack_require__(/*! ./cup1 */ 2)); \*********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = { @@ -152,7 +160,7 @@ module.exports = { Hash: 0a5ced711d4abc81fdd4 Version: webpack next Asset Size Chunks Chunk Names -output.js 3.22 KiB 0 [emitted] main +output.js 3.61 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 206 bytes [entry] [rendered] > main [1] ./example.js @@ -171,7 +179,7 @@ chunk {0} output.js (main) 206 bytes [entry] [rendered] Hash: 0a5ced711d4abc81fdd4 Version: webpack next Asset Size Chunks Chunk Names -output.js 640 bytes 0 [emitted] main +output.js 706 bytes 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 206 bytes [entry] [rendered] > main [1] ./example.js diff --git a/examples/common-chunk-and-vendor-chunk/README.md b/examples/common-chunk-and-vendor-chunk/README.md index 4cba9f3db..a93881657 100644 --- a/examples/common-chunk-and-vendor-chunk/README.md +++ b/examples/common-chunk-and-vendor-chunk/README.md @@ -38,6 +38,7 @@ var path = require("path"); var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", entry: { vendor: ["./vendor1", "./vendor2"], pageA: "./pageA", @@ -214,6 +215,11 @@ module.exports = { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -256,6 +262,7 @@ module.exports = { \*********************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(/*! ./vendor1 */3); @@ -269,6 +276,7 @@ module.exports = __webpack_require__(/*! ./vendor2 */4); \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "vendor1"; @@ -280,6 +288,7 @@ module.exports = "vendor1"; \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "vendor2"; @@ -298,6 +307,7 @@ module.exports = "vendor2"; \*********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "utility2"; @@ -309,6 +319,7 @@ module.exports = "utility2"; \*********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "utility3"; @@ -328,6 +339,7 @@ module.exports = "utility3"; \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var utility1 = __webpack_require__(/*! ./utility1 */ 6); @@ -343,6 +355,7 @@ module.exports = "pageA"; \*********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "utility1"; @@ -363,6 +376,7 @@ module.exports = "utility1"; \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var utility2 = __webpack_require__(/*! ./utility2 */ 0); @@ -386,6 +400,7 @@ module.exports = "pageB"; \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var utility2 = __webpack_require__(/*! ./utility2 */ 0); @@ -406,11 +421,11 @@ module.exports = "pageC"; Hash: 4b8ef245065d9c193fc3 Version: webpack next Asset Size Chunks Chunk Names -common.js 509 bytes 0 [emitted] common - pageA.js 653 bytes 1 [emitted] pageA - pageC.js 432 bytes 2 [emitted] pageC - pageB.js 432 bytes 3 [emitted] pageB -vendor.js 7.75 KiB 4 [emitted] vendor +common.js 651 bytes 0 [emitted] common + pageA.js 795 bytes 1 [emitted] pageA + pageC.js 503 bytes 2 [emitted] pageC + pageB.js 503 bytes 3 [emitted] pageB +vendor.js 8.15 KiB 4 [emitted] vendor Entrypoint vendor = vendor.js Entrypoint pageA = vendor.js common.js pageA.js Entrypoint pageB = vendor.js common.js pageB.js @@ -457,7 +472,7 @@ common.js 132 bytes 0 [emitted] common pageA.js 157 bytes 1 [emitted] pageA pageC.js 119 bytes 2 [emitted] pageC pageB.js 119 bytes 3 [emitted] pageB -vendor.js 1.75 KiB 4 [emitted] vendor +vendor.js 1.82 KiB 4 [emitted] vendor Entrypoint vendor = vendor.js Entrypoint pageA = vendor.js common.js pageA.js Entrypoint pageB = vendor.js common.js pageB.js diff --git a/examples/common-chunk-grandchildren/README.md b/examples/common-chunk-grandchildren/README.md index 7073b5490..572afb8a1 100644 --- a/examples/common-chunk-grandchildren/README.md +++ b/examples/common-chunk-grandchildren/README.md @@ -88,6 +88,7 @@ const path = require("path"); module.exports = [ { + mode: "production", entry: { main: ["./example.js"] }, @@ -105,6 +106,7 @@ module.exports = [ ] }, { + mode: "production", entry: { main: ["./example.js"] }, @@ -265,6 +267,11 @@ module.exports = [ /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -305,6 +312,7 @@ module.exports = [ \**************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(/*! ./example.js */1); @@ -317,6 +325,7 @@ module.exports = __webpack_require__(/*! ./example.js */1); \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var main = function() { @@ -341,6 +350,7 @@ main(); \******************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -363,6 +373,7 @@ module.exports = function() { \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var reusableComponent = __webpack_require__(/*! ./reusableComponent */ 2); @@ -389,6 +400,7 @@ module.exports = function() { \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = function() { @@ -416,6 +428,7 @@ module.exports = function() { \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var reusableComponent = __webpack_require__(/*! ./reusableComponent */ 2); @@ -569,6 +582,11 @@ module.exports = function() { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -604,6 +622,7 @@ module.exports = function() { \**************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(/*! ./example.js */1); @@ -616,6 +635,7 @@ module.exports = __webpack_require__(/*! ./example.js */1); \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var main = function() { @@ -648,6 +668,7 @@ main(); \******************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -671,6 +692,7 @@ module.exports = function() { \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = function() { @@ -698,6 +720,7 @@ module.exports = function() { \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var reusableComponent = __webpack_require__(/*! ./reusableComponent */ 4); @@ -724,6 +747,7 @@ module.exports = function() { \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var reusableComponent = __webpack_require__(/*! ./reusableComponent */ 4); @@ -749,10 +773,10 @@ Version: webpack next Child Hash: 3d3c887e038c22d66243 Asset Size Chunks Chunk Names - 0.output.js 438 bytes 0 [emitted] - 1.output.js 531 bytes 1 [emitted] - 2.output.js 438 bytes 2 [emitted] - output.js 7.59 KiB 3 [emitted] main + 0.output.js 509 bytes 0 [emitted] + 1.output.js 602 bytes 1 [emitted] + 2.output.js 509 bytes 2 [emitted] + output.js 7.98 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 142 bytes {3} [rendered] > [4] ./pageB.js 3:1-6:3 @@ -778,11 +802,11 @@ Child Child Hash: e918fbcaa3ff1f847528 Asset Size Chunks Chunk Names - 0.asyncoutput.js 364 bytes 0 [emitted] - 1.asyncoutput.js 572 bytes 1 [emitted] - 2.asyncoutput.js 438 bytes 2 [emitted] - 3.asyncoutput.js 438 bytes 3 [emitted] - asyncoutput.js 7.35 KiB 4 [emitted] main + 0.asyncoutput.js 435 bytes 0 [emitted] + 1.asyncoutput.js 643 bytes 1 [emitted] + 2.asyncoutput.js 509 bytes 2 [emitted] + 3.asyncoutput.js 509 bytes 3 [emitted] + asyncoutput.js 7.68 KiB 4 [emitted] main Entrypoint main = asyncoutput.js chunk {0} 0.asyncoutput.js 72 bytes {4} [rendered] > async commons [1] ./example.js 3:1-6:3 @@ -817,11 +841,7 @@ Hash: 3d3c887e038c22d66243e918fbcaa3ff1f847528 Version: webpack next Child Hash: 3d3c887e038c22d66243 - Asset Size Chunks Chunk Names - 0.output.js 138 bytes 0 [emitted] - 1.output.js 390 bytes 1 [emitted] - 2.output.js 138 bytes 2 [emitted] - output.js 7.11 KiB 3 [emitted] main + 4 assets Entrypoint main = output.js chunk {0} 0.output.js 142 bytes {3} [rendered] > [4] ./pageB.js 3:1-6:3 @@ -849,15 +869,10 @@ Child Unexpected token: punc ()) [1.output.js:8,53] ERROR in output.js from UglifyJs - Unexpected token: punc ()) [output.js:177,53] + Unexpected token: punc ()) [output.js:182,53] Child Hash: e918fbcaa3ff1f847528 - Asset Size Chunks Chunk Names - 0.asyncoutput.js 133 bytes 0 [emitted] - 1.asyncoutput.js 431 bytes 1 [emitted] - 2.asyncoutput.js 138 bytes 2 [emitted] - 3.asyncoutput.js 138 bytes 3 [emitted] - asyncoutput.js 7.03 KiB 4 [emitted] main + 5 assets Entrypoint main = asyncoutput.js chunk {0} 0.asyncoutput.js 72 bytes {4} [rendered] > async commons [1] ./example.js 3:1-6:3 @@ -888,5 +903,5 @@ Child Unexpected token: punc ()) [1.asyncoutput.js:8,94] ERROR in asyncoutput.js from UglifyJs - Unexpected token: punc ()) [asyncoutput.js:177,94] + Unexpected token: punc ()) [asyncoutput.js:182,94] ``` diff --git a/examples/commonjs/README.md b/examples/commonjs/README.md index c6d07e349..175670491 100644 --- a/examples/commonjs/README.md +++ b/examples/commonjs/README.md @@ -86,6 +86,11 @@ exports.add = function() { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -117,6 +122,7 @@ exports.add = function() { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var inc = __webpack_require__(/*! ./increment */ 1).increment; @@ -130,6 +136,7 @@ inc(a); // 2 \**********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var add = __webpack_require__(/*! ./math */ 2).add; @@ -144,6 +151,7 @@ exports.increment = function(val) { \*****************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { exports.add = function() { @@ -166,7 +174,7 @@ exports.add = function() { Hash: ae7172392c4d0e31a2b7 Version: webpack next Asset Size Chunks Chunk Names -output.js 3.31 KiB 0 [emitted] main +output.js 3.71 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 329 bytes [entry] [rendered] > main [0] ./example.js @@ -184,7 +192,7 @@ chunk {0} output.js (main) 329 bytes [entry] [rendered] Hash: ae7172392c4d0e31a2b7 Version: webpack next Asset Size Chunks Chunk Names -output.js 672 bytes 0 [emitted] main +output.js 738 bytes 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 329 bytes [entry] [rendered] > main [0] ./example.js diff --git a/examples/css-bundle/README.md b/examples/css-bundle/README.md index 28431ed37..1e63052d6 100644 --- a/examples/css-bundle/README.md +++ b/examples/css-bundle/README.md @@ -19,6 +19,7 @@ body { const LoaderOptionsPlugin = require("../../lib/LoaderOptionsPlugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { + mode: "production", module: { rules: [ { @@ -94,6 +95,11 @@ module.exports = { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -125,6 +131,7 @@ module.exports = { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(/*! ./style.css */ 1); @@ -136,6 +143,7 @@ __webpack_require__(/*! ./style.css */ 1); \*******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // removed by extract-text-webpack-plugin @@ -161,7 +169,7 @@ Hash: da73f4cbdaa662283746 Version: webpack next Asset Size Chunks Chunk Names ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted] - output.js 2.83 KiB 0 [emitted] main + output.js 3.16 KiB 0 [emitted] main style.css 69 bytes 0 [emitted] main Entrypoint main = output.js style.css chunk {0} output.js, style.css (main) 64 bytes [entry] [rendered] @@ -190,7 +198,7 @@ Hash: 9369d8f65a2a0dbd9c43 Version: webpack next Asset Size Chunks Chunk Names ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted] - output.js 504 bytes 0 [emitted] main + output.js 570 bytes 0 [emitted] main style.css 61 bytes 0 [emitted] main Entrypoint main = output.js style.css chunk {0} output.js, style.css (main) 64 bytes [entry] [rendered] diff --git a/examples/dll-app-and-vendor/0-vendor/README.md b/examples/dll-app-and-vendor/0-vendor/README.md index b0e2ba6ce..b2c01b439 100644 --- a/examples/dll-app-and-vendor/0-vendor/README.md +++ b/examples/dll-app-and-vendor/0-vendor/README.md @@ -13,6 +13,7 @@ var path = require("path"); var webpack = require("../../../"); module.exports = { + mode: "production", context: __dirname, entry: ["example-vendor"], output: { @@ -91,6 +92,11 @@ var vendor_lib_668eb208c131c5341859 = /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -122,6 +128,7 @@ var vendor_lib_668eb208c131c5341859 = \****************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__; @@ -133,10 +140,11 @@ module.exports = __webpack_require__; \*****************************************/ /*! exports provided: square */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: dll main (referenced with single entry) and by: DllPlugin */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +__webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "square", function() { return square; }); function square(n) { return n * n; @@ -161,7 +169,7 @@ function square(n) { Hash: 668eb208c131c5341859 Version: webpack next Asset Size Chunks Chunk Names -vendor.js 3.15 KiB 0 [emitted] main +vendor.js 3.53 KiB 0 [emitted] main Entrypoint main = vendor.js chunk {0} vendor.js (main) 60 bytes [entry] [rendered] > main [0] dll main @@ -177,7 +185,7 @@ chunk {0} vendor.js (main) 60 bytes [entry] [rendered] Hash: 668eb208c131c5341859 Version: webpack next Asset Size Chunks Chunk Names -vendor.js 678 bytes 0 [emitted] main +vendor.js 702 bytes 0 [emitted] main Entrypoint main = vendor.js chunk {0} vendor.js (main) 60 bytes [entry] [rendered] > main [0] dll main diff --git a/examples/dll-app-and-vendor/1-app/README.md b/examples/dll-app-and-vendor/1-app/README.md index 33a56b81d..efbc849eb 100644 --- a/examples/dll-app-and-vendor/1-app/README.md +++ b/examples/dll-app-and-vendor/1-app/README.md @@ -9,6 +9,7 @@ var path = require("path"); var webpack = require("../../../"); module.exports = { + mode: "production", context: __dirname, entry: "./example-app", output: { @@ -96,6 +97,11 @@ console.log(new square(7)); /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -127,6 +133,7 @@ console.log(new square(7)); \******************************************************************************************************/ /*! exports provided: square */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = (__webpack_require__(2))(1); @@ -138,10 +145,11 @@ module.exports = (__webpack_require__(2))(1); \************************/ /*! no exports provided */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is an entry point */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +__webpack_require__.r(__webpack_exports__); /* harmony import */ var example_vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! example-vendor */0); @@ -156,6 +164,7 @@ console.log(new example_vendor__WEBPACK_IMPORTED_MODULE_0__["square"](7)); \**************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = vendor_lib_668eb208c131c5341859; @@ -172,7 +181,7 @@ module.exports = vendor_lib_668eb208c131c5341859; Hash: 04a51b52310382404203 Version: webpack next Asset Size Chunks Chunk Names -app.js 3.75 KiB 0 [emitted] main +app.js 4.11 KiB 0 [emitted] main Entrypoint main = app.js chunk {0} app.js (main) 182 bytes [entry] [rendered] > main [1] ./example-app.js @@ -194,7 +203,7 @@ chunk {0} app.js (main) 182 bytes [entry] [rendered] Hash: 04a51b52310382404203 Version: webpack next Asset Size Chunks Chunk Names -app.js 710 bytes 0 [emitted] main +app.js 734 bytes 0 [emitted] main Entrypoint main = app.js chunk {0} app.js (main) 182 bytes [entry] [rendered] > main [1] ./example-app.js diff --git a/examples/dll-user/README.md b/examples/dll-user/README.md index b33afea0c..64b8b69fe 100644 --- a/examples/dll-user/README.md +++ b/examples/dll-user/README.md @@ -10,6 +10,7 @@ This is the _user_ bundle, which uses the manifest from [dll-reference example]( var path = require("path"); var webpack = require("../../"); module.exports = { + mode: "production", plugins: [ new webpack.DllReferencePlugin({ context: path.join(__dirname, "..", "dll"), @@ -88,6 +89,11 @@ console.log(require("module")); /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -119,6 +125,7 @@ console.log(require("module")); \*********************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = alpha_6d91db854aef9bf446d4; @@ -130,6 +137,7 @@ module.exports = alpha_6d91db854aef9bf446d4; \********************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = beta_6d91db854aef9bf446d4; @@ -141,6 +149,7 @@ module.exports = beta_6d91db854aef9bf446d4; \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { console.log(__webpack_require__(/*! ../dll/alpha */ 3)); @@ -160,6 +169,7 @@ console.log(__webpack_require__(/*! module */ 8)); \**************************************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = (__webpack_require__(0))(1); @@ -171,6 +181,7 @@ module.exports = (__webpack_require__(0))(1); \**********************************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = (__webpack_require__(0))(2); @@ -182,6 +193,7 @@ module.exports = (__webpack_require__(0))(2); \************************************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = (__webpack_require__(1))(5); @@ -193,6 +205,7 @@ module.exports = (__webpack_require__(1))(5); \*********************************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = (__webpack_require__(1))(6); @@ -204,6 +217,7 @@ module.exports = (__webpack_require__(1))(6); \**********************************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = (__webpack_require__(1))(7); @@ -215,6 +229,7 @@ module.exports = (__webpack_require__(1))(7); \*****************************************************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = (__webpack_require__(0))(3); @@ -231,7 +246,7 @@ module.exports = (__webpack_require__(0))(3); Hash: de10be9bbcb3d59901b3 Version: webpack next Asset Size Chunks Chunk Names -output.js 5.92 KiB 0 [emitted] main +output.js 6.73 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 549 bytes [entry] [rendered] > main [2] ./example.js @@ -265,7 +280,7 @@ chunk {0} output.js (main) 549 bytes [entry] [rendered] Hash: de10be9bbcb3d59901b3 Version: webpack next Asset Size Chunks Chunk Names -output.js 904 bytes 0 [emitted] main +output.js 970 bytes 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 549 bytes [entry] [rendered] > main [2] ./example.js diff --git a/examples/dll/README.md b/examples/dll/README.md index c8d448085..482524596 100644 --- a/examples/dll/README.md +++ b/examples/dll/README.md @@ -11,6 +11,7 @@ This is the _reference_ bundle (with the manifests) for [dll user example](https var path = require("path"); var webpack = require("../../"); module.exports = { + mode: "production", resolve: { extensions: [".js", ".jsx"] }, @@ -86,6 +87,11 @@ var alpha_6d91db854aef9bf446d4 = /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -117,6 +123,7 @@ var alpha_6d91db854aef9bf446d4 = \*****************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__; @@ -128,6 +135,7 @@ module.exports = __webpack_require__; \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "alpha"; @@ -139,6 +147,7 @@ module.exports = "alpha"; \**************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "a"; @@ -150,6 +159,7 @@ module.exports = "a"; \*********************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "module"; @@ -172,8 +182,8 @@ module.exports = "module"; Hash: 6d91db854aef9bf446d4 Version: webpack next Asset Size Chunks Chunk Names - MyDll.beta.js 3.23 KiB 0 [emitted] beta -MyDll.alpha.js 3.26 KiB 1 [emitted] alpha + MyDll.beta.js 3.7 KiB 0 [emitted] beta +MyDll.alpha.js 3.73 KiB 1 [emitted] alpha Entrypoint alpha = MyDll.alpha.js Entrypoint beta = MyDll.beta.js chunk {0} MyDll.beta.js (beta) 80 bytes [entry] [rendered] @@ -210,8 +220,8 @@ chunk {1} MyDll.alpha.js (alpha) 84 bytes [entry] [rendered] Hash: 6d91db854aef9bf446d4 Version: webpack next Asset Size Chunks Chunk Names - MyDll.beta.js 627 bytes 0 [emitted] beta -MyDll.alpha.js 628 bytes 1 [emitted] alpha + MyDll.beta.js 693 bytes 0 [emitted] beta +MyDll.alpha.js 694 bytes 1 [emitted] alpha Entrypoint alpha = MyDll.alpha.js Entrypoint beta = MyDll.beta.js chunk {0} MyDll.beta.js (beta) 80 bytes [entry] [rendered] diff --git a/examples/explicit-vendor-chunk/README.md b/examples/explicit-vendor-chunk/README.md index 3bb433567..082d47799 100644 --- a/examples/explicit-vendor-chunk/README.md +++ b/examples/explicit-vendor-chunk/README.md @@ -6,6 +6,7 @@ var webpack = require("../../"); module.exports = [ { name: "vendor", + mode: "production", entry: ["./vendor", "./vendor2"], output: { path: path.resolve(__dirname, "js"), @@ -21,6 +22,7 @@ module.exports = [ }, { name: "app", + mode: "production", dependencies: ["vendor"], entry: { pageA: "./pageA", @@ -94,6 +96,11 @@ var vendor_a1ad01d338e7658692f6 = /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -125,6 +132,7 @@ var vendor_a1ad01d338e7658692f6 = \****************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__; @@ -136,6 +144,7 @@ module.exports = __webpack_require__; \*******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "Vendor"; @@ -147,6 +156,7 @@ module.exports = "Vendor"; \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "Vendor2"; @@ -204,6 +214,11 @@ module.exports = "Vendor2"; /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -230,6 +245,7 @@ module.exports = "Vendor2"; \**********************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = vendor_a1ad01d338e7658692f6; @@ -241,6 +257,7 @@ module.exports = vendor_a1ad01d338e7658692f6; \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { console.log(__webpack_require__(/*! ./vendor */ 2)); @@ -253,6 +270,7 @@ module.exports = "pageA"; \****************************************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = (__webpack_require__(0))(1); @@ -271,7 +289,7 @@ Version: webpack next Child vendor: Hash: a1ad01d338e7658692f6 Asset Size Chunks Chunk Names - vendor.js 3.04 KiB 0 [emitted] main + vendor.js 3.44 KiB 0 [emitted] main Entrypoint main = vendor.js chunk {0} vendor.js (main) 65 bytes [entry] [rendered] > main [0] dll main @@ -287,9 +305,9 @@ Child vendor: Child app: Hash: d3ecdb631728091b943f Asset Size Chunks Chunk Names - pageB.js 3.38 KiB 0 [emitted] pageB - pageA.js 3.35 KiB 1 [emitted] pageA - pageC.js 2.57 KiB 2 [emitted] pageC + pageB.js 3.77 KiB 0 [emitted] pageB + pageA.js 3.75 KiB 1 [emitted] pageA + pageC.js 2.83 KiB 2 [emitted] pageC Entrypoint pageA = pageA.js Entrypoint pageB = pageB.js Entrypoint pageC = pageC.js @@ -325,7 +343,7 @@ Version: webpack next Child vendor: Hash: a1ad01d338e7658692f6 Asset Size Chunks Chunk Names - vendor.js 602 bytes 0 [emitted] main + vendor.js 668 bytes 0 [emitted] main Entrypoint main = vendor.js chunk {0} vendor.js (main) 65 bytes [entry] [rendered] > main [0] dll main @@ -341,9 +359,9 @@ Child vendor: Child app: Hash: d3ecdb631728091b943f Asset Size Chunks Chunk Names - pageB.js 609 bytes 0 [emitted] pageB - pageA.js 607 bytes 1 [emitted] pageA - pageC.js 501 bytes 2 [emitted] pageC + pageB.js 675 bytes 0 [emitted] pageB + pageA.js 673 bytes 1 [emitted] pageA + pageC.js 567 bytes 2 [emitted] pageC Entrypoint pageA = pageA.js Entrypoint pageB = pageB.js Entrypoint pageC = pageC.js diff --git a/examples/externals/README.md b/examples/externals/README.md index 089f3e35a..f1e2ac02e 100644 --- a/examples/externals/README.md +++ b/examples/externals/README.md @@ -28,6 +28,7 @@ exports.exampleValue = subtract(add(42, 2), 2); ``` javascript module.exports = { + mode: "production", output: { libraryTarget: "umd" }, @@ -108,6 +109,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -139,6 +145,7 @@ return /******/ (function(modules) { // webpackBootstrap \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var add = __webpack_require__(/*! add */ 1); @@ -153,6 +160,7 @@ exports.exampleValue = subtract(add(42, 2), 2); \**********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE__1__; @@ -164,6 +172,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__1__; \***************************************************************************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = __WEBPACK_EXTERNAL_MODULE__2__; @@ -181,7 +190,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__2__; Hash: ffa746601696f82316c5 Version: webpack next Asset Size Chunks Chunk Names -output.js 4.04 KiB 0 [emitted] main +output.js 4.43 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 197 bytes [entry] [rendered] > main [0] ./example.js @@ -198,8 +207,8 @@ chunk {0} output.js (main) 197 bytes [entry] [rendered] ``` Hash: ffa746601696f82316c5 Version: webpack next - Asset Size Chunks Chunk Names -output.js 978 bytes 0 [emitted] main + Asset Size Chunks Chunk Names +output.js 1.02 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 197 bytes [entry] [rendered] > main [0] ./example.js diff --git a/examples/extra-async-chunk-advanced/README.md b/examples/extra-async-chunk-advanced/README.md index 2c1676f06..27cafd1e9 100644 --- a/examples/extra-async-chunk-advanced/README.md +++ b/examples/extra-async-chunk-advanced/README.md @@ -27,6 +27,7 @@ require.ensure(["./a", "./e"], function(require) { var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", plugins: [ new CommonsChunkPlugin({ name: "main", @@ -184,6 +185,11 @@ module.exports = { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -225,6 +231,7 @@ module.exports = { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { Promise.all/* require */([__webpack_require__.e(4), __webpack_require__.e(0), __webpack_require__.e(1)]).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./a */ 0), __webpack_require__(/*! ./b */ 1), __webpack_require__(/*! ./c */ 3)]; ((function(a, b, c) {}).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}).catch(__webpack_require__.oe); @@ -258,14 +265,14 @@ Promise.all/* require.ensure */([__webpack_require__.e(2), __webpack_require__.e Hash: 6f9e0a4c7e6408844aaa Version: webpack next Asset Size Chunks Chunk Names -0.output.js 271 bytes 0 [emitted] async2 -1.output.js 262 bytes 1 [emitted] async1 -2.output.js 265 bytes 2 [emitted] -3.output.js 265 bytes 3 [emitted] -4.output.js 265 bytes 4 [emitted] -5.output.js 265 bytes 5 [emitted] -6.output.js 265 bytes 6 [emitted] - output.js 7.86 KiB 7 [emitted] main +0.output.js 342 bytes 0 [emitted] async2 +1.output.js 333 bytes 1 [emitted] async1 +2.output.js 336 bytes 2 [emitted] +3.output.js 336 bytes 3 [emitted] +4.output.js 336 bytes 4 [emitted] +5.output.js 336 bytes 5 [emitted] +6.output.js 336 bytes 6 [emitted] + output.js 8.12 KiB 7 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js (async2) 21 bytes {2} {7} [rendered] > async commons duplicate [2] ./example.js 1:0-52 @@ -325,7 +332,7 @@ Version: webpack next 4.output.js 91 bytes 4 [emitted] 5.output.js 91 bytes 5 [emitted] 6.output.js 91 bytes 6 [emitted] - output.js 1.95 KiB 7 [emitted] main + output.js 2.01 KiB 7 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js (async2) 21 bytes {2} {7} [rendered] > async commons duplicate [2] ./example.js 1:0-52 diff --git a/examples/extra-async-chunk/README.md b/examples/extra-async-chunk/README.md index 29787b0ea..159209352 100644 --- a/examples/extra-async-chunk/README.md +++ b/examples/extra-async-chunk/README.md @@ -51,6 +51,7 @@ require.ensure(["./a"], function(require) { var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", plugins: [ new CommonsChunkPlugin({ // process all children of the main chunk @@ -204,6 +205,11 @@ module.exports = { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -245,6 +251,7 @@ module.exports = { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { // a chunks with a, b, c @@ -272,6 +279,7 @@ Promise.all/* require.ensure */([__webpack_require__.e(0), __webpack_require__.e \**************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "a"; @@ -283,6 +291,7 @@ module.exports = "a"; \**************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "b"; @@ -302,6 +311,7 @@ module.exports = "b"; \**************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "d"; @@ -322,6 +332,7 @@ module.exports = "d"; \**************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "c"; @@ -339,10 +350,10 @@ module.exports = "c"; Hash: 7fbb1fd30d6b2c043e7a Version: webpack next Asset Size Chunks Chunk Names -0.output.js 453 bytes 0 [emitted] -1.output.js 265 bytes 1 [emitted] -2.output.js 265 bytes 2 [emitted] - output.js 7.21 KiB 3 [emitted] main +0.output.js 595 bytes 0 [emitted] +1.output.js 336 bytes 1 [emitted] +2.output.js 336 bytes 2 [emitted] + output.js 7.47 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 42 bytes {3} [rendered] > async commons [2] ./example.js 2:0-52 @@ -376,7 +387,7 @@ Version: webpack next 0.output.js 118 bytes 0 [emitted] 1.output.js 91 bytes 1 [emitted] 2.output.js 91 bytes 2 [emitted] - output.js 1.71 KiB 3 [emitted] main + output.js 1.77 KiB 3 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 42 bytes {3} [rendered] > async commons [2] ./example.js 2:0-52 diff --git a/examples/harmony-interop/README.md b/examples/harmony-interop/README.md index 9d29c7a6a..211763216 100644 --- a/examples/harmony-interop/README.md +++ b/examples/harmony-interop/README.md @@ -115,6 +115,11 @@ export var named = "named"; /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -146,6 +151,7 @@ export var named = "named"; \***************/ /*! no static exports found */ /*! exports used: default, readFile */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // an example CommonJs module @@ -164,6 +170,7 @@ exports.readFile = function() {}; \******************************/ /*! no static exports found */ /*! exports used: readFile */ +/*! ModuleConcatenation bailout: Module exports are unknown */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -187,10 +194,11 @@ exports.readFile = function() {}; \********************/ /*! no exports provided */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is an entry point */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +__webpack_require__.r(__webpack_exports__); /* harmony import */ var _fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fs */0); /* harmony import */ var _fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_fs__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _reexport_commonjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./reexport-commonjs */1); @@ -220,6 +228,7 @@ Object(_reexport_commonjs__WEBPACK_IMPORTED_MODULE_1__["readFile"])("file"); !*** ./example2.js ***! \*********************/ /*! no static exports found */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { // CommonJs module @@ -238,10 +247,11 @@ var namedExport = module.named; \********************/ /*! exports provided: default, named */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./example2.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +__webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "named", function() { return named; }); // just some exports /* harmony default export */ __webpack_exports__["default"] = ("default"); @@ -260,7 +270,7 @@ var named = "named"; Hash: c8a9aa827dcceedede06 Version: webpack next Asset Size Chunks Chunk Names -output.js 5.99 KiB 0 [emitted] main +output.js 6.52 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 1.17 KiB [entry] [rendered] > main [2] ./example.js @@ -294,8 +304,8 @@ chunk {0} output.js (main) 1.17 KiB [entry] [rendered] ``` Hash: c8a9aa827dcceedede06 Version: webpack next - Asset Size Chunks Chunk Names -output.js 1010 bytes 0 [emitted] main + Asset Size Chunks Chunk Names +output.js 995 bytes 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 1.17 KiB [entry] [rendered] > main [2] ./example.js diff --git a/examples/harmony-library/README.md b/examples/harmony-library/README.md index 56f99cf67..76e615e8f 100644 --- a/examples/harmony-library/README.md +++ b/examples/harmony-library/README.md @@ -3,6 +3,7 @@ ``` javascript var path = require("path"); module.exports = { + mode: "production", entry: "./example", output: { path: path.join(__dirname, "js"), @@ -76,6 +77,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -107,10 +113,11 @@ return /******/ (function(modules) { // webpackBootstrap \********************/ /*! exports provided: value, increment, default */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is an entry point */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +__webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "value", function() { return value; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "increment", function() { return increment; }); var value = 0; @@ -133,7 +140,7 @@ function increment() { Hash: 3644f1adc4c521a71110 Version: webpack next Asset Size Chunks Chunk Names -MyLibrary.umd.js 3.41 KiB 0 [emitted] main +MyLibrary.umd.js 3.63 KiB 0 [emitted] main Entrypoint main = MyLibrary.umd.js chunk {0} MyLibrary.umd.js (main) 97 bytes [entry] [rendered] > main [0] ./example.js @@ -148,7 +155,7 @@ chunk {0} MyLibrary.umd.js (main) 97 bytes [entry] [rendered] Hash: 3644f1adc4c521a71110 Version: webpack next Asset Size Chunks Chunk Names -MyLibrary.umd.js 898 bytes 0 [emitted] main +MyLibrary.umd.js 922 bytes 0 [emitted] main Entrypoint main = MyLibrary.umd.js chunk {0} MyLibrary.umd.js (main) 97 bytes [entry] [rendered] > main [0] ./example.js diff --git a/examples/harmony-unused/README.md b/examples/harmony-unused/README.md index 4793851fd..a809e30f0 100644 --- a/examples/harmony-unused/README.md +++ b/examples/harmony-unused/README.md @@ -98,6 +98,11 @@ export { add as reexportedAdd, multiply as reexportedMultiply } from "./math"; /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -200,7 +205,7 @@ function c() { console.log("c"); } /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +__webpack_require__.r(__webpack_exports__); /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math */0); /* harmony import */ var _library__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./library */2); @@ -217,7 +222,7 @@ _library__WEBPACK_IMPORTED_MODULE_1__["a" /* reexportedMultiply */](1, 2); # js/output.js ``` javascript -!function(t){function n(e){if(r[e])return r[e].exports;var u=r[e]={i:e,l:!1,exports:{}};return t[e].call(u.exports,u,u.exports,n),u.l=!0,u.exports}var r={};n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:e})},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="js/",n(n.s=3)}([function(t,n,r){"use strict";function e(){for(var t=0,n=0,r=arguments,e=r.length;n main [3] ./example.js @@ -263,7 +268,7 @@ chunk {0} output.js (main) 726 bytes [entry] [rendered] Hash: 2f3a60607ad42261c9ec Version: webpack next Asset Size Chunks Chunk Names -output.js 947 bytes 0 [emitted] main +output.js 971 bytes 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 726 bytes [entry] [rendered] > main [3] ./example.js diff --git a/examples/harmony/README.md b/examples/harmony/README.md index 8c04e4279..ec9a7abaf 100644 --- a/examples/harmony/README.md +++ b/examples/harmony/README.md @@ -161,6 +161,11 @@ export function increment(val) { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -186,7 +191,7 @@ export function increment(val) { /******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]); /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 2); +/******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) /************************************************************************/ ``` @@ -196,33 +201,18 @@ export function increment(val) { ``` javascript /******/ ([ /* 0 */ -/*!**********************!*\ - !*** ./increment.js ***! - \**********************/ -/*! exports provided: increment */ -/*! exports used: increment */ +/*!********************************!*\ + !*** ./example.js + 2 modules ***! + \********************************/ +/*! no exports provided */ +/*! all exports used */ +/*! ModuleConcatenation bailout: Module is an entry point */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return increment; }); -/* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math */1); +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -function increment(val) { - return Object(_math__WEBPACK_IMPORTED_MODULE_0__["a" /* add */])(val, 1); -}; - - -/***/ }), -/* 1 */ -/*!*****************!*\ - !*** ./math.js ***! - \*****************/ -/*! exports provided: add */ -/*! exports used: add */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return add; }); +// CONCATENATED MODULE: ./math.js function add() { var sum = 0, i = 0, args = arguments, l = args.length; while (i < l) { @@ -231,25 +221,19 @@ function add() { return sum; } +// CONCATENATED MODULE: ./increment.js -/***/ }), -/* 2 */ -/*!********************!*\ - !*** ./example.js ***! - \********************/ -/*! no exports provided */ -/*! all exports used */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { +function increment(val) { + return add(val, 1); +}; -"use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var _increment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./increment */0); +// CONCATENATED MODULE: ./example.js var a = 1; -Object(_increment__WEBPACK_IMPORTED_MODULE_0__["a" /* increment */])(a); // 2 +increment(a); // 2 // async loading -__webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! ./async-loaded */3)).then(function(asyncLoaded) { +__webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! ./async-loaded */1)).then(function(asyncLoaded) { console.log(asyncLoaded); }); @@ -263,30 +247,20 @@ __webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! . ## Uncompressed ``` -Hash: f36556ecc2d0c451e273 +Hash: 08e2e1da95639d69a579 Version: webpack next Asset Size Chunks Chunk Names -0.output.js 534 bytes 0 [emitted] - output.js 8.07 KiB 1 [emitted] main +0.output.js 650 bytes 0 [emitted] + output.js 7.46 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 25 bytes {1} [rendered] - > [2] ./example.js 6:0-24 - [3] ./async-loaded.js 25 bytes {0} [built] + > [] 6:0-24 + [1] ./async-loaded.js 25 bytes {0} [built] [exports: answer] - import() ./async-loaded [2] ./example.js 6:0-24 + import() ./async-loaded ./example.js 6:0-24 chunk {1} output.js (main) 419 bytes [entry] [rendered] - > main [2] ./example.js - [0] ./increment.js 94 bytes {1} [built] - [exports: increment] - [only some exports used: increment] - harmony side effect evaluation ./increment [2] ./example.js 1:0-47 - harmony import specifier ./increment [2] ./example.js 3:0-3 - [1] ./math.js 142 bytes {1} [built] - [exports: add] - [only some exports used: add] - harmony side effect evaluation ./math [0] ./increment.js 1:0-29 - harmony import specifier ./math [0] ./increment.js 3:11-14 - [2] ./example.js 183 bytes {1} [built] + > main [] + [0] ./example.js + 2 modules 419 bytes {1} [built] [no exports] single entry .\example.js main ``` @@ -294,30 +268,20 @@ chunk {1} output.js (main) 419 bytes [entry] [rendered] ## Minimized (uglify-js, no zip) ``` -Hash: f36556ecc2d0c451e273 +Hash: 08e2e1da95639d69a579 Version: webpack next Asset Size Chunks Chunk Names -0.output.js 187 bytes 0 [emitted] - output.js 1.9 KiB 1 [emitted] main +0.output.js 144 bytes 0 [emitted] + output.js 1.79 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 25 bytes {1} [rendered] - > [2] ./example.js 6:0-24 - [3] ./async-loaded.js 25 bytes {0} [built] + > [] 6:0-24 + [1] ./async-loaded.js 25 bytes {0} [built] [exports: answer] - import() ./async-loaded [2] ./example.js 6:0-24 + import() ./async-loaded ./example.js 6:0-24 chunk {1} output.js (main) 419 bytes [entry] [rendered] - > main [2] ./example.js - [0] ./increment.js 94 bytes {1} [built] - [exports: increment] - [only some exports used: increment] - harmony side effect evaluation ./increment [2] ./example.js 1:0-47 - harmony import specifier ./increment [2] ./example.js 3:0-3 - [1] ./math.js 142 bytes {1} [built] - [exports: add] - [only some exports used: add] - harmony side effect evaluation ./math [0] ./increment.js 1:0-29 - harmony import specifier ./math [0] ./increment.js 3:11-14 - [2] ./example.js 183 bytes {1} [built] + > main [] + [0] ./example.js + 2 modules 419 bytes {1} [built] [no exports] single entry .\example.js main ``` \ No newline at end of file diff --git a/examples/http2-aggressive-splitting/README.md b/examples/http2-aggressive-splitting/README.md index 6d65ac1ac..48d41f718 100644 --- a/examples/http2-aggressive-splitting/README.md +++ b/examples/http2-aggressive-splitting/README.md @@ -20,6 +20,8 @@ The backward compatibility (non HTTP2 client) improves with bigger `maxSize`, as var path = require("path"); var webpack = require("../../"); module.exports = { + mode: "production", + cache: true, // better performance for the AggressiveSplittingPlugin entry: "./example", output: { path: path.join(__dirname, "js"), @@ -47,21 +49,21 @@ module.exports = { Hash: 855e92ac8cd05846cd47 Version: webpack next Asset Size Chunks Chunk Names -49eabe0be9b855a6ece3.js 51.9 KiB 7 [emitted] -c11db784679b537a5d1b.js 58.8 KiB 0 [emitted] -4ec863f864133b7db4c3.js 54.6 KiB 2 [emitted] -a52b878529cda333614e.js 53.2 KiB 3 [emitted] -2020cd642caa01ec1e86.js 52.7 KiB 4 [emitted] -23c4c0d48e8b38e2a9ea.js 52.1 KiB 5 [emitted] -acbadebce580eb634bb7.js 22.2 KiB 6 [emitted] -727a2eb4c7cff3f84596.js 56.6 KiB 1 [emitted] -fd3f47121db53fb3037b.js 51.3 KiB 8 [emitted] -1d590e6c5541be02dd36.js 51.1 KiB 9 [emitted] -e169ea4c146b4e5d51c0.js 50 KiB 10 [emitted] -0633f8f465e2cabc39b5.js 32.4 KiB 11 [emitted] -940defd566cc7edba267.js 60.1 KiB 12 [emitted] -e298620d755cc0f292cf.js 36.7 KiB 13 [emitted] -1d08b68310160ad06455.js 31.7 KiB 14 [emitted] +49eabe0be9b855a6ece3.js 52.5 KiB 7 [emitted] +c11db784679b537a5d1b.js 60.8 KiB 0 [emitted] +4ec863f864133b7db4c3.js 55.6 KiB 2 [emitted] +a52b878529cda333614e.js 53.9 KiB 3 [emitted] +2020cd642caa01ec1e86.js 53.5 KiB 4 [emitted] +23c4c0d48e8b38e2a9ea.js 52.8 KiB 5 [emitted] +acbadebce580eb634bb7.js 22.8 KiB 6 [emitted] +727a2eb4c7cff3f84596.js 58.3 KiB 1 [emitted] +fd3f47121db53fb3037b.js 51.8 KiB 8 [emitted] +1d590e6c5541be02dd36.js 51.5 KiB 9 [emitted] +e169ea4c146b4e5d51c0.js 50.4 KiB 10 [emitted] +0633f8f465e2cabc39b5.js 32.6 KiB 11 [emitted] +940defd566cc7edba267.js 61.4 KiB 12 [emitted] +e298620d755cc0f292cf.js 37.6 KiB 13 [emitted] +1d08b68310160ad06455.js 31.9 KiB 14 [emitted] Entrypoint main = 940defd566cc7edba267.js 1d08b68310160ad06455.js e298620d755cc0f292cf.js chunk {0} c11db784679b537a5d1b.js 48.5 KiB {12} {13} {14} [rendered] [recorded] > aggressive-splitted [14] ./example.js 2:0-22 @@ -129,7 +131,7 @@ fd3f47121db53fb3037b.js 15.3 KiB 8 [emitted] 1d590e6c5541be02dd36.js 12.6 KiB 9 [emitted] e169ea4c146b4e5d51c0.js 11.2 KiB 10 [emitted] 0633f8f465e2cabc39b5.js 5.02 KiB 11 [emitted] -940defd566cc7edba267.js 10.3 KiB 12 [emitted] +940defd566cc7edba267.js 10.4 KiB 12 [emitted] e298620d755cc0f292cf.js 5.96 KiB 13 [emitted] 1d08b68310160ad06455.js 7.17 KiB 14 [emitted] Entrypoint main = 940defd566cc7edba267.js 1d08b68310160ad06455.js e298620d755cc0f292cf.js diff --git a/examples/hybrid-routing/README.md b/examples/hybrid-routing/README.md index a4634b929..6687c33e5 100644 --- a/examples/hybrid-routing/README.md +++ b/examples/hybrid-routing/README.md @@ -4,6 +4,7 @@ var path = require("path"); var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", entry: { // The entry points for the pages pageA: "./aEntry", @@ -245,6 +246,11 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b" /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -285,6 +291,7 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b" \*******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function(page) { @@ -302,6 +309,7 @@ module.exports = function(page) { \*******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var render = __webpack_require__(/*! ./render */ 0); @@ -337,6 +345,7 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b" \****************************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var map = { @@ -366,6 +375,7 @@ webpackContext.id = 6; \*******************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var cbs = [], @@ -390,6 +400,7 @@ __webpack_require__.e/* require.ensure */(1).then((function(require) { \*******************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var cbs = [], @@ -422,6 +433,7 @@ __webpack_require__.e/* require.ensure */(0).then((function(require) { \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -436,6 +448,7 @@ module.exports = function() { \*******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { // Just show the page "a" @@ -457,6 +470,7 @@ render(__webpack_require__(/*! ./aPage */ 1)); \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -475,11 +489,11 @@ module.exports = function() { Hash: a9c98a6416be93f3fdf3 Version: webpack next Asset Size Chunks Chunk Names - 0.chunk.js 317 bytes 0 [emitted] - 1.chunk.js 323 bytes 1 [emitted] -pageB.bundle.js 686 bytes 2, 0 [emitted] pageB -pageA.bundle.js 677 bytes 3, 1 [emitted] pageA - commons.js 10.6 KiB 4 [emitted] commons + 0.chunk.js 388 bytes 0 [emitted] + 1.chunk.js 394 bytes 1 [emitted] +pageB.bundle.js 828 bytes 2, 0 [emitted] pageB +pageA.bundle.js 819 bytes 3, 1 [emitted] pageA + commons.js 11.1 KiB 4 [emitted] commons Entrypoint pageA = commons.js pageA.bundle.js Entrypoint pageB = commons.js pageB.bundle.js Entrypoint commons = commons.js @@ -533,7 +547,7 @@ Version: webpack next 1.chunk.js 122 bytes 1 [emitted] pageB.bundle.js 164 bytes 2, 0 [emitted] pageB pageA.bundle.js 163 bytes 3, 1 [emitted] pageA - commons.js 2.4 KiB 4 [emitted] commons + commons.js 2.46 KiB 4 [emitted] commons Entrypoint pageA = commons.js pageA.bundle.js Entrypoint pageB = commons.js pageB.bundle.js Entrypoint commons = commons.js diff --git a/examples/i18n/README.md b/examples/i18n/README.md index c6ec72a3d..e9211c4bd 100644 --- a/examples/i18n/README.md +++ b/examples/i18n/README.md @@ -24,6 +24,7 @@ var languages = { module.exports = Object.keys(languages).map(function(language) { return { name: language, + mode: "production", entry: "./example", output: { path: path.join(__dirname, "js"), @@ -97,6 +98,11 @@ module.exports = Object.keys(languages).map(function(language) { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -128,6 +134,7 @@ module.exports = Object.keys(languages).map(function(language) { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { console.log("Hallo Welt"); @@ -186,6 +193,11 @@ console.log("Missing Text"); /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -212,6 +224,7 @@ console.log("Missing Text"); \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { console.log("Hello World"); @@ -231,7 +244,7 @@ Version: webpack next Child en: Hash: 8a5f1b2749a468f6c191 Asset Size Chunks Chunk Names - en.output.js 2.62 KiB 0 [emitted] main + en.output.js 2.88 KiB 0 [emitted] main Entrypoint main = en.output.js chunk {0} en.output.js (main) 65 bytes [entry] [rendered] > main [0] ./example.js @@ -240,7 +253,7 @@ Child en: Child de: Hash: a24548b478fddc0ef618 Asset Size Chunks Chunk Names - de.output.js 2.62 KiB 0 [emitted] main + de.output.js 2.88 KiB 0 [emitted] main Entrypoint main = de.output.js chunk {0} de.output.js (main) 65 bytes [entry] [rendered] > main [0] ./example.js @@ -259,7 +272,7 @@ Version: webpack next Child en: Hash: 8a5f1b2749a468f6c191 Asset Size Chunks Chunk Names - en.output.js 538 bytes 0 [emitted] main + en.output.js 604 bytes 0 [emitted] main Entrypoint main = en.output.js chunk {0} en.output.js (main) 65 bytes [entry] [rendered] > main [0] ./example.js @@ -268,7 +281,7 @@ Child en: Child de: Hash: a24548b478fddc0ef618 Asset Size Chunks Chunk Names - de.output.js 537 bytes 0 [emitted] main + de.output.js 603 bytes 0 [emitted] main Entrypoint main = de.output.js chunk {0} de.output.js (main) 65 bytes [entry] [rendered] > main [0] ./example.js diff --git a/examples/loader/README.md b/examples/loader/README.md index 60b71997b..480c1e347 100644 --- a/examples/loader/README.md +++ b/examples/loader/README.md @@ -82,6 +82,11 @@ module.exports = function(content) { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -113,6 +118,7 @@ module.exports = function(content) { \****************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { exports = module.exports = __webpack_require__(/*! ../../node_modules/css-loader/lib/css-base.js */ 3)(undefined); @@ -132,6 +138,7 @@ exports.push([module.i, ".some-class {\r\n\tcolor: hotpink;\r\n}\r\n", ""]); \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { // use our loader @@ -149,6 +156,7 @@ console.dir(__webpack_require__(/*! css-loader!./test.css */ 0)); // manual \*****************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { exports.answer = 42; @@ -161,6 +169,7 @@ exports.foo = "bar"; \*********************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { /* @@ -262,8 +271,8 @@ Prints in node.js (`enhanced-require example.js`) and in browser: ``` Hash: cb0ecece43c771e1f9e7 Version: webpack next - Asset Size Chunks Chunk Names -output.js 6.1 KiB 0 [emitted] main + Asset Size Chunks Chunk Names +output.js 6.56 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 2.66 KiB [entry] [rendered] > main [1] ./example.js @@ -283,7 +292,7 @@ chunk {0} output.js (main) 2.66 KiB [entry] [rendered] Hash: 362753a4b9c9758ad0e2 Version: webpack next Asset Size Chunks Chunk Names -output.js 1.45 KiB 0 [emitted] main +output.js 1.51 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 2.64 KiB [entry] [rendered] > main [1] ./example.js diff --git a/examples/mixed/README.md b/examples/mixed/README.md index ca6a6572c..10427121e 100644 --- a/examples/mixed/README.md +++ b/examples/mixed/README.md @@ -194,6 +194,11 @@ require( /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -234,6 +239,7 @@ require( \*********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { // CommonJs Module Format @@ -252,6 +258,7 @@ new Promise(function(resolve) { resolve(); }).then(function() { var __WEBPACK_AM \****************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// AMD Module Format @@ -271,10 +278,11 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// AMD Module Fo \********************/ /*! exports provided: default */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./amd.js (referenced with amd require, cjs require), ./commonjs.js (referenced with amd require, cjs require), ./example.js (referenced with cjs require) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +__webpack_require__.r(__webpack_exports__); /* harmony import */ var _commonjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./commonjs */0); /* harmony import */ var _commonjs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_commonjs__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _amd__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./amd */1); @@ -293,6 +301,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { // CommonJs-style requires @@ -327,6 +336,7 @@ __webpack_require__.e/* require */(0).then(function() { var __WEBPACK_AMD_REQUIR \******************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var map = { @@ -357,6 +367,7 @@ webpackContext.id = 4; \*****************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -370,6 +381,7 @@ module.exports = function() { \*****************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -383,6 +395,7 @@ module.exports = function() { \*****************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -401,8 +414,8 @@ module.exports = function() { Hash: c5e217711d33e344c3e3 Version: webpack next Asset Size Chunks Chunk Names -0.output.js 1.88 KiB 0 [emitted] - output.js 9.66 KiB 1 [emitted] main +0.output.js 2.16 KiB 0 [emitted] + output.js 10.3 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 439 bytes {1} [rendered] > [3] ./example.js 7:0-14:1 @@ -448,7 +461,7 @@ Hash: c5e217711d33e344c3e3 Version: webpack next Asset Size Chunks Chunk Names 0.output.js 563 bytes 0 [emitted] - output.js 2.02 KiB 1 [emitted] main + output.js 2.05 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 439 bytes {1} [rendered] > [3] ./example.js 7:0-14:1 diff --git a/examples/move-to-parent/README.md b/examples/move-to-parent/README.md index 87315b26c..e261ccc7f 100644 --- a/examples/move-to-parent/README.md +++ b/examples/move-to-parent/README.md @@ -49,12 +49,14 @@ var outputOptions = { }; module.exports = [{ name: "page", + mode: "production", entry: { page: "./page" }, output: outputOptions }, { name: "pageA", + mode: "production", entry: { pageA: "./page" }, @@ -68,6 +70,7 @@ module.exports = [{ ] }, { name: "pageB", + mode: "production", entry: { pageB: "./page" }, @@ -82,6 +85,7 @@ module.exports = [{ ] }, { name: "pageC", + mode: "production", entry: { pageC: "./page" }, @@ -110,11 +114,11 @@ Version: webpack next Child page: Hash: 177cb4f87a649dcf8f69 Asset Size Chunks Chunk Names - 0.chunk.js 850 bytes 0, 1, 2, 3 [emitted] - 1.chunk.js 648 bytes 1, 2, 3 [emitted] - 2.chunk.js 455 bytes 2, 3 [emitted] - 3.chunk.js 262 bytes 3 [emitted] - page.bundle.js 7.26 KiB 4 [emitted] page + 0.chunk.js 1.11 KiB 0, 1, 2, 3 [emitted] + 1.chunk.js 861 bytes 1, 2, 3 [emitted] + 2.chunk.js 597 bytes 2, 3 [emitted] + 3.chunk.js 333 bytes 3 [emitted] + page.bundle.js 7.52 KiB 4 [emitted] page Entrypoint page = page.bundle.js chunk {0} 0.chunk.js 84 bytes {4} [rendered] > [3] ./page.js 4:0-37 @@ -140,10 +144,10 @@ Child page: Child pageA: Hash: 5390da5dc6be017898dd Asset Size Chunks Chunk Names - 0.chunk.js 666 bytes 0, 1, 2 [emitted] - 1.chunk.js 464 bytes 1, 2 [emitted] - 2.chunk.js 271 bytes 2 [emitted] - pageA.bundle.js 7.47 KiB 3 [emitted] pageA + 0.chunk.js 879 bytes 0, 1, 2 [emitted] + 1.chunk.js 606 bytes 1, 2 [emitted] + 2.chunk.js 342 bytes 2 [emitted] + pageA.bundle.js 7.8 KiB 3 [emitted] pageA Entrypoint pageA = pageA.bundle.js chunk {0} 0.chunk.js 63 bytes {3} [rendered] > [3] ./page.js 4:0-37 @@ -164,9 +168,9 @@ Child pageA: Child pageB: Hash: c8f0b2530347cda025f3 Asset Size Chunks Chunk Names - 0.chunk.js 482 bytes 0, 1 [emitted] - 1.chunk.js 265 bytes 1 [emitted] - pageB.bundle.js 7.66 KiB 2 [emitted] pageB + 0.chunk.js 624 bytes 0, 1 [emitted] + 1.chunk.js 336 bytes 1 [emitted] + pageB.bundle.js 8.05 KiB 2 [emitted] pageB Entrypoint pageB = pageB.bundle.js chunk {0} 0.chunk.js 42 bytes {2} [rendered] > [3] ./page.js 4:0-37 @@ -183,8 +187,8 @@ Child pageB: Child pageC: Hash: 3bed15ba96ffc9d826c2 Asset Size Chunks Chunk Names - 0.chunk.js 271 bytes 0 [emitted] - pageC.bundle.js 7.88 KiB 1 [emitted] pageC + 0.chunk.js 342 bytes 0 [emitted] + pageC.bundle.js 8.35 KiB 1 [emitted] pageC Entrypoint pageC = pageC.bundle.js chunk {0} 0.chunk.js 21 bytes {1} [rendered] > duplicate [3] ./page.js 2:0-23 @@ -211,7 +215,7 @@ Child page: 1.chunk.js 151 bytes 1, 2, 3 [emitted] 2.chunk.js 120 bytes 2, 3 [emitted] 3.chunk.js 89 bytes 3 [emitted] - page.bundle.js 1.71 KiB 4 [emitted] page + page.bundle.js 1.77 KiB 4 [emitted] page Entrypoint page = page.bundle.js chunk {0} 0.chunk.js 84 bytes {4} [rendered] > [3] ./page.js 4:0-37 @@ -240,7 +244,7 @@ Child pageA: 0.chunk.js 153 bytes 0, 1, 2 [emitted] 1.chunk.js 121 bytes 1, 2 [emitted] 2.chunk.js 90 bytes 2 [emitted] - pageA.bundle.js 1.76 KiB 3 [emitted] pageA + pageA.bundle.js 1.82 KiB 3 [emitted] pageA Entrypoint pageA = pageA.bundle.js chunk {0} 0.chunk.js 63 bytes {3} [rendered] > [3] ./page.js 4:0-37 @@ -263,7 +267,7 @@ Child pageB: Asset Size Chunks Chunk Names 0.chunk.js 123 bytes 0, 1 [emitted] 1.chunk.js 91 bytes 1 [emitted] - pageB.bundle.js 1.81 KiB 2 [emitted] pageB + pageB.bundle.js 1.87 KiB 2 [emitted] pageB Entrypoint pageB = pageB.bundle.js chunk {0} 0.chunk.js 42 bytes {2} [rendered] > [3] ./page.js 4:0-37 @@ -281,7 +285,7 @@ Child pageC: Hash: 3bed15ba96ffc9d826c2 Asset Size Chunks Chunk Names 0.chunk.js 90 bytes 0 [emitted] - pageC.bundle.js 1.81 KiB 1 [emitted] pageC + pageC.bundle.js 1.88 KiB 1 [emitted] pageC Entrypoint pageC = pageC.bundle.js chunk {0} 0.chunk.js 21 bytes {1} [rendered] > duplicate [3] ./page.js 2:0-23 diff --git a/examples/multi-compiler/README.md b/examples/multi-compiler/README.md index e03534c8b..05740c0da 100644 --- a/examples/multi-compiler/README.md +++ b/examples/multi-compiler/README.md @@ -16,6 +16,7 @@ var webpack = require("../../"); module.exports = [ { name: "mobile", + mode: "production", entry: "./example", output: { path: path.join(__dirname, "js"), @@ -29,6 +30,7 @@ module.exports = [ }, { name: "desktop", + mode: "production", entry: "./example", output: { path: path.join(__dirname, "js"), @@ -94,6 +96,11 @@ module.exports = [ /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -125,6 +132,7 @@ module.exports = [ \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { if(false) { @@ -185,6 +193,11 @@ console.log("Running " + "desktop" + " build"); /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -211,6 +224,7 @@ console.log("Running " + "desktop" + " build"); \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { if(true) { @@ -225,6 +239,7 @@ console.log("Running " + "mobile" + " build"); \*************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // mobile only stuff @@ -243,7 +258,7 @@ Version: webpack next Child mobile: Hash: 38f1b6745f2b6ecb12f3 Asset Size Chunks Chunk Names - mobile.js 2.89 KiB 0 [emitted] main + mobile.js 3.22 KiB 0 [emitted] main Entrypoint main = mobile.js chunk {0} mobile.js (main) 117 bytes [entry] [rendered] > main [0] ./example.js @@ -254,7 +269,7 @@ Child mobile: Child desktop: Hash: dc51c5defcd12cfd66b4 Asset Size Chunks Chunk Names - desktop.js 2.66 KiB 0 [emitted] main + desktop.js 2.91 KiB 0 [emitted] main Entrypoint main = desktop.js chunk {0} desktop.js (main) 97 bytes [entry] [rendered] > main [0] ./example.js @@ -270,7 +285,7 @@ Version: webpack next Child mobile: Hash: 38f1b6745f2b6ecb12f3 Asset Size Chunks Chunk Names - mobile.js 540 bytes 0 [emitted] main + mobile.js 606 bytes 0 [emitted] main Entrypoint main = mobile.js chunk {0} mobile.js (main) 117 bytes [entry] [rendered] > main [0] ./example.js @@ -281,7 +296,7 @@ Child mobile: Child desktop: Hash: dc51c5defcd12cfd66b4 Asset Size Chunks Chunk Names - desktop.js 520 bytes 0 [emitted] main + desktop.js 586 bytes 0 [emitted] main Entrypoint main = desktop.js chunk {0} desktop.js (main) 97 bytes [entry] [rendered] > main [0] ./example.js diff --git a/examples/multi-part-library/README.md b/examples/multi-part-library/README.md index d73d0887c..326e2ea70 100644 --- a/examples/multi-part-library/README.md +++ b/examples/multi-part-library/README.md @@ -17,6 +17,7 @@ Note: When your library has dependencies that should not be included in the comp ``` javascript var path = require("path"); module.exports = { + mode: "production", entry: { alpha: "./alpha", beta: "./beta" @@ -93,6 +94,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -124,6 +130,7 @@ return /******/ (function(modules) { // webpackBootstrap \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "alpha"; @@ -192,6 +199,11 @@ return /******/ (function(modules) { // webpackBootstrap /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -219,6 +231,7 @@ return /******/ (function(modules) { // webpackBootstrap \*****************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "beta"; @@ -233,11 +246,11 @@ module.exports = "beta"; ## Uncompressed ``` -Hash: 50ee6e3a1b476054872d +Hash: 17fa97a0dfa6b745377a Version: webpack next Asset Size Chunks Chunk Names - MyLibrary.beta.js 2.98 KiB 0 [emitted] beta -MyLibrary.alpha.js 2.98 KiB 1 [emitted] alpha + MyLibrary.beta.js 3.24 KiB 0 [emitted] beta +MyLibrary.alpha.js 3.24 KiB 1 [emitted] alpha Entrypoint alpha = MyLibrary.alpha.js Entrypoint beta = MyLibrary.beta.js chunk {0} MyLibrary.beta.js (beta) 24 bytes [entry] [rendered] @@ -253,11 +266,11 @@ chunk {1} MyLibrary.alpha.js (alpha) 25 bytes [entry] [rendered] ## Minimized (uglify-js, no zip) ``` -Hash: 50ee6e3a1b476054872d +Hash: 17fa97a0dfa6b745377a Version: webpack next Asset Size Chunks Chunk Names - MyLibrary.beta.js 759 bytes 0 [emitted] beta -MyLibrary.alpha.js 761 bytes 1 [emitted] alpha + MyLibrary.beta.js 825 bytes 0 [emitted] beta +MyLibrary.alpha.js 827 bytes 1 [emitted] alpha Entrypoint alpha = MyLibrary.alpha.js Entrypoint beta = MyLibrary.beta.js chunk {0} MyLibrary.beta.js (beta) 24 bytes [entry] [rendered] diff --git a/examples/multiple-commons-chunks/README.md b/examples/multiple-commons-chunks/README.md index 803d9b5c0..b9c900bb4 100644 --- a/examples/multiple-commons-chunks/README.md +++ b/examples/multiple-commons-chunks/README.md @@ -19,6 +19,7 @@ require("./modules/admin"); var path = require("path"); var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", entry: { pageA: "./pageA", pageB: "./pageB", @@ -229,6 +230,11 @@ module.exports = { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -266,6 +272,7 @@ module.exports = { \**************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { @@ -280,6 +287,7 @@ module.exports = { \************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { @@ -299,6 +307,7 @@ module.exports = { \************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { @@ -311,6 +320,7 @@ module.exports = { \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(/*! ./modules/a-b-c */ 0); @@ -334,6 +344,7 @@ __webpack_require__(/*! ./modules/a-c */ 2); \**************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { @@ -353,6 +364,7 @@ __webpack_require__(/*! ./modules/a-c */ 2); \***********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(/*! ./modules/a-b-c */ 0); @@ -371,15 +383,15 @@ __webpack_require__(/*! ./modules/admin */ 1); Hash: aae3eb52e46997530381 Version: webpack next Asset Size Chunks Chunk Names - pageC.js 869 bytes 0 [emitted] pageC - pageB.js 629 bytes 1 [emitted] pageB - pageA.js 629 bytes 2 [emitted] pageA - adminPageC.js 608 bytes 3, 4 [emitted] adminPageC -admin-commons.js 286 bytes 4 [emitted] admin-commons - adminPageB.js 398 bytes 5 [emitted] adminPageB - adminPageA.js 398 bytes 6 [emitted] adminPageA - commons.js 7.3 KiB 7, 8 [emitted] commons - c-commons.js 7.06 KiB 8 [emitted] c-commons + pageC.js 1.06 KiB 0 [emitted] pageC + pageB.js 771 bytes 1 [emitted] pageB + pageA.js 771 bytes 2 [emitted] pageA + adminPageC.js 750 bytes 3, 4 [emitted] adminPageC +admin-commons.js 357 bytes 4 [emitted] admin-commons + adminPageB.js 469 bytes 5 [emitted] adminPageB + adminPageA.js 469 bytes 6 [emitted] adminPageA + commons.js 7.62 KiB 7, 8 [emitted] commons + c-commons.js 7.32 KiB 8 [emitted] c-commons Entrypoint pageA = commons.js pageA.js Entrypoint pageB = commons.js pageB.js Entrypoint pageC = c-commons.js pageC.js @@ -465,8 +477,8 @@ Version: webpack next admin-commons.js 77 bytes 4 [emitted] admin-commons adminPageB.js 101 bytes 5 [emitted] adminPageB adminPageA.js 101 bytes 6 [emitted] adminPageA - commons.js 1.68 KiB 7, 8 [emitted] commons - c-commons.js 1.66 KiB 8 [emitted] c-commons + commons.js 1.74 KiB 7, 8 [emitted] commons + c-commons.js 1.72 KiB 8 [emitted] c-commons Entrypoint pageA = commons.js pageA.js Entrypoint pageB = commons.js pageB.js Entrypoint pageC = c-commons.js pageC.js diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/README.md b/examples/multiple-entry-points-commons-chunk-css-bundle/README.md index cdebe6fb3..303de3251 100644 --- a/examples/multiple-entry-points-commons-chunk-css-bundle/README.md +++ b/examples/multiple-entry-points-commons-chunk-css-bundle/README.md @@ -60,6 +60,7 @@ const LoaderOptionsPlugin = require("../../lib/LoaderOptionsPlugin"); const CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { + mode: "production", entry: { A: "./a", B: "./b", @@ -109,6 +110,7 @@ module.exports = { \**************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(/*! ./style.css */ 0); @@ -122,6 +124,7 @@ __webpack_require__(/*! ./styleA.css */ 2); \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // removed by extract-text-webpack-plugin @@ -197,10 +200,10 @@ d090b6fba0f6d326d282a19146ff54a7.png 120 bytes [emitted] 16155c689e517682064c99893cb832cc.png 120 bytes [emitted] ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted] c2a2f62d69330b7d787782f5010f9d13.png 120 bytes [emitted] - B.js 617 bytes 0 [emitted] B - A.js 599 bytes 1 [emitted] A - C.js 2.82 KiB 2 [emitted] C - commons.js 7.08 KiB 3 [emitted] commons + B.js 759 bytes 0 [emitted] B + A.js 741 bytes 1 [emitted] A + C.js 3.15 KiB 2 [emitted] C + commons.js 7.33 KiB 3 [emitted] commons C.css 140 bytes 2 [emitted] C commons.css 209 bytes 3 [emitted] commons Entrypoint A = commons.js commons.css A.js @@ -286,8 +289,8 @@ ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted] c2a2f62d69330b7d787782f5010f9d13.png 120 bytes [emitted] B.js 116 bytes 0 [emitted] B A.js 114 bytes 1 [emitted] A - C.js 508 bytes 2 [emitted] C - commons.js 1.66 KiB 3 [emitted] commons + C.js 574 bytes 2 [emitted] C + commons.js 1.72 KiB 3 [emitted] commons C.css 120 bytes 2 [emitted] C commons.css 179 bytes 3 [emitted] commons Entrypoint A = commons.js commons.css A.js diff --git a/examples/multiple-entry-points/README.md b/examples/multiple-entry-points/README.md index cfe62f5aa..65534ce4d 100644 --- a/examples/multiple-entry-points/README.md +++ b/examples/multiple-entry-points/README.md @@ -51,6 +51,7 @@ require.ensure(["./shared"], function(require) { var path = require("path"); var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", entry: { pageA: "./pageA", pageB: "./pageB" @@ -235,6 +236,11 @@ module.exports = { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -272,6 +278,7 @@ module.exports = { \*******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "Common"; @@ -291,6 +298,7 @@ module.exports = "Common"; \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var common = __webpack_require__(/*! ./common */ 0); @@ -314,6 +322,7 @@ __webpack_require__.e/* require */(0/* duplicate */).then(function() { var __WEB \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var common = __webpack_require__(/*! ./common */ 0); @@ -338,6 +347,7 @@ __webpack_require__.e/* require.ensure */(0/* duplicate */).then((function(requi \*******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var common = __webpack_require__(/*! ./common */ 0); @@ -357,10 +367,10 @@ module.exports = function(msg) { Hash: fff03ff0a6abf2637b15 Version: webpack next Asset Size Chunks Chunk Names - 0.chunk.js 396 bytes 0 [emitted] -pageB.bundle.js 577 bytes 1 [emitted] pageB -pageA.bundle.js 620 bytes 2 [emitted] pageA - commons.js 7.07 KiB 3 [emitted] commons + 0.chunk.js 467 bytes 0 [emitted] +pageB.bundle.js 648 bytes 1 [emitted] pageB +pageA.bundle.js 691 bytes 2 [emitted] pageA + commons.js 7.33 KiB 3 [emitted] commons Entrypoint pageA = commons.js pageA.bundle.js Entrypoint pageB = commons.js pageB.bundle.js chunk {0} 0.chunk.js 91 bytes {1} {2} [rendered] @@ -394,7 +404,7 @@ Version: webpack next 0.chunk.js 121 bytes 0 [emitted] pageB.bundle.js 168 bytes 1 [emitted] pageB pageA.bundle.js 193 bytes 2 [emitted] pageA - commons.js 1.68 KiB 3 [emitted] commons + commons.js 1.74 KiB 3 [emitted] commons Entrypoint pageA = commons.js pageA.bundle.js Entrypoint pageB = commons.js pageB.bundle.js chunk {0} 0.chunk.js 91 bytes {1} {2} [rendered] diff --git a/examples/named-chunks/README.md b/examples/named-chunks/README.md index 1abe31514..56dd353c4 100644 --- a/examples/named-chunks/README.md +++ b/examples/named-chunks/README.md @@ -164,6 +164,11 @@ require.ensure(["b"], function(require) { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -206,6 +211,7 @@ require.ensure(["b"], function(require) { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var a = __webpack_require__(/*! a */ 3); @@ -237,6 +243,7 @@ __webpack_require__.e/* require.ensure */(1).then((function(require) { \***************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // module a @@ -255,6 +262,7 @@ __webpack_require__.e/* require.ensure */(1).then((function(require) { \***************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // module b @@ -266,6 +274,7 @@ __webpack_require__.e/* require.ensure */(1).then((function(require) { \***************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // module d @@ -279,6 +288,7 @@ __webpack_require__.e/* require.ensure */(1).then((function(require) { \***************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // module c @@ -297,6 +307,7 @@ __webpack_require__.e/* require.ensure */(1).then((function(require) { \***************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // module b @@ -308,6 +319,7 @@ __webpack_require__.e/* require.ensure */(1).then((function(require) { \***************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { // module d @@ -324,9 +336,9 @@ __webpack_require__.e/* require.ensure */(1).then((function(require) { Hash: a4fbcc7d664f6f0aeb32 Version: webpack next Asset Size Chunks Chunk Names -0.output.js 751 bytes 0, 1 [emitted] my own chunk -1.output.js 511 bytes 1 [emitted] - output.js 7.68 KiB 2 [emitted] main +0.output.js 964 bytes 0, 1 [emitted] my own chunk +1.output.js 653 bytes 1 [emitted] + output.js 8.01 KiB 2 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js (my own chunk) 33 bytes {2} [rendered] > my own chunk [2] ./example.js 3:0-6:18 @@ -351,7 +363,7 @@ Version: webpack next Asset Size Chunks Chunk Names 0.output.js 112 bytes 0, 1 [emitted] my own chunk 1.output.js 92 bytes 1 [emitted] - output.js 1.75 KiB 2 [emitted] main + output.js 1.81 KiB 2 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js (my own chunk) 33 bytes {2} [rendered] > my own chunk [2] ./example.js 3:0-6:18 diff --git a/examples/require.context/README.md b/examples/require.context/README.md index 96d7a9bdc..64f21a568 100644 --- a/examples/require.context/README.md +++ b/examples/require.context/README.md @@ -73,6 +73,11 @@ module.exports = function() { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -104,6 +109,7 @@ module.exports = function() { \************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -117,6 +123,7 @@ module.exports = function() { \************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -130,6 +137,7 @@ module.exports = function() { \************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -143,6 +151,7 @@ module.exports = function() { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { function getTemplate(templateName) { @@ -158,6 +167,7 @@ console.log(getTemplate("b")); \*********************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var map = { @@ -196,7 +206,7 @@ webpackContext.id = 4; Hash: baa2ff0af1a7df4a1c89 Version: webpack next Asset Size Chunks Chunk Names -output.js 4.32 KiB 0 [emitted] main +output.js 4.85 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 613 bytes [entry] [rendered] > main [3] ./example.js @@ -221,7 +231,7 @@ chunk {0} output.js (main) 613 bytes [entry] [rendered] Hash: baa2ff0af1a7df4a1c89 Version: webpack next Asset Size Chunks Chunk Names -output.js 1.05 KiB 0 [emitted] main +output.js 1.12 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 613 bytes [entry] [rendered] > main [3] ./example.js diff --git a/examples/require.resolve/README.md b/examples/require.resolve/README.md index 60bd6699c..ed7343c06 100644 --- a/examples/require.resolve/README.md +++ b/examples/require.resolve/README.md @@ -74,6 +74,11 @@ module.exports = Math.random(); /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -105,6 +110,7 @@ module.exports = Math.random(); \**************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = Math.random(); @@ -116,6 +122,7 @@ module.exports = Math.random(); \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var a = __webpack_require__(/*! ./a */ 0); @@ -144,7 +151,7 @@ if(a == a2) throw new Error("Cache clear failed :("); Hash: 778b337ad5fd5e1bd1bf Version: webpack next Asset Size Chunks Chunk Names -output.js 3.11 KiB 0 [emitted] main +output.js 3.43 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 326 bytes [entry] [rendered] > main [1] ./example.js @@ -162,7 +169,7 @@ chunk {0} output.js (main) 326 bytes [entry] [rendered] Hash: 778b337ad5fd5e1bd1bf Version: webpack next Asset Size Chunks Chunk Names -output.js 599 bytes 0 [emitted] main +output.js 665 bytes 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 326 bytes [entry] [rendered] > main [1] ./example.js diff --git a/examples/scope-hoisting/README.md b/examples/scope-hoisting/README.md index f9134e545..69764bb58 100644 --- a/examples/scope-hoisting/README.md +++ b/examples/scope-hoisting/README.md @@ -101,12 +101,8 @@ export var y = "y"; # webpack.config.js ``` javascript -var webpack = require("../../"); - module.exports = { - plugins: [ - new webpack.optimize.ModuleConcatenationPlugin() - ] + mode: "production" }; ``` @@ -253,6 +249,11 @@ module.exports = { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -433,13 +434,13 @@ Hash: 728059a4c3ff363ecb4e Version: webpack next Asset Size Chunks Chunk Names 0.output.js 2.01 KiB 0 [emitted] - output.js 8.05 KiB 1 [emitted] main + output.js 8.24 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 286 bytes {1} [rendered] > [] 4:0-16 [3] ./lazy.js + 2 modules 242 bytes {0} [built] [exports: d, c, x, y] - import() ./lazy ./example.js 4:0-16 + import() ./lazy ./example.js 4:0-16 + 1 hidden module chunk {1} output.js (main) 390 bytes [entry] [rendered] > main [] @@ -463,13 +464,13 @@ Hash: 728059a4c3ff363ecb4e Version: webpack next Asset Size Chunks Chunk Names 0.output.js 404 bytes 0 [emitted] - output.js 1.78 KiB 1 [emitted] main + output.js 1.84 KiB 1 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js 286 bytes {1} [rendered] > [] 4:0-16 [3] ./lazy.js + 2 modules 242 bytes {0} [built] [exports: d, c, x, y] - import() ./lazy ./example.js 4:0-16 + import() ./lazy ./example.js 4:0-16 + 1 hidden module chunk {1} output.js (main) 390 bytes [entry] [rendered] > main [] diff --git a/examples/side-effects/README.md b/examples/side-effects/README.md index 81d2773db..317543fb8 100644 --- a/examples/side-effects/README.md +++ b/examples/side-effects/README.md @@ -103,6 +103,11 @@ export { c } from "./c"; /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -119,7 +124,7 @@ export { c } from "./c"; /******/ __webpack_require__.p = "js/"; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 4); +/******/ return __webpack_require__(__webpack_require__.s = 0); /******/ }) /************************************************************************/ ``` @@ -129,120 +134,49 @@ export { c } from "./c"; ``` javascript /******/ ([ /* 0 */ -/*!******************************************!*\ - !*** ./node_modules/big-module/index.js ***! - \******************************************/ -/*! exports provided: a, b, c */ -/*! exports used: a, b */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony import */ var _a__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./a */1); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _a__WEBPACK_IMPORTED_MODULE_0__["a"]; }); - -/* harmony import */ var _b__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./b */2); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "b", function() { return _b__WEBPACK_IMPORTED_MODULE_1__["a"]; }); - -/* harmony import */ var _c__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./c */3); - - - - - -/***/ }), -/* 1 */ -/*!**************************************!*\ - !*** ./node_modules/big-module/a.js ***! - \**************************************/ -/*! exports provided: a */ -/*! exports used: a */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return a; }); -const a = "a"; - - -/***/ }), -/* 2 */ -/*!**************************************!*\ - !*** ./node_modules/big-module/b.js ***! - \**************************************/ -/*! exports provided: b */ -/*! exports used: b */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return b; }); -const b = "b"; - - -/***/ }), -/* 3 */ -/*!**************************************!*\ - !*** ./node_modules/big-module/c.js ***! - \**************************************/ -/*! exports provided: c */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* unused harmony export c */ -const c = "c"; - - -/***/ }), -/* 4 */ -/*!********************!*\ - !*** ./example.js ***! - \********************/ +/*!********************************!*\ + !*** ./example.js + 6 modules ***! + \********************************/ /*! no exports provided */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is an entry point */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); -/* harmony import */ var big_module__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! big-module */0); -/* harmony import */ var big_module_with_flag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! big-module-with-flag */5); -/* harmony import */ var big_module_with_flag__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! big-module-with-flag */6); + +// CONCATENATED MODULE: ./node_modules/big-module/a.js +const a = "a"; + +// CONCATENATED MODULE: ./node_modules/big-module/b.js +const b = "b"; + +// CONCATENATED MODULE: ./node_modules/big-module/c.js +const c = "c"; + +// CONCATENATED MODULE: ./node_modules/big-module/index.js + + + + +// CONCATENATED MODULE: ./node_modules/big-module-with-flag/a.js +const a_a = "a"; + +// CONCATENATED MODULE: ./node_modules/big-module-with-flag/b.js +const b_b = "b"; + +// CONCATENATED MODULE: ./example.js console.log( - big_module__WEBPACK_IMPORTED_MODULE_0__["a"], - big_module__WEBPACK_IMPORTED_MODULE_0__["b"], - big_module_with_flag__WEBPACK_IMPORTED_MODULE_1__["a"], - big_module_with_flag__WEBPACK_IMPORTED_MODULE_2__["a" /* b */] + a, + b, + a_a, + b_b ); -/***/ }), -/* 5 */ -/*!************************************************!*\ - !*** ./node_modules/big-module-with-flag/a.js ***! - \************************************************/ -/*! exports provided: a */ -/*! exports used: a */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return a; }); -const a = "a"; - - -/***/ }), -/* 6 */ -/*!************************************************!*\ - !*** ./node_modules/big-module-with-flag/b.js ***! - \************************************************/ -/*! exports provided: b */ -/*! exports used: b */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return b; }); -const b = "b"; - - /***/ }) /******/ ]); ``` @@ -252,31 +186,29 @@ const b = "b"; ## Uncompressed ``` -Hash: ffa5ab92959135f25dd4 +Hash: 1b6ad20ba7bd65d7f026 Version: webpack next Asset Size Chunks Chunk Names -output.js 6.05 KiB 0 [emitted] main +output.js 3.47 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 342 bytes [entry] [rendered] - > main [4] ./example.js - [4] ./example.js 149 bytes {0} [built] + > main [] + [0] ./example.js + 6 modules 342 bytes {0} [built] [no exports] single entry .\example.js main - + 6 hidden modules ``` ## Minimized (uglify-js, no zip) ``` -Hash: ffa5ab92959135f25dd4 +Hash: 1b6ad20ba7bd65d7f026 Version: webpack next - Asset Size Chunks Chunk Names -output.js 1.03 KiB 0 [emitted] main + Asset Size Chunks Chunk Names +output.js 640 bytes 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 342 bytes [entry] [rendered] - > main [4] ./example.js - [4] ./example.js 149 bytes {0} [built] + > main [] + [0] ./example.js + 6 modules 342 bytes {0} [built] [no exports] single entry .\example.js main - + 6 hidden modules ``` diff --git a/examples/source-map/README.md b/examples/source-map/README.md index 0d252826c..553b95502 100644 --- a/examples/source-map/README.md +++ b/examples/source-map/README.md @@ -34,6 +34,7 @@ module.exports = [ "nosources-source-map", "source-map", ].map(devtool => ({ + mode: "development", entry: { bundle: "coffee-loader!./example.coffee", }, @@ -52,13 +53,13 @@ module.exports = [ ## source-map.js and source-map.js.map ``` javascript -(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[ -/* 0 */ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["bundle"],{ + +/***/ "../../node_modules/coffee-loader/index.js!./example.coffee": /*!*************************************************************!*\ !*** (webpack)/node_modules/coffee-loader!./example.coffee ***! \*************************************************************/ /*! no static exports found */ -/*! all exports used */ /***/ (function(module, exports) { var math, race, @@ -80,7 +81,8 @@ race = function() { /***/ }) -],[[0,1,0]]]); + +},[["../../node_modules/coffee-loader/index.js!./example.coffee","manifest","bundle"]]]); //# sourceMappingURL=bundle-source-map.js.map ``` @@ -90,13 +92,13 @@ race = function() { ## hidden-source-map.js and hidden-source-map.js.map ``` javascript -(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[ -/* 0 */ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["bundle"],{ + +/***/ "../../node_modules/coffee-loader/index.js!./example.coffee": /*!*************************************************************!*\ !*** (webpack)/node_modules/coffee-loader!./example.coffee ***! \*************************************************************/ /*! no static exports found */ -/*! all exports used */ /***/ (function(module, exports) { var math, race, @@ -118,7 +120,8 @@ race = function() { /***/ }) -],[[0,1,0]]]); + +},[["../../node_modules/coffee-loader/index.js!./example.coffee","manifest","bundle"]]]); ``` ``` javascript @@ -127,13 +130,13 @@ race = function() { ## inline-source-map.js ``` javascript -(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[ -/* 0 */ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["bundle"],{ + +/***/ "../../node_modules/coffee-loader/index.js!./example.coffee": /*!*************************************************************!*\ !*** (webpack)/node_modules/coffee-loader!./example.coffee ***! \*************************************************************/ /*! no static exports found */ -/*! all exports used */ /***/ (function(module, exports) { var math, race, @@ -155,7 +158,8 @@ race = function() { /***/ }) -],[[0,1,0]]]); + +},[["../../node_modules/coffee-loader/index.js!./example.coffee","manifest","bundle"]]]); //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9leGFtcGxlLmNvZmZlZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFHQTtFQUFBOztBQUFBLE9BQ0U7RUFBQSxNQUFRLElBQUksQ0FBQyxJQUFiO0VBQ0EsUUFBUSxNQURSO0VBRUEsTUFBUSxTQUFDLENBQUQ7V0FBTyxJQUFJLE9BQU8sQ0FBUDtFQUFYLENBRlI7OztBQUtGLE9BQU87QUFDTDtFQURNLHVCQUFRO1NBQ2QsTUFBTSxNQUFOLEVBQWMsT0FBZDtBQURLIiwiZmlsZSI6Ii4vYnVuZGxlLWlubGluZS1zb3VyY2UtbWFwLmpzIiwic291cmNlc0NvbnRlbnQiOlsiIyBUYWtlbiBmcm9tIGh0dHA6Ly9jb2ZmZWVzY3JpcHQub3JnL1xyXG5cclxuIyBPYmplY3RzOlxyXG5tYXRoID1cclxuICByb290OiAgIE1hdGguc3FydFxyXG4gIHNxdWFyZTogc3F1YXJlXHJcbiAgY3ViZTogICAoeCkgLT4geCAqIHNxdWFyZSB4XHJcblxyXG4jIFNwbGF0czpcclxucmFjZSA9ICh3aW5uZXIsIHJ1bm5lcnMuLi4pIC0+XHJcbiAgcHJpbnQgd2lubmVyLCBydW5uZXJzXHJcblxuXG5cbi8vIFdFQlBBQ0sgRk9PVEVSIC8vXG4vLyAuL2V4YW1wbGUuY29mZmVlIl0sInNvdXJjZVJvb3QiOiIifQ== ``` @@ -166,205 +170,219 @@ race = function() { ## eval-source-map.js ``` javascript -(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[ -/* 0 */ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["bundle"],{ + +/***/ "../../node_modules/coffee-loader/index.js!./example.coffee": /*!*************************************************************!*\ !*** (webpack)/node_modules/coffee-loader!./example.coffee ***! \*************************************************************/ /*! no static exports found */ -/*! all exports used */ /***/ (function(module, exports) { -eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9leGFtcGxlLmNvZmZlZT85MWU1Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBO0VBQUE7O0FBQUEsT0FDRTtFQUFBLE1BQVEsSUFBSSxDQUFDLElBQWI7RUFDQSxRQUFRLE1BRFI7RUFFQSxNQUFRLFNBQUMsQ0FBRDtXQUFPLElBQUksT0FBTyxDQUFQO0VBQVgsQ0FGUjs7O0FBS0YsT0FBTztBQUNMO0VBRE0sdUJBQVE7U0FDZCxNQUFNLE1BQU4sRUFBYyxPQUFkO0FBREsiLCJmaWxlIjoiMC5qcyIsInNvdXJjZXNDb250ZW50IjpbIiMgVGFrZW4gZnJvbSBodHRwOi8vY29mZmVlc2NyaXB0Lm9yZy9cclxuXHJcbiMgT2JqZWN0czpcclxubWF0aCA9XHJcbiAgcm9vdDogICBNYXRoLnNxcnRcclxuICBzcXVhcmU6IHNxdWFyZVxyXG4gIGN1YmU6ICAgKHgpIC0+IHggKiBzcXVhcmUgeFxyXG5cclxuIyBTcGxhdHM6XHJcbnJhY2UgPSAod2lubmVyLCBydW5uZXJzLi4uKSAtPlxyXG4gIHByaW50IHdpbm5lciwgcnVubmVyc1xyXG5cblxuXG4vLyBXRUJQQUNLIEZPT1RFUiAvL1xuLy8gLi9leGFtcGxlLmNvZmZlZSJdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///0\n"); +eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9leGFtcGxlLmNvZmZlZT85MWU1Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBO0VBQUE7O0FBQUEsT0FDRTtFQUFBLE1BQVEsSUFBSSxDQUFDLElBQWI7RUFDQSxRQUFRLE1BRFI7RUFFQSxNQUFRLFNBQUMsQ0FBRDtXQUFPLElBQUksT0FBTyxDQUFQO0VBQVgsQ0FGUjs7O0FBS0YsT0FBTztBQUNMO0VBRE0sdUJBQVE7U0FDZCxNQUFNLE1BQU4sRUFBYyxPQUFkO0FBREsiLCJmaWxlIjoiLi4vLi4vbm9kZV9tb2R1bGVzL2NvZmZlZS1sb2FkZXIvaW5kZXguanMhLi9leGFtcGxlLmNvZmZlZS5qcyIsInNvdXJjZXNDb250ZW50IjpbIiMgVGFrZW4gZnJvbSBodHRwOi8vY29mZmVlc2NyaXB0Lm9yZy9cclxuXHJcbiMgT2JqZWN0czpcclxubWF0aCA9XHJcbiAgcm9vdDogICBNYXRoLnNxcnRcclxuICBzcXVhcmU6IHNxdWFyZVxyXG4gIGN1YmU6ICAgKHgpIC0+IHggKiBzcXVhcmUgeFxyXG5cclxuIyBTcGxhdHM6XHJcbnJhY2UgPSAod2lubmVyLCBydW5uZXJzLi4uKSAtPlxyXG4gIHByaW50IHdpbm5lciwgcnVubmVyc1xyXG5cblxuXG4vLyBXRUJQQUNLIEZPT1RFUiAvL1xuLy8gLi9leGFtcGxlLmNvZmZlZSJdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///../../node_modules/coffee-loader/index.js!./example.coffee\n"); /***/ }) -],[[0,1,0]]]); + +},[["../../node_modules/coffee-loader/index.js!./example.coffee","manifest","bundle"]]]); ``` ## eval.js ``` javascript -(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[ -/* 0 */ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["bundle"],{ + +/***/ "../../node_modules/coffee-loader/index.js!./example.coffee": /*!*************************************************************!*\ !*** (webpack)/node_modules/coffee-loader!./example.coffee ***! \*************************************************************/ /*! no static exports found */ -/*! all exports used */ /***/ (function(module, exports) { -eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/node_modules/coffee-loader!./example.coffee\n// module id = 0\n// module chunks = 0\n\n//# sourceURL=webpack:///./example.coffee?(webpack)/node_modules/coffee-loader"); +eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/node_modules/coffee-loader!./example.coffee\n// module id = ../../node_modules/coffee-loader/index.js!./example.coffee\n// module chunks = bundle\n\n//# sourceURL=webpack:///./example.coffee?(webpack)/node_modules/coffee-loader"); /***/ }) -],[[0,1,0]]]); + +},[["../../node_modules/coffee-loader/index.js!./example.coffee","manifest","bundle"]]]); ``` ## cheap-eval-source-map.js ``` javascript -(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[ -/* 0 */ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["bundle"],{ + +/***/ "../../node_modules/coffee-loader/index.js!./example.coffee": /*!*************************************************************!*\ !*** (webpack)/node_modules/coffee-loader!./example.coffee ***! \*************************************************************/ /*! no static exports found */ -/*! all exports used */ /***/ (function(module, exports) { -eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2V4YW1wbGUuY29mZmVlPzA5MjciXSwic291cmNlc0NvbnRlbnQiOlsidmFyIG1hdGgsIHJhY2UsXG4gIHNsaWNlID0gW10uc2xpY2U7XG5cbm1hdGggPSB7XG4gIHJvb3Q6IE1hdGguc3FydCxcbiAgc3F1YXJlOiBzcXVhcmUsXG4gIGN1YmU6IGZ1bmN0aW9uKHgpIHtcbiAgICByZXR1cm4geCAqIHNxdWFyZSh4KTtcbiAgfVxufTtcblxucmFjZSA9IGZ1bmN0aW9uKCkge1xuICB2YXIgcnVubmVycywgd2lubmVyO1xuICB3aW5uZXIgPSBhcmd1bWVudHNbMF0sIHJ1bm5lcnMgPSAyIDw9IGFyZ3VtZW50cy5sZW5ndGggPyBzbGljZS5jYWxsKGFyZ3VtZW50cywgMSkgOiBbXTtcbiAgcmV0dXJuIHByaW50KHdpbm5lciwgcnVubmVycyk7XG59O1xuXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gKHdlYnBhY2spL25vZGVfbW9kdWxlcy9jb2ZmZWUtbG9hZGVyIS4vZXhhbXBsZS5jb2ZmZWVcbi8vIG1vZHVsZSBpZCA9IDBcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTsiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///0\n"); +eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi4vLi4vbm9kZV9tb2R1bGVzL2NvZmZlZS1sb2FkZXIvaW5kZXguanMhLi9leGFtcGxlLmNvZmZlZS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2V4YW1wbGUuY29mZmVlPzA5MjciXSwic291cmNlc0NvbnRlbnQiOlsidmFyIG1hdGgsIHJhY2UsXG4gIHNsaWNlID0gW10uc2xpY2U7XG5cbm1hdGggPSB7XG4gIHJvb3Q6IE1hdGguc3FydCxcbiAgc3F1YXJlOiBzcXVhcmUsXG4gIGN1YmU6IGZ1bmN0aW9uKHgpIHtcbiAgICByZXR1cm4geCAqIHNxdWFyZSh4KTtcbiAgfVxufTtcblxucmFjZSA9IGZ1bmN0aW9uKCkge1xuICB2YXIgcnVubmVycywgd2lubmVyO1xuICB3aW5uZXIgPSBhcmd1bWVudHNbMF0sIHJ1bm5lcnMgPSAyIDw9IGFyZ3VtZW50cy5sZW5ndGggPyBzbGljZS5jYWxsKGFyZ3VtZW50cywgMSkgOiBbXTtcbiAgcmV0dXJuIHByaW50KHdpbm5lciwgcnVubmVycyk7XG59O1xuXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gKHdlYnBhY2spL25vZGVfbW9kdWxlcy9jb2ZmZWUtbG9hZGVyIS4vZXhhbXBsZS5jb2ZmZWVcbi8vIG1vZHVsZSBpZCA9IC4uLy4uL25vZGVfbW9kdWxlcy9jb2ZmZWUtbG9hZGVyL2luZGV4LmpzIS4vZXhhbXBsZS5jb2ZmZWVcbi8vIG1vZHVsZSBjaHVua3MgPSBidW5kbGUiXSwibWFwcGluZ3MiOiJBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOyIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///../../node_modules/coffee-loader/index.js!./example.coffee\n"); /***/ }) -],[[0,1,0]]]); + +},[["../../node_modules/coffee-loader/index.js!./example.coffee","manifest","bundle"]]]); ``` ## cheap-module-eval-source-map.js ``` javascript -(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[ -/* 0 */ +(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["bundle"],{ + +/***/ "../../node_modules/coffee-loader/index.js!./example.coffee": /*!*************************************************************!*\ !*** (webpack)/node_modules/coffee-loader!./example.coffee ***! \*************************************************************/ /*! no static exports found */ -/*! all exports used */ /***/ (function(module, exports) { -eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2V4YW1wbGUuY29mZmVlPzkxZTUiXSwic291cmNlc0NvbnRlbnQiOlsiIyBUYWtlbiBmcm9tIGh0dHA6Ly9jb2ZmZWVzY3JpcHQub3JnL1xyXG5cclxuIyBPYmplY3RzOlxyXG5tYXRoID1cclxuICByb290OiAgIE1hdGguc3FydFxyXG4gIHNxdWFyZTogc3F1YXJlXHJcbiAgY3ViZTogICAoeCkgLT4geCAqIHNxdWFyZSB4XHJcblxyXG4jIFNwbGF0czpcclxucmFjZSA9ICh3aW5uZXIsIHJ1bm5lcnMuLi4pIC0+XHJcbiAgcHJpbnQgd2lubmVyLCBydW5uZXJzXHJcblxuXG5cbi8vIFdFQlBBQ0sgRk9PVEVSIC8vXG4vLyAuL2V4YW1wbGUuY29mZmVlIl0sIm1hcHBpbmdzIjoiQUFHQTtBQUFBO0FBQ0E7QUFEQTtBQUNBO0FBQ0E7QUFDQTtBQUFBO0FBQUE7OztBQUdBO0FBQ0E7QUFEQTtBQUNBO0FBREE7Iiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///0\n"); +eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiLi4vLi4vbm9kZV9tb2R1bGVzL2NvZmZlZS1sb2FkZXIvaW5kZXguanMhLi9leGFtcGxlLmNvZmZlZS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2V4YW1wbGUuY29mZmVlPzkxZTUiXSwic291cmNlc0NvbnRlbnQiOlsiIyBUYWtlbiBmcm9tIGh0dHA6Ly9jb2ZmZWVzY3JpcHQub3JnL1xyXG5cclxuIyBPYmplY3RzOlxyXG5tYXRoID1cclxuICByb290OiAgIE1hdGguc3FydFxyXG4gIHNxdWFyZTogc3F1YXJlXHJcbiAgY3ViZTogICAoeCkgLT4geCAqIHNxdWFyZSB4XHJcblxyXG4jIFNwbGF0czpcclxucmFjZSA9ICh3aW5uZXIsIHJ1bm5lcnMuLi4pIC0+XHJcbiAgcHJpbnQgd2lubmVyLCBydW5uZXJzXHJcblxuXG5cbi8vIFdFQlBBQ0sgRk9PVEVSIC8vXG4vLyAuL2V4YW1wbGUuY29mZmVlIl0sIm1hcHBpbmdzIjoiQUFHQTtBQUFBO0FBQ0E7QUFEQTtBQUNBO0FBQ0E7QUFDQTtBQUFBO0FBQUE7OztBQUdBO0FBQ0E7QUFEQTtBQUNBO0FBREE7Iiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///../../node_modules/coffee-loader/index.js!./example.coffee\n"); /***/ }) -],[[0,1,0]]]); + +},[["../../node_modules/coffee-loader/index.js!./example.coffee","manifest","bundle"]]]); ``` ## cheap-module-source-map.js.map ``` javascript -{"version":3,"file":"./bundle-cheap-module-source-map.js","sources":["webpack:///./example.coffee"],"sourcesContent":["# Taken from http://coffeescript.org/\r\n\r\n# Objects:\r\nmath =\r\n root: Math.sqrt\r\n square: square\r\n cube: (x) -> x * square x\r\n\r\n# Splats:\r\nrace = (winner, runners...) ->\r\n print winner, runners\r\n\n\n\n// WEBPACK FOOTER //\n// ./example.coffee"],"mappings":";;;;;;;;;AAGA;AAAA;AACA;AADA;AACA;AACA;AACA;AAAA;AAAA;;;AAGA;AACA;AADA;AACA;AADA;;;;A","sourceRoot":""} +{"version":3,"file":"./bundle-cheap-module-source-map.js","sources":["webpack:///./example.coffee"],"sourcesContent":["# Taken from http://coffeescript.org/\r\n\r\n# Objects:\r\nmath =\r\n root: Math.sqrt\r\n square: square\r\n cube: (x) -> x * square x\r\n\r\n# Splats:\r\nrace = (winner, runners...) ->\r\n print winner, runners\r\n\n\n\n// WEBPACK FOOTER //\n// ./example.coffee"],"mappings":";;;;;;;;;AAGA;AAAA;AACA;AADA;AACA;AACA;AACA;AAAA;AAAA;;;AAGA;AACA;AADA;AACA;AADA;;;;;A","sourceRoot":""} ``` ## cheap-source-map.js.map ``` javascript -{"version":3,"file":"./bundle-cheap-source-map.js","sources":["webpack:///./example.coffee"],"sourcesContent":["var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/node_modules/coffee-loader!./example.coffee\n// module id = 0\n// module chunks = 0"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;A","sourceRoot":""} +{"version":3,"file":"./bundle-cheap-source-map.js","sources":["webpack:///./example.coffee"],"sourcesContent":["var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/node_modules/coffee-loader!./example.coffee\n// module id = ../../node_modules/coffee-loader/index.js!./example.coffee\n// module chunks = bundle"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;A","sourceRoot":""} ``` # webpack output ``` -Hash: 79b99f290c67f8b1abdec592b327b01606b67e88290880dde0b61319ee722a2eb6895625006f42f2c35449964babb3d3227ba2c98edc64f18904cb4e9a8715ef2d2714490e6474efb4b8aba9d82675fb2d51572a8c7c156a86414260c8ca0a21b3744bbd +Hash: 78499e602826e502f04e23aeb90775edc42bc235d254d61a567196f9035f7d2dea95838abda6ced5c59cc8c98b45058d6212ba975e472c21b47458cd4690b3b2eea809995d715c0cc451b298e6aaff64f50f394eadf371be4fd2ef0e056250654b0cb56e Version: webpack next Child - Hash: 79b99f290c67f8b1abde - Asset Size Chunks Chunk Names - ./bundle-cheap-eval-source-map.js 1.71 KiB 0 [emitted] bundle - ./manifest-cheap-eval-source-map.js 6.87 KiB 1 [emitted] manifest + Hash: 78499e602826e502f04e + Asset Size Chunks Chunk Names + ./bundle-cheap-eval-source-map.js 2.04 KiB bundle [emitted] bundle + ./manifest-cheap-eval-source-map.js 7.07 KiB manifest [emitted] manifest Entrypoint bundle = ./manifest-cheap-eval-source-map.js ./bundle-cheap-eval-source-map.js - chunk {0} ./bundle-cheap-eval-source-map.js (bundle) 308 bytes {1} [initial] [rendered] - > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee - [0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built] + chunk {bundle} ./bundle-cheap-eval-source-map.js (bundle) 308 bytes {manifest} [initial] [rendered] + > bundle [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee + [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {bundle} [built] + [no exports used] single entry coffee-loader!./example.coffee bundle - chunk {1} ./manifest-cheap-eval-source-map.js (manifest) 0 bytes [entry] [rendered] + chunk {manifest} ./manifest-cheap-eval-source-map.js (manifest) 0 bytes [entry] [rendered] Child - Hash: c592b327b01606b67e88 - Asset Size Chunks Chunk Names - ./bundle-cheap-module-eval-source-map.js 1.44 KiB 0 [emitted] bundle - ./manifest-cheap-module-eval-source-map.js 6.88 KiB 1 [emitted] manifest + Hash: 23aeb90775edc42bc235 + Asset Size Chunks Chunk Names + ./bundle-cheap-module-eval-source-map.js 1.69 KiB bundle [emitted] bundle + ./manifest-cheap-module-eval-source-map.js 7.08 KiB manifest [emitted] manifest Entrypoint bundle = ./manifest-cheap-module-eval-source-map.js ./bundle-cheap-module-eval-source-map.js - chunk {0} ./bundle-cheap-module-eval-source-map.js (bundle) 308 bytes {1} [initial] [rendered] - > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee - [0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built] + chunk {bundle} ./bundle-cheap-module-eval-source-map.js (bundle) 308 bytes {manifest} [initial] [rendered] + > bundle [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee + [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {bundle} [built] + [no exports used] single entry coffee-loader!./example.coffee bundle - chunk {1} ./manifest-cheap-module-eval-source-map.js (manifest) 0 bytes [entry] [rendered] + chunk {manifest} ./manifest-cheap-module-eval-source-map.js (manifest) 0 bytes [entry] [rendered] Child - Hash: 290880dde0b61319ee72 - Asset Size Chunks Chunk Names - ./bundle-cheap-module-source-map.js 759 bytes 0 [emitted] bundle - ./manifest-cheap-module-source-map.js 6.93 KiB 1 [emitted] manifest - ./bundle-cheap-module-source-map.js.map 507 bytes 0 [emitted] bundle - ./manifest-cheap-module-source-map.js.map 7.05 KiB 1 [emitted] manifest + Hash: d254d61a567196f9035f + Asset Size Chunks Chunk Names + ./bundle-cheap-module-source-map.js 879 bytes bundle [emitted] bundle + ./manifest-cheap-module-source-map.js 7.13 KiB manifest [emitted] manifest + ./bundle-cheap-module-source-map.js.map 508 bytes bundle [emitted] bundle + ./manifest-cheap-module-source-map.js.map 7.25 KiB manifest [emitted] manifest Entrypoint bundle = ./manifest-cheap-module-source-map.js ./manifest-cheap-module-source-map.js.map ./bundle-cheap-module-source-map.js ./bundle-cheap-module-source-map.js.map - chunk {0} ./bundle-cheap-module-source-map.js, ./bundle-cheap-module-source-map.js.map (bundle) 308 bytes {1} [initial] [rendered] - > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee - [0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built] + chunk {bundle} ./bundle-cheap-module-source-map.js, ./bundle-cheap-module-source-map.js.map (bundle) 308 bytes {manifest} [initial] [rendered] + > bundle [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee + [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {bundle} [built] + [no exports used] single entry coffee-loader!./example.coffee bundle - chunk {1} ./manifest-cheap-module-source-map.js, ./manifest-cheap-module-source-map.js.map (manifest) 0 bytes [entry] [rendered] + chunk {manifest} ./manifest-cheap-module-source-map.js, ./manifest-cheap-module-source-map.js.map (manifest) 0 bytes [entry] [rendered] Child - Hash: 2a2eb6895625006f42f2 - Asset Size Chunks Chunk Names - ./bundle-cheap-source-map.js 752 bytes 0 [emitted] bundle - ./manifest-cheap-source-map.js 6.92 KiB 1 [emitted] manifest - ./bundle-cheap-source-map.js.map 703 bytes 0 [emitted] bundle - ./manifest-cheap-source-map.js.map 7.04 KiB 1 [emitted] manifest + Hash: 7d2dea95838abda6ced5 + Asset Size Chunks Chunk Names + ./bundle-cheap-source-map.js 872 bytes bundle [emitted] bundle + ./manifest-cheap-source-map.js 7.12 KiB manifest [emitted] manifest + ./bundle-cheap-source-map.js.map 766 bytes bundle [emitted] bundle + ./manifest-cheap-source-map.js.map 7.23 KiB manifest [emitted] manifest Entrypoint bundle = ./manifest-cheap-source-map.js ./manifest-cheap-source-map.js.map ./bundle-cheap-source-map.js ./bundle-cheap-source-map.js.map - chunk {0} ./bundle-cheap-source-map.js, ./bundle-cheap-source-map.js.map (bundle) 308 bytes {1} [initial] [rendered] - > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee - [0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built] + chunk {bundle} ./bundle-cheap-source-map.js, ./bundle-cheap-source-map.js.map (bundle) 308 bytes {manifest} [initial] [rendered] + > bundle [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee + [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {bundle} [built] + [no exports used] single entry coffee-loader!./example.coffee bundle - chunk {1} ./manifest-cheap-source-map.js, ./manifest-cheap-source-map.js.map (manifest) 0 bytes [entry] [rendered] + chunk {manifest} ./manifest-cheap-source-map.js, ./manifest-cheap-source-map.js.map (manifest) 0 bytes [entry] [rendered] Child - Hash: c35449964babb3d3227b - Asset Size Chunks Chunk Names - ./bundle-eval.js 946 bytes 0 [emitted] bundle - ./manifest-eval.js 6.86 KiB 1 [emitted] manifest + Hash: c59cc8c98b45058d6212 + Asset Size Chunks Chunk Names + ./bundle-eval.js 1.1 KiB bundle [emitted] bundle + ./manifest-eval.js 7.05 KiB manifest [emitted] manifest Entrypoint bundle = ./manifest-eval.js ./bundle-eval.js - chunk {0} ./bundle-eval.js (bundle) 308 bytes {1} [initial] [rendered] - > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee - [0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built] + chunk {bundle} ./bundle-eval.js (bundle) 308 bytes {manifest} [initial] [rendered] + > bundle [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee + [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {bundle} [built] + [no exports used] single entry coffee-loader!./example.coffee bundle - chunk {1} ./manifest-eval.js (manifest) 0 bytes [entry] [rendered] + chunk {manifest} ./manifest-eval.js (manifest) 0 bytes [entry] [rendered] Child - Hash: a2c98edc64f18904cb4e - Asset Size Chunks Chunk Names - ./bundle-eval-source-map.js 1.58 KiB 0 [emitted] bundle - ./manifest-eval-source-map.js 6.87 KiB 1 [emitted] manifest + Hash: ba975e472c21b47458cd + Asset Size Chunks Chunk Names + ./bundle-eval-source-map.js 1.83 KiB bundle [emitted] bundle + ./manifest-eval-source-map.js 7.06 KiB manifest [emitted] manifest Entrypoint bundle = ./manifest-eval-source-map.js ./bundle-eval-source-map.js - chunk {0} ./bundle-eval-source-map.js (bundle) 308 bytes {1} [initial] [rendered] - > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee - [0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built] + chunk {bundle} ./bundle-eval-source-map.js (bundle) 308 bytes {manifest} [initial] [rendered] + > bundle [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee + [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {bundle} [built] + [no exports used] single entry coffee-loader!./example.coffee bundle - chunk {1} ./manifest-eval-source-map.js (manifest) 0 bytes [entry] [rendered] + chunk {manifest} ./manifest-eval-source-map.js (manifest) 0 bytes [entry] [rendered] Child - Hash: 9a8715ef2d2714490e64 - Asset Size Chunks Chunk Names - ./bundle-hidden-source-map.js 700 bytes 0 [emitted] bundle - ./manifest-hidden-source-map.js 6.87 KiB 1 [emitted] manifest - ./bundle-hidden-source-map.js.map 604 bytes 0 [emitted] bundle - ./manifest-hidden-source-map.js.map 7.12 KiB 1 [emitted] manifest + Hash: 4690b3b2eea809995d71 + Asset Size Chunks Chunk Names + ./bundle-hidden-source-map.js 820 bytes bundle [emitted] bundle + ./manifest-hidden-source-map.js 7.06 KiB manifest [emitted] manifest + ./bundle-hidden-source-map.js.map 604 bytes bundle [emitted] bundle + ./manifest-hidden-source-map.js.map 7.32 KiB manifest [emitted] manifest Entrypoint bundle = ./manifest-hidden-source-map.js ./manifest-hidden-source-map.js.map ./bundle-hidden-source-map.js ./bundle-hidden-source-map.js.map - chunk {0} ./bundle-hidden-source-map.js, ./bundle-hidden-source-map.js.map (bundle) 308 bytes {1} [initial] [rendered] - > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee - [0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built] + chunk {bundle} ./bundle-hidden-source-map.js, ./bundle-hidden-source-map.js.map (bundle) 308 bytes {manifest} [initial] [rendered] + > bundle [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee + [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {bundle} [built] + [no exports used] single entry coffee-loader!./example.coffee bundle - chunk {1} ./manifest-hidden-source-map.js, ./manifest-hidden-source-map.js.map (manifest) 0 bytes [entry] [rendered] + chunk {manifest} ./manifest-hidden-source-map.js, ./manifest-hidden-source-map.js.map (manifest) 0 bytes [entry] [rendered] Child - Hash: 74efb4b8aba9d82675fb - Asset Size Chunks Chunk Names - ./bundle-inline-source-map.js 1.54 KiB 0 [emitted] bundle - ./manifest-inline-source-map.js 16.4 KiB 1 [emitted] manifest + Hash: 5c0cc451b298e6aaff64 + Asset Size Chunks Chunk Names + ./bundle-inline-source-map.js 1.65 KiB bundle [emitted] bundle + ./manifest-inline-source-map.js 16.9 KiB manifest [emitted] manifest Entrypoint bundle = ./manifest-inline-source-map.js ./bundle-inline-source-map.js - chunk {0} ./bundle-inline-source-map.js (bundle) 308 bytes {1} [initial] [rendered] - > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee - [0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built] + chunk {bundle} ./bundle-inline-source-map.js (bundle) 308 bytes {manifest} [initial] [rendered] + > bundle [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee + [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {bundle} [built] + [no exports used] single entry coffee-loader!./example.coffee bundle - chunk {1} ./manifest-inline-source-map.js (manifest) 0 bytes [entry] [rendered] + chunk {manifest} ./manifest-inline-source-map.js (manifest) 0 bytes [entry] [rendered] Child - Hash: 2d51572a8c7c156a8641 - Asset Size Chunks Chunk Names - ./bundle-nosources-source-map.js 756 bytes 0 [emitted] bundle - ./manifest-nosources-source-map.js 6.93 KiB 1 [emitted] manifest - ./bundle-nosources-source-map.js.map 315 bytes 0 [emitted] bundle - ./manifest-nosources-source-map.js.map 1.06 KiB 1 [emitted] manifest + Hash: f50f394eadf371be4fd2 + Asset Size Chunks Chunk Names + ./bundle-nosources-source-map.js 876 bytes bundle [emitted] bundle + ./manifest-nosources-source-map.js 7.12 KiB manifest [emitted] manifest + ./bundle-nosources-source-map.js.map 315 bytes bundle [emitted] bundle + ./manifest-nosources-source-map.js.map 1.1 KiB manifest [emitted] manifest Entrypoint bundle = ./manifest-nosources-source-map.js ./manifest-nosources-source-map.js.map ./bundle-nosources-source-map.js ./bundle-nosources-source-map.js.map - chunk {0} ./bundle-nosources-source-map.js, ./bundle-nosources-source-map.js.map (bundle) 308 bytes {1} [initial] [rendered] - > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee - [0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built] + chunk {bundle} ./bundle-nosources-source-map.js, ./bundle-nosources-source-map.js.map (bundle) 308 bytes {manifest} [initial] [rendered] + > bundle [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee + [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {bundle} [built] + [no exports used] single entry coffee-loader!./example.coffee bundle - chunk {1} ./manifest-nosources-source-map.js, ./manifest-nosources-source-map.js.map (manifest) 0 bytes [entry] [rendered] + chunk {manifest} ./manifest-nosources-source-map.js, ./manifest-nosources-source-map.js.map (manifest) 0 bytes [entry] [rendered] Child - Hash: 4260c8ca0a21b3744bbd - Asset Size Chunks Chunk Names - ./bundle-source-map.js 746 bytes 0 [emitted] bundle - ./manifest-source-map.js 6.91 KiB 1 [emitted] manifest - ./bundle-source-map.js.map 597 bytes 0 [emitted] bundle - ./manifest-source-map.js.map 7.11 KiB 1 [emitted] manifest + Hash: ef0e056250654b0cb56e + Asset Size Chunks Chunk Names + ./bundle-source-map.js 866 bytes bundle [emitted] bundle + ./manifest-source-map.js 7.1 KiB manifest [emitted] manifest + ./bundle-source-map.js.map 597 bytes bundle [emitted] bundle + ./manifest-source-map.js.map 7.31 KiB manifest [emitted] manifest Entrypoint bundle = ./manifest-source-map.js ./manifest-source-map.js.map ./bundle-source-map.js ./bundle-source-map.js.map - chunk {0} ./bundle-source-map.js, ./bundle-source-map.js.map (bundle) 308 bytes {1} [initial] [rendered] - > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee - [0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built] + chunk {bundle} ./bundle-source-map.js, ./bundle-source-map.js.map (bundle) 308 bytes {manifest} [initial] [rendered] + > bundle [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee + [../../node_modules/coffee-loader/index.js!./example.coffee] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {bundle} [built] + [no exports used] single entry coffee-loader!./example.coffee bundle - chunk {1} ./manifest-source-map.js, ./manifest-source-map.js.map (manifest) 0 bytes [entry] [rendered] + chunk {manifest} ./manifest-source-map.js, ./manifest-source-map.js.map (manifest) 0 bytes [entry] [rendered] ``` diff --git a/examples/two-explicit-vendor-chunks/README.md b/examples/two-explicit-vendor-chunks/README.md index 3c7636859..7a083ba00 100644 --- a/examples/two-explicit-vendor-chunks/README.md +++ b/examples/two-explicit-vendor-chunks/README.md @@ -4,6 +4,7 @@ var path = require("path"); var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin"); module.exports = { + mode: "production", entry: { vendor1: ["./vendor1"], vendor2: ["./vendor2"], @@ -178,6 +179,11 @@ module.exports = { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -218,6 +224,7 @@ module.exports = { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = "Vendor1"; @@ -230,6 +237,7 @@ module.exports = "Vendor1"; \***********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(/*! ./vendor1 */0); @@ -250,6 +258,7 @@ module.exports = __webpack_require__(/*! ./vendor1 */0); \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = "Vendor2"; @@ -264,6 +273,7 @@ __webpack_require__(/*! ./vendor1 */ 0); \***********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(/*! ./vendor2 */1); @@ -284,6 +294,7 @@ module.exports = __webpack_require__(/*! ./vendor2 */1); \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = "pageA"; @@ -304,11 +315,11 @@ __webpack_require__(/*! ./vendor2 */ 1); Hash: 6fe4b98832b1f1c2bd5b Version: webpack next Asset Size Chunks Chunk Names -vendor2.js 654 bytes 0 [emitted] vendor2 - pageC.js 293 bytes 1 [emitted] pageC - pageB.js 293 bytes 2 [emitted] pageB - pageA.js 400 bytes 3 [emitted] pageA -vendor1.js 7.47 KiB 4 [emitted] vendor1 +vendor2.js 796 bytes 0 [emitted] vendor2 + pageC.js 364 bytes 1 [emitted] pageC + pageB.js 364 bytes 2 [emitted] pageB + pageA.js 471 bytes 3 [emitted] pageA +vendor1.js 7.79 KiB 4 [emitted] vendor1 Entrypoint vendor1 = vendor1.js Entrypoint vendor2 = vendor1.js vendor2.js Entrypoint pageA = vendor1.js vendor2.js pageA.js @@ -353,7 +364,7 @@ vendor2.js 146 bytes 0 [emitted] vendor2 pageC.js 107 bytes 1 [emitted] pageC pageB.js 107 bytes 2 [emitted] pageB pageA.js 119 bytes 3 [emitted] pageA -vendor1.js 1.71 KiB 4 [emitted] vendor1 +vendor1.js 1.78 KiB 4 [emitted] vendor1 Entrypoint vendor1 = vendor1.js Entrypoint vendor2 = vendor1.js vendor2.js Entrypoint pageA = vendor1.js vendor2.js pageA.js diff --git a/examples/wasm-simple/README.md b/examples/wasm-simple/README.md index 41b1bd4be..135d73ceb 100644 --- a/examples/wasm-simple/README.md +++ b/examples/wasm-simple/README.md @@ -215,6 +215,11 @@ export function fibonacciJavascript(i) { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -258,6 +263,7 @@ export function fibonacciJavascript(i) { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__.e/* import() */(1).then(__webpack_require__.bind(null, /*! ./add.wasm */1)).then(addModule => { @@ -303,6 +309,7 @@ function timed(name, fn) { \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -320,10 +327,11 @@ module.exports = instance.exports; \*****************/ /*! exports provided: add, factorial, fibonacci, factorialJavascript, fibonacciJavascript */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./example.js (referenced with import()) */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +__webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "factorialJavascript", function() { return factorialJavascript; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fibonacciJavascript", function() { return fibonacciJavascript; }); /* harmony import */ var _add_wasm__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./add.wasm */1); @@ -362,6 +370,7 @@ function fibonacciJavascript(i) { \************************/ /*! no static exports found */ /*! exports used: factorial */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -379,6 +388,7 @@ module.exports = instance.exports; \************************/ /*! no static exports found */ /*! exports used: fibonacci */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -404,6 +414,7 @@ module.exports = instance.exports; \******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -426,12 +437,12 @@ module.exports = instance.exports; Hash: ab6e4a9175255d038490 Version: webpack next Asset Size Chunks Chunk Names - 0.output.js 3.47 KiB 0, 1 [emitted] + 0.output.js 3.78 KiB 0, 1 [emitted] 80925f35a6f1cf550d38.wasm 41 bytes 0, 1, 1 [emitted] 3d28950d91bc7246f5af.wasm 62 bytes 0, 1 [emitted] 1d2268b99656e9575a63.wasm 67 bytes 0, 1 [emitted] - 1.output.js 486 bytes 1 [emitted] - output.js 8.7 KiB 2 [emitted] main + 1.output.js 557 bytes 1 [emitted] + output.js 8.95 KiB 2 [emitted] main Entrypoint main = output.js chunk {0} 0.output.js, 80925f35a6f1cf550d38.wasm, 3d28950d91bc7246f5af.wasm, 1d2268b99656e9575a63.wasm 585 bytes {2} [rendered] > [0] ./example.js 3:1-17 @@ -467,13 +478,7 @@ chunk {2} output.js (main) 788 bytes [entry] [rendered] ``` Hash: ab6e4a9175255d038490 Version: webpack next - Asset Size Chunks Chunk Names - 0.output.js 772 bytes 0, 1 [emitted] -80925f35a6f1cf550d38.wasm 41 bytes 0, 1, 1 [emitted] -3d28950d91bc7246f5af.wasm 62 bytes 0, 1 [emitted] -1d2268b99656e9575a63.wasm 67 bytes 0, 1 [emitted] - 1.output.js 155 bytes 1 [emitted] - output.js 8.54 KiB 2 [emitted] main + 6 assets Entrypoint main = output.js chunk {0} 0.output.js, 80925f35a6f1cf550d38.wasm, 3d28950d91bc7246f5af.wasm, 1d2268b99656e9575a63.wasm 585 bytes {2} [rendered] > [0] ./example.js 3:1-17 @@ -504,5 +509,5 @@ chunk {2} output.js (main) 788 bytes [entry] [rendered] single entry .\example.js main ERROR in output.js from UglifyJs -Unexpected token: operator (>) [output.js:193,95] +Unexpected token: operator (>) [output.js:198,95] ``` diff --git a/examples/web-worker/README.md b/examples/web-worker/README.md index 974a869d6..4687b4423 100644 --- a/examples/web-worker/README.md +++ b/examples/web-worker/README.md @@ -72,6 +72,11 @@ onmessage = function(event) { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -103,6 +108,7 @@ onmessage = function(event) { \********************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var Worker = __webpack_require__(/*! worker-loader!./worker */ 1); @@ -120,6 +126,7 @@ worker.onmessage = function(event) { \********************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { module.exports = function() { @@ -205,6 +212,11 @@ module.exports = function() { /******/ } /******/ }; /******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? @@ -231,6 +243,7 @@ module.exports = function() { \*******************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { onmessage = function(event) { @@ -256,6 +269,7 @@ self["webpackChunk"]([0],[ \**************************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports, __webpack_require__) { var map = { @@ -289,6 +303,7 @@ webpackContext.id = 1; \*****************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -302,6 +317,7 @@ module.exports = function() { \*****************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -315,6 +331,7 @@ module.exports = function() { \*****************************************/ /*! no static exports found */ /*! all exports used */ +/*! ModuleConcatenation bailout: Module is not an ECMAScript module */ /***/ (function(module, exports) { module.exports = function() { @@ -333,9 +350,9 @@ module.exports = function() { Hash: ea02849f7950e1efeb6f Version: webpack next Asset Size Chunks Chunk Names -0.hash.worker.js 1.83 KiB [emitted] - hash.worker.js 3.84 KiB [emitted] - output.js 3.2 KiB 0 [emitted] main +0.hash.worker.js 2.11 KiB [emitted] + hash.worker.js 4.1 KiB [emitted] + output.js 3.52 KiB 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 311 bytes [entry] [rendered] > main [0] ./example.js @@ -345,8 +362,8 @@ chunk {0} output.js (main) 311 bytes [entry] [rendered] cjs require worker-loader!./worker [0] ./example.js 1:13-46 Child worker: Asset Size Chunks Chunk Names - 0.hash.worker.js 1.83 KiB 0 [emitted] - hash.worker.js 3.84 KiB 1 [emitted] main + 0.hash.worker.js 2.11 KiB 0 [emitted] + hash.worker.js 4.1 KiB 1 [emitted] main Entrypoint main = hash.worker.js chunk {0} 0.hash.worker.js 463 bytes {1} [rendered] > [0] ./worker.js 3:1-5:3 @@ -374,8 +391,8 @@ Hash: ea02849f7950e1efeb6f Version: webpack next Asset Size Chunks Chunk Names 0.hash.worker.js 549 bytes [emitted] - hash.worker.js 849 bytes [emitted] - output.js 632 bytes 0 [emitted] main + hash.worker.js 915 bytes [emitted] + output.js 698 bytes 0 [emitted] main Entrypoint main = output.js chunk {0} output.js (main) 311 bytes [entry] [rendered] > main [0] ./example.js @@ -386,7 +403,7 @@ chunk {0} output.js (main) 311 bytes [entry] [rendered] Child worker: Asset Size Chunks Chunk Names 0.hash.worker.js 549 bytes 0 [emitted] - hash.worker.js 849 bytes 1 [emitted] main + hash.worker.js 915 bytes 1 [emitted] main Entrypoint main = hash.worker.js chunk {0} 0.hash.worker.js 463 bytes {1} [rendered] > [0] ./worker.js 3:1-5:3