@@ -13,13 +13,15 @@ const utils = require('../utils');
1313const SIZES = new Set ( [ 'stat' , 'parsed' , 'compressed' ] ) ;
1414const ACCEPTED_SIZES = new Set ( [ ...SIZES , 'gzip' ] ) ;
1515
16+ const ALGORITHMS = new Set ( [ 'gzip' , 'brotli' ] ) ;
17+
1618const program = commander
1719 . version ( require ( '../../package.json' ) . version )
1820 . usage (
19- `<bundleStatsFile> [bundleDir] [options]
21+ `<bundleStatsFile> [bundleDir] [options]
2022
2123 Arguments:
22-
24+
2325 bundleStatsFile Path to Webpack Stats JSON file.
2426 bundleDir Directory containing all generated bundles.
2527 You should provided it if you want analyzer to show you the real parsed module sizes.
@@ -56,17 +58,23 @@ const program = commander
5658 . option (
5759 '-s, --default-sizes <type>' ,
5860 'Module sizes to show in treemap by default.' +
59- br ( `Possible values: ${ [ ...SIZES ] . join ( ', ' ) } ` ) ,
61+ br ( `Possible values: ${ [ ...SIZES ] . join ( ', ' ) } ` ) ,
6062 'parsed'
6163 )
64+ . option (
65+ '--compression-algorithm <type>' ,
66+ 'Compression algorithm that will be used to calculate the compressed module sizes.' +
67+ br ( `Possible values: ${ [ ...ALGORITHMS ] . join ( ', ' ) } ` ) ,
68+ 'gzip'
69+ )
6270 . option (
6371 '-O, --no-open' ,
6472 "Don't open report in default browser automatically."
6573 )
6674 . option (
6775 '-e, --exclude <regexp>' ,
6876 'Assets that should be excluded from the report.' +
69- br ( 'Can be specified multiple times.' ) ,
77+ br ( 'Can be specified multiple times.' ) ,
7078 array ( )
7179 )
7280 . option (
8492 report : reportFilename ,
8593 title : reportTitle ,
8694 defaultSizes,
95+ compressionAlgorithm,
8796 logLevel,
8897 open : openBrowser ,
8998 exclude : excludeAssets ,
@@ -108,6 +117,9 @@ if (mode === 'server') {
108117if ( ! ACCEPTED_SIZES . has ( defaultSizes ) ) {
109118 showHelp ( `Invalid default sizes option. Possible values are: ${ [ ...SIZES ] . join ( ', ' ) } ` ) ;
110119}
120+ if ( ! ALGORITHMS . has ( compressionAlgorithm ) ) {
121+ showHelp ( `Invalid compression algorithm option. Possible values are: ${ [ ...ALGORITHMS ] . join ( ', ' ) } ` ) ;
122+ }
111123
112124bundleStatsFile = resolve ( bundleStatsFile ) ;
113125
@@ -128,6 +140,7 @@ if (mode === 'server') {
128140 port,
129141 host,
130142 defaultSizes,
143+ compressionAlgorithm,
131144 reportTitle,
132145 bundleDir,
133146 excludeAssets,
@@ -139,13 +152,15 @@ if (mode === 'server') {
139152 reportFilename : resolve ( reportFilename || 'report.html' ) ,
140153 reportTitle,
141154 defaultSizes,
155+ compressionAlgorithm,
142156 bundleDir,
143157 excludeAssets,
144158 logger : new Logger ( logLevel )
145159 } ) ;
146160} else if ( mode === 'json' ) {
147161 viewer . generateJSONReport ( bundleStats , {
148162 reportFilename : resolve ( reportFilename || 'report.json' ) ,
163+ compressionAlgorithm,
149164 bundleDir,
150165 excludeAssets,
151166 logger : new Logger ( logLevel )
@@ -159,7 +174,7 @@ function showHelp(error) {
159174}
160175
161176function br ( str ) {
162- return `\n${ ' ' . repeat ( 28 ) } ${ str } ` ;
177+ return `\n${ ' ' . repeat ( 32 ) } ${ str } ` ;
163178}
164179
165180function array ( ) {
0 commit comments