Skip to content

Commit 82c08ad

Browse files
EugeneHlushkomontogeek
authored andcommitted
docs(api) document stats asset info object props (#3283)
1 parent 1356322 commit 82c08ad

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

src/content/api/stats.mdx

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ contributors:
55
- skipjack
66
- franjohn21
77
- byzyk
8+
- EugeneHlushko
89
---
910

1011
When compiling source code with webpack, users can generate a JSON file containing statistics about modules. These statistics can be used to analyze an application's dependency graph as well as to optimize compilation speed. The file is typically generated with the following CLI command:
@@ -22,33 +23,33 @@ The top-level structure of the output JSON file is fairly straightforward but th
2223

2324
``` js-with-links
2425
{
25-
"version": "1.4.13", // Version of webpack used for the compilation
26-
"hash": "11593e3b3ac85436984a", // Compilation specific hash
27-
"time": 2469, // Compilation time in milliseconds
28-
"filteredModules": 0, // A count of excluded modules when [`exclude`](/configuration/stats/#stats) is passed to the [`toJson`](/api/node/#statstojsonoptions) method
29-
"outputPath": "/", // path to webpack output directory
30-
"assetsByChunkName": {
26+
'version': '1.4.13', // Version of webpack used for the compilation
27+
'hash': '11593e3b3ac85436984a', // Compilation specific hash
28+
'time': 2469, // Compilation time in milliseconds
29+
'filteredModules': 0, // A count of excluded modules when [`exclude`](/configuration/stats/#stats) is passed to the [`toJson`](/api/node/#statstojsonoptions) method
30+
'outputPath': '/', // path to webpack output directory
31+
'assetsByChunkName': {
3132
// Chunk name to emitted asset(s) mapping
32-
"main": "web.js?h=11593e3b3ac85436984a",
33-
"named-chunk": "named-chunk.web.js",
34-
"other-chunk": [
35-
"other-chunk.js",
36-
"other-chunk.css"
33+
'main': 'web.js?h=11593e3b3ac85436984a',
34+
'named-chunk': 'named-chunk.web.js',
35+
'other-chunk': [
36+
'other-chunk.js',
37+
'other-chunk.css'
3738
]
3839
},
39-
"assets": [
40+
'assets': [
4041
// A list of [asset objects](#asset-objects)
4142
],
42-
"chunks": [
43+
'chunks': [
4344
// A list of [chunk objects](#chunk-objects)
4445
],
45-
"modules": [
46+
'modules': [
4647
// A list of [module objects](#module-objects)
4748
],
48-
"errors": [
49+
'errors': [
4950
// A list of [error strings](#errors-and-warnings)
5051
],
51-
"warnings": [
52+
'warnings': [
5253
// A list of [warning strings](#errors-and-warnings)
5354
]
5455
}
@@ -63,14 +64,22 @@ Each `assets` object represents an `output` file emitted from the compilation. T
6364

6465
```js
6566
{
66-
"chunkNames": [], // The chunks this asset contains
67-
"chunks": [ 10, 6 ], // The chunk IDs this asset contains
68-
"emitted": true, // Indicates whether or not the asset made it to the `output` directory
69-
"name": "10.web.js", // The `output` filename
70-
"size": 1058 // The size of the file in bytes
67+
'chunkNames': [], // The chunks this asset contains
68+
'chunks': [ 10, 6 ], // The chunk IDs this asset contains
69+
'emitted': true, // Indicates whether or not the asset made it to the `output` directory
70+
'name': '10.web.js', // The `output` filename
71+
'size': 1058, // The size of the file in bytes
72+
'info': {
73+
'immutable': true, // A flag telling whether the asset can be long term cached (contains a hash)
74+
'size': 1058, // The size in bytes, only becomes available after asset has been emitted
75+
'development': true, // A flag telling whether the asset is only used for development and doesn't count towards user-facing assets
76+
'hotModuleReplacement': true // A flag telling whether the asset ships data for updating an existing application (HMR)
77+
}
7178
}
7279
```
7380

81+
T> Asset's `info` property is available since webpack v4.40.0
82+
7483

7584
### Chunk Objects
7685

0 commit comments

Comments
 (0)