webpack-bundle-analyzer 4.2.0 → 4.3.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/CHANGELOG.md +9 -0
- package/lib/viewer.js +22 -17
- package/package.json +3 -3
- package/src/viewer.js +19 -15
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,15 @@ _Note: Gaps between patch versions are faulty, broken or test releases._
|
|
|
14
14
|
|
|
15
15
|
<!-- Add changelog entries for new changes under this section -->
|
|
16
16
|
|
|
17
|
+
## 4.3.0
|
|
18
|
+
|
|
19
|
+
* **Improvement**
|
|
20
|
+
* Replace express with builtin node server, reducing number of dependencies ([#398](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/398) by [@TrySound](https://github.com/TrySound))
|
|
21
|
+
* Move `filesize` to dev dependencies, reducing number of dependencies ([#401](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/401) by [@realityking](https://github.com/realityking))
|
|
22
|
+
|
|
23
|
+
* **Internal**
|
|
24
|
+
* Replace Travis with GitHub actions ([#402](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/402) by [@valscion](https://github.com/valscion))
|
|
25
|
+
|
|
17
26
|
## 4.2.0
|
|
18
27
|
|
|
19
28
|
* **Improvement**
|
package/lib/viewer.js
CHANGED
|
@@ -8,9 +8,9 @@ const http = require('http');
|
|
|
8
8
|
|
|
9
9
|
const WebSocket = require('ws');
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const sirv = require('sirv');
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const _ = require('lodash');
|
|
14
14
|
|
|
15
15
|
const {
|
|
16
16
|
bold
|
|
@@ -63,22 +63,27 @@ async function startServer(bundleStats, opts) {
|
|
|
63
63
|
};
|
|
64
64
|
let chartData = getChartData(analyzerOpts, bundleStats, bundleDir);
|
|
65
65
|
if (!chartData) return;
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
const sirvMiddleware = sirv(`${projectRoot}/public`, {
|
|
67
|
+
// disables caching and traverse the file system on every request
|
|
68
|
+
dev: true
|
|
69
|
+
});
|
|
70
|
+
const server = http.createServer((req, res) => {
|
|
71
|
+
if (req.method === 'GET' && req.url === '/') {
|
|
72
|
+
const html = renderViewer({
|
|
73
|
+
mode: 'server',
|
|
74
|
+
title: resolveTitle(reportTitle),
|
|
75
|
+
chartData,
|
|
76
|
+
defaultSizes,
|
|
77
|
+
enableWebSocket: true
|
|
78
|
+
});
|
|
79
|
+
res.writeHead(200, {
|
|
80
|
+
'Content-Type': 'text/html'
|
|
81
|
+
});
|
|
82
|
+
res.end(html);
|
|
83
|
+
} else {
|
|
84
|
+
sirvMiddleware(req, res);
|
|
85
|
+
}
|
|
80
86
|
});
|
|
81
|
-
const server = http.createServer(app);
|
|
82
87
|
await new Promise(resolve => {
|
|
83
88
|
server.listen(port, host, () => {
|
|
84
89
|
resolve();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-bundle-analyzer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.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",
|
|
@@ -37,11 +37,10 @@
|
|
|
37
37
|
"acorn-walk": "^8.0.0",
|
|
38
38
|
"chalk": "^4.1.0",
|
|
39
39
|
"commander": "^6.2.0",
|
|
40
|
-
"express": "^4.17.1",
|
|
41
|
-
"filesize": "^6.1.0",
|
|
42
40
|
"gzip-size": "^6.0.0",
|
|
43
41
|
"lodash": "^4.17.20",
|
|
44
42
|
"opener": "^1.5.2",
|
|
43
|
+
"sirv": "^1.0.7",
|
|
45
44
|
"ws": "^7.3.1"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
@@ -69,6 +68,7 @@
|
|
|
69
68
|
"eslint-config-th0r-react": "2.0.1",
|
|
70
69
|
"eslint-plugin-react": "7.21.5",
|
|
71
70
|
"exports-loader": "1.1.1",
|
|
71
|
+
"filesize": "^6.1.0",
|
|
72
72
|
"globby": "11.0.1",
|
|
73
73
|
"gulp": "4.0.2",
|
|
74
74
|
"gulp-babel": "8.0.0",
|
package/src/viewer.js
CHANGED
|
@@ -3,8 +3,8 @@ const fs = require('fs');
|
|
|
3
3
|
const http = require('http');
|
|
4
4
|
|
|
5
5
|
const WebSocket = require('ws');
|
|
6
|
+
const sirv = require('sirv');
|
|
6
7
|
const _ = require('lodash');
|
|
7
|
-
const express = require('express');
|
|
8
8
|
const {bold} = require('chalk');
|
|
9
9
|
|
|
10
10
|
const Logger = require('./Logger');
|
|
@@ -48,22 +48,26 @@ async function startServer(bundleStats, opts) {
|
|
|
48
48
|
|
|
49
49
|
if (!chartData) return;
|
|
50
50
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
app.get('/', (req, res) => {
|
|
55
|
-
res.writeHead(200, {'Content-Type': 'text/html'});
|
|
56
|
-
const html = renderViewer({
|
|
57
|
-
mode: 'server',
|
|
58
|
-
title: resolveTitle(reportTitle),
|
|
59
|
-
chartData,
|
|
60
|
-
defaultSizes,
|
|
61
|
-
enableWebSocket: true
|
|
62
|
-
});
|
|
63
|
-
return res.end(html);
|
|
51
|
+
const sirvMiddleware = sirv(`${projectRoot}/public`, {
|
|
52
|
+
// disables caching and traverse the file system on every request
|
|
53
|
+
dev: true
|
|
64
54
|
});
|
|
65
55
|
|
|
66
|
-
const server = http.createServer(
|
|
56
|
+
const server = http.createServer((req, res) => {
|
|
57
|
+
if (req.method === 'GET' && req.url === '/') {
|
|
58
|
+
const html = renderViewer({
|
|
59
|
+
mode: 'server',
|
|
60
|
+
title: resolveTitle(reportTitle),
|
|
61
|
+
chartData,
|
|
62
|
+
defaultSizes,
|
|
63
|
+
enableWebSocket: true
|
|
64
|
+
});
|
|
65
|
+
res.writeHead(200, {'Content-Type': 'text/html'});
|
|
66
|
+
res.end(html);
|
|
67
|
+
} else {
|
|
68
|
+
sirvMiddleware(req, res);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
67
71
|
|
|
68
72
|
await new Promise(resolve => {
|
|
69
73
|
server.listen(port, host, () => {
|