Skip to content

Commit 8117cd0

Browse files
committed
Change public API from gzip to compressed
To be in line with the new `compressedSize*` options. Supports `gzip` as a synonym for backwards compatibility. Internal naming is also still `gzip*`.
1 parent 09363f0 commit 8117cd0

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ new BundleAnalyzerPlugin(options?: object)
6161
|**`analyzerPort`**|`{Number}` or `auto`|Default: `8888`. Port that will be used in `server` mode to start HTTP server.|
6262
|**`reportFilename`**|`{String}`|Default: `report.html`. Path to bundle report file that will be generated in `static` mode. It can be either an absolute path or a path relative to a bundle output directory (which is output.path in webpack config).|
6363
|**`reportTitle`**|`{String\|function}`|Default: function that returns pretty printed current date and time. Content of the HTML `title` element; or a function of the form `() => string` that provides the content.|
64-
|**`defaultSizes`**|One of: `stat`, `parsed`, `gzip`|Default: `parsed`. Module sizes to show in report by default. [Size definitions](#size-definitions) section describes what these values mean.|
64+
|**`defaultSizes`**|One of: `stat`, `parsed`, `compressed`|Default: `parsed`. Module sizes to show in report by default. [Size definitions](#size-definitions) section describes what these values mean.|
6565
|**`openAnalyzer`**|`{Boolean}`|Default: `true`. Automatically open report in default browser.|
6666
|**`generateStatsFile`**|`{Boolean}`|Default: `false`. If `true`, webpack stats JSON file will be generated in bundle output directory|
6767
|**`statsFilename`**|`{String}`|Default: `stats.json`. Name of webpack stats JSON file that will be generated if `generateStatsFile` is `true`. It can be either an absolute path or a path relative to a bundle output directory (which is output.path in webpack config).|
@@ -121,7 +121,7 @@ Directory containing all generated bundles.
121121
-r, --report <file> Path to bundle report file that will be generated in `static` mode. (default: report.html)
122122
-t, --title <title> String to use in title element of html report. (default: pretty printed current date)
123123
-s, --default-sizes <type> Module sizes to show in treemap by default.
124-
Possible values: stat, parsed, gzip (default: parsed)
124+
Possible values: stat, parsed, compressed (default: parsed)
125125
-O, --no-open Don't open report in default browser automatically.
126126
-e, --exclude <regexp> Assets that should be excluded from the report.
127127
Can be specified multiple times.
@@ -147,9 +147,9 @@ It is called "stat size" because it's obtained from Webpack's
147147
This is the "output" size of your files. If you're using a Webpack plugin such
148148
as Uglify, then this value will reflect the minified size of your code.
149149

150-
### `gzip`
150+
### `compressed`
151151

152-
This is the size of running the parsed bundles/modules through gzip compression.
152+
This is the size of running the parsed bundles/modules through compression.
153153

154154
<h2 align="center">Selecting Which Chunks to Display</h2>
155155

@@ -169,7 +169,7 @@ The Chunk Context Menu can be opened by right-clicking or `Ctrl`-clicking on a s
169169

170170
<h2 align="center">Troubleshooting</h2>
171171

172-
### I don't see `gzip` or `parsed` sizes, it only shows `stat` size
172+
### I don't see `compressed` or `parsed` sizes, it only shows `stat` size
173173

174174
It happens when `webpack-bundle-analyzer` analyzes files that don't actually exist in your file system, for example when you work with `webpack-dev-server` that keeps all the files in RAM. If you use `webpack-bundle-analyzer` as a plugin you won't get any errors, however if you run it via CLI you get the error message in terminal:
175175
```

src/bin/analyzer.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const viewer = require('../viewer');
1010
const Logger = require('../Logger');
1111
const utils = require('../utils');
1212

13-
const SIZES = new Set(['stat', 'parsed', 'gzip']);
13+
const SIZES = new Set(['stat', 'parsed', 'compressed']);
14+
const ACCEPTED_SIZES = new Set([...SIZES, 'gzip']);
1415

1516
const program = commander
1617
.version(require('../../package.json').version)
@@ -110,7 +111,9 @@ if (mode === 'server') {
110111
port = port === 'auto' ? 0 : Number(port);
111112
if (isNaN(port)) showHelp('Invalid port. Should be a number or `auto`');
112113
}
113-
if (!SIZES.has(defaultSizes)) showHelp(`Invalid default sizes option. Possible values are: ${[...SIZES].join(', ')}`);
114+
if (!ACCEPTED_SIZES.has(defaultSizes)) {
115+
showHelp(`Invalid default sizes option. Possible values are: ${[...SIZES].join(', ')}`);
116+
}
114117

115118
bundleStatsFile = resolve(bundleStatsFile);
116119

src/viewer.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ function resolveTitle(reportTitle) {
2222
}
2323
}
2424

25+
function resolveDefaultSizes(defaultSizes) {
26+
return defaultSizes === 'compressed' ? 'gzip' : defaultSizes;
27+
}
28+
2529
module.exports = {
2630
startServer,
2731
generateReport,
@@ -61,7 +65,7 @@ async function startServer(bundleStats, opts) {
6165
mode: 'server',
6266
title: resolveTitle(reportTitle),
6367
chartData,
64-
defaultSizes,
68+
defaultSizes: resolveDefaultSizes(defaultSizes),
6569
compressedSizeLabel,
6670
enableWebSocket: true
6771
});
@@ -145,7 +149,7 @@ async function generateReport(bundleStats, opts) {
145149
mode: 'static',
146150
title: resolveTitle(reportTitle),
147151
chartData,
148-
defaultSizes,
152+
defaultSizes: resolveDefaultSizes(defaultSizes),
149153
compressedSizeLabel,
150154
enableWebSocket: false
151155
});

0 commit comments

Comments
 (0)