Skip to content

Commit ae2ae4e

Browse files
authored
Merge pull request webpack#6640 from clarkdo/module-assets
fix: module assets is in buildInfo
2 parents 01a5224 + 23208a3 commit ae2ae4e

File tree

7 files changed

+58
-1
lines changed

7 files changed

+58
-1
lines changed

lib/Stats.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ class Stats {
136136
options.nestedModules,
137137
true
138138
);
139+
const showModuleAssets = optionOrLocalFallback(
140+
options.moduleAssets,
141+
!forToString
142+
);
139143
const showDepth = optionOrLocalFallback(options.depth, !forToString);
140144
const showCachedModules = optionOrLocalFallback(options.cached, true);
141145
const showCachedAssets = optionOrLocalFallback(options.cachedAssets, true);
@@ -417,7 +421,6 @@ class Stats {
417421
optional: module.optional,
418422
prefetched: module.prefetched,
419423
chunks: Array.from(module.chunksIterable, chunk => chunk.id),
420-
assets: Object.keys(module.assets || {}),
421424
issuer: module.issuer && module.issuer.identifier(),
422425
issuerId: module.issuer && module.issuer.id,
423426
issuerName:
@@ -435,6 +438,9 @@ class Stats {
435438
errors: module.errors ? module.errors.length : 0,
436439
warnings: module.warnings ? module.warnings.length : 0
437440
};
441+
if (showModuleAssets) {
442+
obj.assets = Object.keys(module.buildInfo.assets || {});
443+
}
438444
if (showReasons) {
439445
obj.reasons = module.reasons
440446
.map(reason => {
@@ -867,6 +873,13 @@ class Stats {
867873
if (module.built) {
868874
colors.green(" [built]");
869875
}
876+
if (module.assets && module.assets.length) {
877+
colors.magenta(
878+
` [${module.assets.length} asset${
879+
module.assets.length === 1 ? "" : "s"
880+
}]`
881+
);
882+
}
870883
if (module.prefetched) {
871884
colors.magenta(" [prefetched]");
872885
}

schemas/WebpackOptions.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,10 @@
17671767
"type": "boolean",
17681768
"description": "add information about modules nested in other modules (like with module concatenation)"
17691769
},
1770+
"moduleAssets": {
1771+
"type": "boolean",
1772+
"description": "add information about assets inside modules"
1773+
},
17701774
"children": {
17711775
"type": "boolean",
17721776
"description": "add children information"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Hash: d71bd16b0b20f34e994a
2+
Time: Xms
3+
Built at: Thu Jan 01 1970 00:00:00 GMT
4+
Entrypoint main = main.js
5+
chunk {0} 0.js 68 bytes <{1}> [rendered]
6+
[0] ./node_modules/a/1.png 51 bytes {0} [built] [1 asset]
7+
[1] ./node_modules/a/index.js 17 bytes {0} [built]
8+
chunk {1} main.js (main) 12 bytes >{0}< [entry] [rendered]
9+
[2] ./index.js 12 bytes {1} [built]
10+
[0] ./node_modules/a/1.png 51 bytes {0} [built] [1 asset]
11+
[1] ./node_modules/a/index.js 17 bytes {0} [built]
12+
[2] ./index.js 12 bytes {1} [built]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import('a')
Loading

test/statsCases/module-assets/node_modules/a/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
mode: "production",
3+
entry: "./index",
4+
stats: {
5+
assets: false,
6+
chunks: true,
7+
chunkModules: true,
8+
modules: true,
9+
moduleAssets: true
10+
},
11+
module: {
12+
rules: [
13+
{
14+
test: /\.png$/,
15+
use: [
16+
{
17+
loader: "file-loader",
18+
options: {
19+
name: "[name].[ext]"
20+
}
21+
}
22+
]
23+
}
24+
]
25+
}
26+
};

0 commit comments

Comments
 (0)