add test case for assets that become identical after optimization

This commit is contained in:
Tobias Koppers 2021-03-01 10:15:06 +01:00
parent 70376ad4ec
commit 923ac94f82
7 changed files with 84 additions and 43 deletions

View File

@ -2440,97 +2440,119 @@ LOG from webpack.FileSystemInfo
exports[`StatsTestCases should print correct stats for real-content-hash 1`] = `
"a-normal:
assets by path *.js 3.14 KiB
asset 28d919d2ba0afe316d4d-28d919.js 2.65 KiB [emitted] [immutable] [minimized] (name: runtime~main)
assets by path *.js 3.16 KiB
asset 1a429866b1a4b47a3ece-1a4298.js 2.65 KiB [emitted] [immutable] [minimized] (name: runtime)
asset a639a9edc4557744bf94-a639a9.js 288 bytes [emitted] [immutable] [minimized] (name: lazy)
asset 3cc8faad16137711c07e-3cc8fa.js 210 bytes [emitted] [immutable] [minimized] (name: main)
asset b32c1c3b5e5cb3818671-b32c1c.js 210 bytes [emitted] [immutable] [minimized] (name: index)
asset 666f2b8847021ccc7608-666f2b.js 21 bytes [emitted] [immutable] [minimized] (name: a, b)
assets by chunk 20.4 KiB (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg?query 5.89 KiB [cached] [immutable] [from: file.jpg?query] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: main)
Entrypoint main 2.85 KiB (5.89 KiB) = 28d919d2ba0afe316d4d-28d919.js 2.65 KiB 3cc8faad16137711c07e-3cc8fa.js 210 bytes 1 auxiliary asset
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: index)
Entrypoint index 2.85 KiB (5.89 KiB) = 1a429866b1a4b47a3ece-1a4298.js 2.65 KiB b32c1c3b5e5cb3818671-b32c1c.js 210 bytes 1 auxiliary asset
Entrypoint a 21 bytes = 666f2b8847021ccc7608-666f2b.js
Entrypoint b 21 bytes = 666f2b8847021ccc7608-666f2b.js
runtime modules 7.42 KiB 8 modules
orphan modules 23 bytes [orphan] 1 module
cacheable modules 426 bytes (javascript) 26.3 KiB (asset)
cacheable modules 514 bytes (javascript) 26.3 KiB (asset)
javascript modules 388 bytes
./a/index.js 150 bytes [built] [code generated]
./a/a.js 22 bytes [built] [code generated]
./a/b.js 66 bytes [built] [code generated]
./a/lazy.js + 1 modules 150 bytes [built] [code generated]
asset modules 126 bytes (javascript) 26.3 KiB (asset)
./a/file.jpg 42 bytes (javascript) 5.89 KiB (asset) [built] [code generated]
./a/file.png 42 bytes (javascript) 14.6 KiB (asset) [built] [code generated]
./a/file.jpg?query 42 bytes (javascript) 5.89 KiB (asset) [built] [code generated]
javascript modules 300 bytes
./a/index.js 150 bytes [built] [code generated]
./a/lazy.js + 1 modules 150 bytes [built] [code generated]
a-normal (webpack x.x.x) compiled successfully in X ms
b-normal:
assets by path *.js 3.14 KiB
asset 78946a272f83db936232-78946a.js 2.65 KiB [emitted] [immutable] [minimized] (name: runtime~main)
assets by path *.js 3.16 KiB
asset a608d8c4ea5e597b8ec0-a608d8.js 2.65 KiB [emitted] [immutable] [minimized] (name: runtime)
asset a639a9edc4557744bf94-a639a9.js 288 bytes [emitted] [immutable] [minimized] (name: lazy)
asset 3cc8faad16137711c07e-3cc8fa.js 210 bytes [emitted] [immutable] [minimized] (name: main)
asset b32c1c3b5e5cb3818671-b32c1c.js 210 bytes [emitted] [immutable] [minimized] (name: index)
asset 666f2b8847021ccc7608-666f2b.js 21 bytes [emitted] [immutable] [minimized] (name: a, b)
assets by chunk 20.4 KiB (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg?query 5.89 KiB [cached] [immutable] [from: file.jpg?query] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: main)
Entrypoint main 2.85 KiB (5.89 KiB) = 78946a272f83db936232-78946a.js 2.65 KiB 3cc8faad16137711c07e-3cc8fa.js 210 bytes 1 auxiliary asset
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: index)
Entrypoint index 2.85 KiB (5.89 KiB) = a608d8c4ea5e597b8ec0-a608d8.js 2.65 KiB b32c1c3b5e5cb3818671-b32c1c.js 210 bytes 1 auxiliary asset
Entrypoint a 21 bytes = 666f2b8847021ccc7608-666f2b.js
Entrypoint b 21 bytes = 666f2b8847021ccc7608-666f2b.js
runtime modules 7.42 KiB 8 modules
orphan modules 19 bytes [orphan] 1 module
cacheable modules 381 bytes (javascript) 26.3 KiB (asset)
cacheable modules 469 bytes (javascript) 26.3 KiB (asset)
javascript modules 343 bytes
./b/index.js 109 bytes [built] [code generated]
./b/a.js 22 bytes [built] [code generated]
./b/b.js 66 bytes [built] [code generated]
./b/lazy.js + 1 modules 146 bytes [built] [code generated]
asset modules 126 bytes (javascript) 26.3 KiB (asset)
./b/file.jpg 42 bytes (javascript) 5.89 KiB (asset) [built] [code generated]
./b/file.png 42 bytes (javascript) 14.6 KiB (asset) [built] [code generated]
./b/file.jpg?query 42 bytes (javascript) 5.89 KiB (asset) [built] [code generated]
javascript modules 255 bytes
./b/index.js 109 bytes [built] [code generated]
./b/lazy.js + 1 modules 146 bytes [built] [code generated]
b-normal (webpack x.x.x) compiled successfully in X ms
a-source-map:
assets by path *.js 3.3 KiB
asset 6ab6298c9ee98458fcc2-6ab629.js 2.7 KiB [emitted] [immutable] [minimized] (name: runtime~main)
sourceMap 6ab6298c9ee98458fcc2-6ab629.js.map 14.6 KiB [emitted] [dev] (auxiliary name: runtime~main)
assets by path *.js 3.38 KiB
asset 2064caf3f763dcbec7da-2064ca.js 2.7 KiB [emitted] [immutable] [minimized] (name: runtime)
sourceMap 2064caf3f763dcbec7da-2064ca.js.map 14.6 KiB [emitted] [dev] (auxiliary name: runtime)
asset 05c637d15dff2d0dc5fd-05c637.js 344 bytes [emitted] [immutable] [minimized] (name: lazy)
sourceMap 05c637d15dff2d0dc5fd-05c637.js.map 399 bytes [emitted] [dev] (auxiliary name: lazy)
asset b8bfcec62cdd15c9a840-b8bfce.js 266 bytes [emitted] [immutable] [minimized] (name: main)
sourceMap b8bfcec62cdd15c9a840-b8bfce.js.map 366 bytes [emitted] [dev] (auxiliary name: main)
asset 793a9ff3858dbc0b791d-793a9f.js 266 bytes [emitted] [immutable] [minimized] (name: index)
sourceMap 793a9ff3858dbc0b791d-793a9f.js.map 366 bytes [emitted] [dev] (auxiliary name: index)
asset 222c2acc68675174e6b2-222c2a.js 77 bytes [emitted] [immutable] [minimized] (name: a, b)
sourceMap 222c2acc68675174e6b2-222c2a.js.map 254 bytes [emitted] [dev] (auxiliary name: a, b)
assets by chunk 20.4 KiB (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg?query 5.89 KiB [cached] [immutable] [from: file.jpg?query] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: main)
Entrypoint main 2.96 KiB (20.8 KiB) = 6ab6298c9ee98458fcc2-6ab629.js 2.7 KiB b8bfcec62cdd15c9a840-b8bfce.js 266 bytes 3 auxiliary assets
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: index)
Entrypoint index 2.96 KiB (20.8 KiB) = 2064caf3f763dcbec7da-2064ca.js 2.7 KiB 793a9ff3858dbc0b791d-793a9f.js 266 bytes 3 auxiliary assets
Entrypoint a 77 bytes (254 bytes) = 222c2acc68675174e6b2-222c2a.js 1 auxiliary asset
Entrypoint b 77 bytes (254 bytes) = 222c2acc68675174e6b2-222c2a.js 1 auxiliary asset
runtime modules 7.42 KiB 8 modules
orphan modules 23 bytes [orphan] 1 module
cacheable modules 426 bytes (javascript) 26.3 KiB (asset)
cacheable modules 514 bytes (javascript) 26.3 KiB (asset)
javascript modules 388 bytes
./a/index.js 150 bytes [built] [code generated]
./a/a.js 22 bytes [built] [code generated]
./a/b.js 66 bytes [built] [code generated]
./a/lazy.js + 1 modules 150 bytes [built] [code generated]
asset modules 126 bytes (javascript) 26.3 KiB (asset)
./a/file.jpg 42 bytes (javascript) 5.89 KiB (asset) [built] [code generated]
./a/file.png 42 bytes (javascript) 14.6 KiB (asset) [built] [code generated]
./a/file.jpg?query 42 bytes (javascript) 5.89 KiB (asset) [built] [code generated]
javascript modules 300 bytes
./a/index.js 150 bytes [built] [code generated]
./a/lazy.js + 1 modules 150 bytes [built] [code generated]
a-source-map (webpack x.x.x) compiled successfully in X ms
b-source-map:
assets by path *.js 3.3 KiB
asset a16ab0460019d5b48418-a16ab0.js 2.7 KiB [emitted] [immutable] [minimized] (name: runtime~main)
sourceMap a16ab0460019d5b48418-a16ab0.js.map 14.6 KiB [emitted] [dev] (auxiliary name: runtime~main)
assets by path *.js 3.38 KiB
asset 5a04964d0347bb4c6f39-5a0496.js 2.7 KiB [emitted] [immutable] [minimized] (name: runtime)
sourceMap 5a04964d0347bb4c6f39-5a0496.js.map 14.6 KiB [emitted] [dev] (auxiliary name: runtime)
asset 05c637d15dff2d0dc5fd-05c637.js 344 bytes [emitted] [immutable] [minimized] (name: lazy)
sourceMap 05c637d15dff2d0dc5fd-05c637.js.map 395 bytes [emitted] [dev] (auxiliary name: lazy)
asset b8bfcec62cdd15c9a840-b8bfce.js 266 bytes [emitted] [immutable] [minimized] (name: main)
sourceMap b8bfcec62cdd15c9a840-b8bfce.js.map 323 bytes [emitted] [dev] (auxiliary name: main)
asset 793a9ff3858dbc0b791d-793a9f.js 266 bytes [emitted] [immutable] [minimized] (name: index)
sourceMap 793a9ff3858dbc0b791d-793a9f.js.map 323 bytes [emitted] [dev] (auxiliary name: index)
asset 222c2acc68675174e6b2-222c2a.js 77 bytes [emitted] [immutable] [minimized] (name: a, b)
sourceMap 222c2acc68675174e6b2-222c2a.js.map 254 bytes [emitted] [dev] (auxiliary name: a, b)
assets by chunk 20.4 KiB (auxiliary name: lazy)
asset 89a353e9c515885abd8e.png 14.6 KiB [emitted] [immutable] [from: file.png] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg?query 5.89 KiB [cached] [immutable] [from: file.jpg?query] (auxiliary name: lazy)
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: main)
Entrypoint main 2.96 KiB (20.8 KiB) = a16ab0460019d5b48418-a16ab0.js 2.7 KiB b8bfcec62cdd15c9a840-b8bfce.js 266 bytes 3 auxiliary assets
asset 7382fad5b015914e0811.jpg 5.89 KiB [emitted] [immutable] [from: file.jpg] (auxiliary name: index)
Entrypoint index 2.96 KiB (20.8 KiB) = 5a04964d0347bb4c6f39-5a0496.js 2.7 KiB 793a9ff3858dbc0b791d-793a9f.js 266 bytes 3 auxiliary assets
Entrypoint a 77 bytes (254 bytes) = 222c2acc68675174e6b2-222c2a.js 1 auxiliary asset
Entrypoint b 77 bytes (254 bytes) = 222c2acc68675174e6b2-222c2a.js 1 auxiliary asset
runtime modules 7.42 KiB 8 modules
orphan modules 19 bytes [orphan] 1 module
cacheable modules 381 bytes (javascript) 26.3 KiB (asset)
cacheable modules 469 bytes (javascript) 26.3 KiB (asset)
javascript modules 343 bytes
./b/index.js 109 bytes [built] [code generated]
./b/a.js 22 bytes [built] [code generated]
./b/b.js 66 bytes [built] [code generated]
./b/lazy.js + 1 modules 146 bytes [built] [code generated]
asset modules 126 bytes (javascript) 26.3 KiB (asset)
./b/file.jpg 42 bytes (javascript) 5.89 KiB (asset) [built] [code generated]
./b/file.png 42 bytes (javascript) 14.6 KiB (asset) [built] [code generated]
./b/file.jpg?query 42 bytes (javascript) 5.89 KiB (asset) [built] [code generated]
javascript modules 255 bytes
./b/index.js 109 bytes [built] [code generated]
./b/lazy.js + 1 modules 146 bytes [built] [code generated]
b-source-map (webpack x.x.x) compiled successfully in X ms"
`;

View File

@ -0,0 +1 @@
console.log("hello");

View File

@ -0,0 +1,4 @@
// yes that's important
if (true) {
console.log("hel" + "lo");
}

View File

@ -0,0 +1 @@
console.log("hello");

View File

@ -0,0 +1,4 @@
// yes that's important
if (true) {
console.log("hel" + "lo");
}

View File

@ -16,9 +16,12 @@ module.exports = {
const b = stats.stats[i + 1].toJson({
assets: true
});
expect(Object.keys(a.assetsByChunkName).length).toBe(3);
expect(Object.keys(a.assetsByChunkName).length).toBe(5);
expect(a.assetsByChunkName.main).toEqual(b.assetsByChunkName.main);
expect(a.assetsByChunkName.lazy).toEqual(b.assetsByChunkName.lazy);
expect(a.assetsByChunkName.a).toEqual(b.assetsByChunkName.a);
expect(a.assetsByChunkName.b).toEqual(b.assetsByChunkName.b);
expect(a.assetsByChunkName.a).toEqual(a.assetsByChunkName.b);
}
for (let i = 0; i < 4; i++) {
const statsData = stats.stats[i].toJson({

View File

@ -3,7 +3,14 @@ const path = require("path");
/** @type {import("../../../").Configuration} */
const base = {
mode: "production",
entry: "./index",
entry: {
index: {
import: "./index",
runtime: "runtime"
},
a: "./a",
b: "./b"
},
module: {
generator: {
asset: {
@ -18,7 +25,6 @@ const base = {
]
},
optimization: {
runtimeChunk: true,
minimize: true
},
stats: {