webpack-bundle-analyzer 5.1.1 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -4
- package/lib/analyzer.js +2 -0
- package/lib/bin/analyzer.js +4 -1
- package/lib/sizeUtils.js +5 -0
- package/lib/tree/ConcatenatedModule.js +3 -0
- package/lib/tree/ContentFolder.js +4 -0
- package/lib/tree/ContentModule.js +3 -0
- package/lib/tree/Folder.js +5 -1
- package/lib/tree/Module.js +9 -1
- package/lib/viewer.js +1 -1
- package/package.json +3 -3
- package/public/viewer.js +2 -2
- package/public/viewer.js.map +1 -1
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ This module will help you:
|
|
|
45
45
|
4. Optimize it!
|
|
46
46
|
|
|
47
47
|
And the best thing is it supports minified bundles! It parses them to get real size of bundled modules.
|
|
48
|
-
And it also shows their gzipped or
|
|
48
|
+
And it also shows their gzipped, Brotli, or Zstandard sizes!
|
|
49
49
|
|
|
50
50
|
<h2 align="center">Options (for plugin)</h2>
|
|
51
51
|
|
|
@@ -62,7 +62,7 @@ new BundleAnalyzerPlugin(options?: object)
|
|
|
62
62
|
|**`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).|
|
|
63
63
|
|**`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
64
|
|**`defaultSizes`**|One of: `stat`, `parsed`, `gzip`, `brotli`|Default: `parsed`. Module sizes to show in report by default. [Size definitions](#size-definitions) section describes what these values mean.|
|
|
65
|
-
|**`compressionAlgorithm`**|One of: `gzip`, `brotli`|Default: `gzip`. Compression type used to calculate the compressed module sizes.|
|
|
65
|
+
|**`compressionAlgorithm`**|One of: `gzip`, `brotli`, `zstd`|Default: `gzip`. Compression type used to calculate the compressed module sizes.|
|
|
66
66
|
|**`openAnalyzer`**|`{Boolean}`|Default: `true`. Automatically open report in default browser.|
|
|
67
67
|
|**`generateStatsFile`**|`{Boolean}`|Default: `false`. If `true`, webpack stats JSON file will be generated in bundle output directory|
|
|
68
68
|
|**`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).|
|
|
@@ -122,9 +122,9 @@ Directory containing all generated bundles.
|
|
|
122
122
|
-r, --report <file> Path to bundle report file that will be generated in `static` mode. (default: report.html)
|
|
123
123
|
-t, --title <title> String to use in title element of html report. (default: pretty printed current date)
|
|
124
124
|
-s, --default-sizes <type> Module sizes to show in treemap by default.
|
|
125
|
-
Possible values: stat, parsed, gzip, brotli (default: parsed)
|
|
125
|
+
Possible values: stat, parsed, gzip, brotli, zstd (default: parsed)
|
|
126
126
|
--compression-algorithm <type> Compression algorithm that will be used to calculate the compressed module sizes.
|
|
127
|
-
Possible values: gzip, brotli (default: gzip)
|
|
127
|
+
Possible values: gzip, brotli, zstd (default: gzip)
|
|
128
128
|
-O, --no-open Don't open report in default browser automatically.
|
|
129
129
|
-e, --exclude <regexp> Assets that should be excluded from the report.
|
|
130
130
|
Can be specified multiple times.
|
|
@@ -158,6 +158,10 @@ This is the size of running the parsed bundles/modules through gzip compression.
|
|
|
158
158
|
|
|
159
159
|
This is the size of running the parsed bundles/modules through Brotli compression.
|
|
160
160
|
|
|
161
|
+
### `zstd`
|
|
162
|
+
|
|
163
|
+
This is the size of running the parsed bundles/modules through Zstandard compression. (Node.js 22.15.0+ is required for this feature)
|
|
164
|
+
|
|
161
165
|
<h2 align="center">Selecting Which Chunks to Display</h2>
|
|
162
166
|
|
|
163
167
|
When opened, the report displays all of the Webpack chunks for your project. It's possible to filter to a more specific list of chunks by using the sidebar or the chunk context menu.
|
package/lib/analyzer.js
CHANGED
|
@@ -111,6 +111,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
|
|
|
111
111
|
asset.parsedSize = Buffer.byteLength(assetSources.src);
|
|
112
112
|
if (compressionAlgorithm === 'gzip') asset.gzipSize = getCompressedSize('gzip', assetSources.src);
|
|
113
113
|
if (compressionAlgorithm === 'brotli') asset.brotliSize = getCompressedSize('brotli', assetSources.src);
|
|
114
|
+
if (compressionAlgorithm === 'zstd') asset.zstdSize = getCompressedSize('zstd', assetSources.src);
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
// Picking modules from current bundle script
|
|
@@ -166,6 +167,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
|
|
|
166
167
|
parsedSize: asset.parsedSize,
|
|
167
168
|
gzipSize: asset.gzipSize,
|
|
168
169
|
brotliSize: asset.brotliSize,
|
|
170
|
+
zstdSize: asset.zstdSize,
|
|
169
171
|
groups: Object.values(asset.tree.children).map(i => i.toChartData()),
|
|
170
172
|
isInitialByEntrypoint: chunkToInitialByEntrypoint[filename] ?? {}
|
|
171
173
|
}));
|
package/lib/bin/analyzer.js
CHANGED
|
@@ -13,8 +13,11 @@ const analyzer = require('../analyzer');
|
|
|
13
13
|
const viewer = require('../viewer');
|
|
14
14
|
const Logger = require('../Logger');
|
|
15
15
|
const utils = require('../utils');
|
|
16
|
+
const {
|
|
17
|
+
isZstdSupported
|
|
18
|
+
} = require('../sizeUtils');
|
|
16
19
|
const SIZES = new Set(['stat', 'parsed', 'gzip']);
|
|
17
|
-
const COMPRESSION_ALGORITHMS = new Set(['gzip', 'brotli']);
|
|
20
|
+
const COMPRESSION_ALGORITHMS = new Set(isZstdSupported ? ['gzip', 'brotli', 'zstd'] : ['gzip', 'brotli']);
|
|
18
21
|
const program = commander.version(require('../../package.json').version).usage(`<bundleStatsFile> [bundleDir] [options]
|
|
19
22
|
|
|
20
23
|
Arguments:
|
package/lib/sizeUtils.js
CHANGED
|
@@ -4,11 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getCompressedSize = getCompressedSize;
|
|
7
|
+
exports.isZstdSupported = void 0;
|
|
7
8
|
const zlib = require('zlib');
|
|
9
|
+
const isZstdSupported = exports.isZstdSupported = 'createZstdCompress' in zlib;
|
|
8
10
|
function getCompressedSize(compressionAlgorithm, input) {
|
|
9
11
|
if (compressionAlgorithm === 'gzip') return zlib.gzipSync(input, {
|
|
10
12
|
level: 9
|
|
11
13
|
}).length;
|
|
12
14
|
if (compressionAlgorithm === 'brotli') return zlib.brotliCompressSync(input).length;
|
|
15
|
+
if (compressionAlgorithm === 'zstd' && isZstdSupported) {
|
|
16
|
+
return zlib.zstdCompressSync(input).length;
|
|
17
|
+
}
|
|
13
18
|
throw new Error(`Unsupported compression algorithm: ${compressionAlgorithm}.`);
|
|
14
19
|
}
|
|
@@ -25,6 +25,9 @@ class ConcatenatedModule extends _Module.default {
|
|
|
25
25
|
get brotliSize() {
|
|
26
26
|
return this.getBrotliSize() ?? this.getEstimatedSize('brotliSize');
|
|
27
27
|
}
|
|
28
|
+
get zstdSize() {
|
|
29
|
+
return this.getZstdSize() ?? this.getEstimatedSize('zstdSize');
|
|
30
|
+
}
|
|
28
31
|
getEstimatedSize(sizeType) {
|
|
29
32
|
const parentModuleSize = this.parent[sizeType];
|
|
30
33
|
if (parentModuleSize !== undefined) {
|
|
@@ -20,6 +20,9 @@ class ContentFolder extends _BaseFolder.default {
|
|
|
20
20
|
get brotliSize() {
|
|
21
21
|
return this.getSize('brotliSize');
|
|
22
22
|
}
|
|
23
|
+
get zstdSize() {
|
|
24
|
+
return this.getSize('zstdSize');
|
|
25
|
+
}
|
|
23
26
|
getSize(sizeType) {
|
|
24
27
|
const ownerModuleSize = this.ownerModule[sizeType];
|
|
25
28
|
if (ownerModuleSize !== undefined) {
|
|
@@ -32,6 +35,7 @@ class ContentFolder extends _BaseFolder.default {
|
|
|
32
35
|
parsedSize: this.parsedSize,
|
|
33
36
|
gzipSize: this.gzipSize,
|
|
34
37
|
brotliSize: this.brotliSize,
|
|
38
|
+
zstdSize: this.zstdSize,
|
|
35
39
|
inaccurateSizes: true
|
|
36
40
|
};
|
|
37
41
|
}
|
|
@@ -20,6 +20,9 @@ class ContentModule extends _Module.default {
|
|
|
20
20
|
get brotliSize() {
|
|
21
21
|
return this.getSize('brotliSize');
|
|
22
22
|
}
|
|
23
|
+
get zstdSize() {
|
|
24
|
+
return this.getSize('zstdSize');
|
|
25
|
+
}
|
|
23
26
|
getSize(sizeType) {
|
|
24
27
|
const ownerModuleSize = this.ownerModule[sizeType];
|
|
25
28
|
if (ownerModuleSize !== undefined) {
|
package/lib/tree/Folder.js
CHANGED
|
@@ -24,6 +24,9 @@ class Folder extends _BaseFolder.default {
|
|
|
24
24
|
get brotliSize() {
|
|
25
25
|
return this.opts.compressionAlgorithm === 'brotli' ? this.getCompressedSize('brotli') : undefined;
|
|
26
26
|
}
|
|
27
|
+
get zstdSize() {
|
|
28
|
+
return this.opts.compressionAlgorithm === 'zstd' ? this.getCompressedSize('zstd') : undefined;
|
|
29
|
+
}
|
|
27
30
|
getCompressedSize(compressionAlgorithm) {
|
|
28
31
|
const key = `_${compressionAlgorithm}Size`;
|
|
29
32
|
if (!Object.prototype.hasOwnProperty.call(this, key)) {
|
|
@@ -61,7 +64,8 @@ class Folder extends _BaseFolder.default {
|
|
|
61
64
|
...super.toChartData(),
|
|
62
65
|
parsedSize: this.parsedSize,
|
|
63
66
|
gzipSize: this.gzipSize,
|
|
64
|
-
brotliSize: this.brotliSize
|
|
67
|
+
brotliSize: this.brotliSize,
|
|
68
|
+
zstdSize: this.zstdSize
|
|
65
69
|
};
|
|
66
70
|
}
|
|
67
71
|
}
|
package/lib/tree/Module.js
CHANGED
|
@@ -20,6 +20,7 @@ class Module extends _Node.default {
|
|
|
20
20
|
this.data.parsedSrc = value;
|
|
21
21
|
delete this._gzipSize;
|
|
22
22
|
delete this._brotliSize;
|
|
23
|
+
delete this._zstdSize;
|
|
23
24
|
}
|
|
24
25
|
get size() {
|
|
25
26
|
return this.data.size;
|
|
@@ -36,6 +37,9 @@ class Module extends _Node.default {
|
|
|
36
37
|
get brotliSize() {
|
|
37
38
|
return this.getBrotliSize();
|
|
38
39
|
}
|
|
40
|
+
get zstdSize() {
|
|
41
|
+
return this.getZstdSize();
|
|
42
|
+
}
|
|
39
43
|
getParsedSize() {
|
|
40
44
|
return this.src ? this.src.length : undefined;
|
|
41
45
|
}
|
|
@@ -45,6 +49,9 @@ class Module extends _Node.default {
|
|
|
45
49
|
getBrotliSize() {
|
|
46
50
|
return this.opts.compressionAlgorithm === 'brotli' ? this.getCompressedSize('brotli') : undefined;
|
|
47
51
|
}
|
|
52
|
+
getZstdSize() {
|
|
53
|
+
return this.opts.compressionAlgorithm === 'zstd' ? this.getCompressedSize('zstd') : undefined;
|
|
54
|
+
}
|
|
48
55
|
getCompressedSize(compressionAlgorithm) {
|
|
49
56
|
const key = `_${compressionAlgorithm}Size`;
|
|
50
57
|
if (!(key in this)) {
|
|
@@ -68,7 +75,8 @@ class Module extends _Node.default {
|
|
|
68
75
|
statSize: this.size,
|
|
69
76
|
parsedSize: this.parsedSize,
|
|
70
77
|
gzipSize: this.gzipSize,
|
|
71
|
-
brotliSize: this.brotliSize
|
|
78
|
+
brotliSize: this.brotliSize,
|
|
79
|
+
zstdSize: this.zstdSize
|
|
72
80
|
};
|
|
73
81
|
}
|
|
74
82
|
}
|
package/lib/viewer.js
CHANGED
|
@@ -25,7 +25,7 @@ function resolveTitle(reportTitle) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function resolveDefaultSizes(defaultSizes, compressionAlgorithm) {
|
|
28
|
-
if (['gzip', 'brotli'].includes(defaultSizes)) return compressionAlgorithm;
|
|
28
|
+
if (['gzip', 'brotli', 'zstd'].includes(defaultSizes)) return compressionAlgorithm;
|
|
29
29
|
return defaultSizes;
|
|
30
30
|
}
|
|
31
31
|
module.exports = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-bundle-analyzer",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap",
|
|
5
5
|
"author": "Yury Grunin <grunin.ya@ya.ru>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"html-escaper": "^2.0.2",
|
|
43
43
|
"opener": "^1.5.2",
|
|
44
44
|
"picocolors": "^1.0.0",
|
|
45
|
-
"sirv": "^
|
|
46
|
-
"ws": "^
|
|
45
|
+
"sirv": "^3.0.2",
|
|
46
|
+
"ws": "^8.19.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@babel/core": "7.26.9",
|