Skip to content

Commit f27dfc2

Browse files
committed
add stats cases for named chunks
1 parent 04e4a14 commit f27dfc2

File tree

11 files changed

+83
-0
lines changed

11 files changed

+83
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import("./modules/a");
2+
import("./modules/b");
3+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Hash: ad8adb01e611de794006
2+
Time: Xms
3+
Asset Size Chunks Chunk Names
4+
chunk-containing-__a_js.js 266 bytes chunk-containing-__a_js [emitted]
5+
chunk-containing-__b_js.js 123 bytes chunk-containing-__b_js [emitted]
6+
entry.js 5.93 kB entry [emitted] entry
7+
chunk {chunk-containing-__a_js} chunk-containing-__a_js.js 37 bytes {entry} [rendered]
8+
[2] (webpack)/test/statsCases/named-chunks-plugin-async/modules/a.js 37 bytes {chunk-containing-__a_js} [built]
9+
chunk {chunk-containing-__b_js} chunk-containing-__b_js.js 22 bytes {chunk-containing-__a_js} {entry} [rendered]
10+
[0] (webpack)/test/statsCases/named-chunks-plugin-async/modules/b.js 22 bytes {chunk-containing-__b_js} [built]
11+
chunk {entry} entry.js (entry) 47 bytes [entry] [rendered]
12+
[1] (webpack)/test/statsCases/named-chunks-plugin-async/entry.js 47 bytes {entry} [built]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import("./b");
2+
module.exports = "a";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "b";
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"use strict";
2+
3+
const NamedChunksPlugin = require("../../../lib/NamedChunksPlugin");
4+
const RequestShortener = require("../../../lib/RequestShortener");
5+
6+
module.exports = {
7+
entry: {
8+
"entry": "./entry",
9+
},
10+
plugins: [
11+
new NamedChunksPlugin(function(chunk) {
12+
if(chunk.name) {
13+
return chunk.name;
14+
}
15+
const modulesToName = (mods) => mods.map((mod) => {
16+
const rs = new RequestShortener(mod.context);
17+
return rs.shorten(mod.request).replace(/[.\/\\]/g, "_");
18+
}).join("-");
19+
20+
if(chunk.modules.length > 0) {
21+
return `chunk-containing-${modulesToName(chunk.modules)}`;
22+
}
23+
24+
return null;
25+
}),
26+
]
27+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require("./modules/a");
2+
require("./modules/b");
3+
require("./modules/c");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Hash: 94a45a9bbaecf6012107
2+
Time: Xms
3+
Asset Size Chunks Chunk Names
4+
entry.js 356 bytes entry, manifest [emitted] entry
5+
manifest.js 5.72 kB manifest [emitted] manifest
6+
vendor.js 408 bytes vendor, manifest [emitted] vendor
7+
chunk {entry} entry.js (entry) 94 bytes {vendor} [initial] [rendered]
8+
[./entry.js] (webpack)/test/statsCases/named-chunks-plugin/entry.js 72 bytes {entry} [built]
9+
[./modules/c.js] (webpack)/test/statsCases/named-chunks-plugin/modules/c.js 22 bytes {entry} [built]
10+
chunk {manifest} manifest.js (manifest) 0 bytes [entry] [rendered]
11+
chunk {vendor} vendor.js (vendor) 84 bytes {manifest} [initial] [rendered]
12+
[./modules/a.js] (webpack)/test/statsCases/named-chunks-plugin/modules/a.js 22 bytes {vendor} [built]
13+
[./modules/b.js] (webpack)/test/statsCases/named-chunks-plugin/modules/b.js 22 bytes {vendor} [built]
14+
[0] multi ./modules/a ./modules/b 40 bytes {vendor} [built]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "a";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "b";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "c";

0 commit comments

Comments
 (0)