Skip to content

Commit

Permalink
docs(api): update stats data (#4225)
Browse files Browse the repository at this point in the history
* docs(api): update stats data

* apply suggestions from code review

Co-authored-by: Sam Chen <[email protected]>

* Update src/content/api/stats.mdx

Co-authored-by: Sam Chen <[email protected]>

Co-authored-by: Sam Chen <[email protected]>
  • Loading branch information
snitin315 and chenxsan authored Dec 1, 2020
1 parent d416b85 commit 64e4231
Showing 1 changed file with 35 additions and 5 deletions.
40 changes: 35 additions & 5 deletions src/content/api/stats.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ contributors:
- superburrito
- chenxsan
- rahul3v
- snitin315
---

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:

``` bash
webpack --profile --json > compilation-stats.json
npx webpack --profile --json=compilation-stats.json
```

The `--json > compilation-stats.json` flag indicates to webpack that it should emit the `compilation-stats.json` containing the dependency graph and various other build information. Typically, the `--profile` flag is also added so that a `profile` section is added to each [`modules` object](#module-objects) containing module-specific compilation stats.
The `--json=compilation-stats.json` flag indicates to webpack that it should emit the `compilation-stats.json` containing the dependency graph and various other build information. Typically, the `--profile` flag is also added so that a `profile` section is added to each [`modules` object](#module-objects) containing module-specific compilation stats.


## Structure
Expand All @@ -26,10 +27,10 @@ The top-level structure of the output JSON file is fairly straightforward but th

``` js-with-links
{
'version': '5.0.0-alpha.6', // Version of webpack used for the compilation
'version': '5.9.0', // Version of webpack used for the compilation
'hash': '11593e3b3ac85436984a', // Compilation specific hash
'time': 2469, // Compilation time in milliseconds
'filteredModules': 0, // A count of excluded modules when [`exclude`](/configuration/stats/#statsexclude) is passed to the [`toJson`](/api/node/#statstojsonoptions) method
'publicPath': 'auto',
'outputPath': '/', // path to webpack output directory
'assetsByChunkName': {
// Chunk name to emitted asset(s) mapping
Expand All @@ -53,12 +54,17 @@ The top-level structure of the output JSON file is fairly straightforward but th
'modules': [
// A list of [module objects](#module-objects)
],
'entryPoints': {
// A list of [entry objects](#entry-objects)
},
'errors': [
// A list of [error objects](#errors-and-warnings)
],
'errorsCount': 0, // number of errors
'warnings': [
// A list of [warning objects](#errors-and-warnings)
]
],
'warningsCount': 0, // nummber of warnings
}
```

Expand Down Expand Up @@ -187,6 +193,30 @@ Every module also contains a list of `reasons` objects describing why that modul
}
```

### Entry Objects

```json
"main": {
"name": "main",
"chunks": [
179
],
"assets": [
{
"name": "main.js",
"size": 22
}
],
"filteredAssets": 0,
"assetsSize": 22,
"auxiliaryAssets": [],
"filteredAuxiliaryAssets": 0,
"auxiliaryAssetsSize": 0,
"children": {},
"childAssets": {},
"isOverSizeLimit": false
}
```

### Errors and Warnings

Expand Down

1 comment on commit 64e4231

@vercel
Copy link

@vercel vercel bot commented on 64e4231 Dec 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.