webpack-bundle-analyzer 3.1.0 → 3.3.2
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 +34 -7
- package/README.md +12 -12
- package/lib/analyzer.js +5 -3
- package/lib/bin/analyzer.js +4 -2
- package/lib/tree/utils.js +1 -1
- package/lib/utils.js +1 -1
- package/lib/viewer.js +26 -7
- package/package.json +30 -29
- package/public/viewer.js +5 -6
- package/public/viewer.js.map +1 -1
- package/src/analyzer.js +5 -3
- package/src/bin/analyzer.js +4 -2
- package/src/tree/utils.js +1 -1
- package/src/utils.js +1 -1
- package/src/viewer.js +25 -7
- package/views/script.ejs +1 -1
- package/views/viewer.ejs +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -14,21 +14,48 @@ _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
|
+
## 3.3.2
|
|
18
|
+
|
|
19
|
+
* **Bug Fix**
|
|
20
|
+
* Fix regression with escaping internal assets ([#264](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/264), fixes [#263](https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/263))
|
|
21
|
+
|
|
22
|
+
## 3.3.1
|
|
23
|
+
|
|
24
|
+
* **Improvements**
|
|
25
|
+
* Use relative links for serving internal assets ([#261](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/261), fixes [#254](https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/254))
|
|
26
|
+
* Properly escape embedded JS/JSON ([#262](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/262))
|
|
27
|
+
|
|
28
|
+
* **Bug Fix**
|
|
29
|
+
* Fix showing help message on `-h` flag ([#260](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/260), fixes [#239](https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/239))
|
|
30
|
+
|
|
31
|
+
## 3.3.0
|
|
32
|
+
|
|
33
|
+
* **New Feature**
|
|
34
|
+
* Show/hide chunks using context menu ([#246](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/246), [@bregenspan](https://github.com/bregenspan))
|
|
35
|
+
|
|
36
|
+
* **Internal**
|
|
37
|
+
* Updated dev dependencies
|
|
38
|
+
|
|
39
|
+
## 3.2.0
|
|
40
|
+
|
|
41
|
+
* **Improvements**
|
|
42
|
+
* Add support for .mjs output files ([#252](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/252), [@jlopezxs](https://github.com/jlopezxs))
|
|
43
|
+
|
|
17
44
|
## 3.1.0
|
|
18
45
|
|
|
19
|
-
* **Bug Fix**
|
|
20
|
-
|
|
21
|
-
|
|
46
|
+
* **Bug Fix**
|
|
47
|
+
* Properly determine the size of the modules containing special characters ([#223](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/223), [@hulkish](https://github.com/hulkish))
|
|
48
|
+
* Update acorn to v6 ([#248](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/248), [@realityking](https://github.com/realityking))
|
|
22
49
|
|
|
23
50
|
## 3.0.4
|
|
24
51
|
|
|
25
|
-
* **Bug Fix**
|
|
26
|
-
|
|
52
|
+
* **Bug Fix**
|
|
53
|
+
* Make webpack's done hook wait until analyzer writes report or stat file ([#247](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/247), [@mareolan](https://github.com/mareolan))
|
|
27
54
|
|
|
28
55
|
## 3.0.3
|
|
29
56
|
|
|
30
|
-
* **Bug Fix**
|
|
31
|
-
|
|
57
|
+
* **Bug Fix**
|
|
58
|
+
* Disable viewer websocket connection when report is generated in `static` mode ([#215](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/215), [@sebastianhaeni](https://github.com/sebastianhaeni))
|
|
32
59
|
|
|
33
60
|
## 3.0.2
|
|
34
61
|
|
package/README.md
CHANGED
|
@@ -148,23 +148,23 @@ as Uglify, then this value will reflect the minified size of your code.
|
|
|
148
148
|
|
|
149
149
|
This is the size of running the parsed bundles/modules through gzip compression.
|
|
150
150
|
|
|
151
|
-
<h2 align="center">
|
|
151
|
+
<h2 align="center">Selecting Which Chunks to Display</h2>
|
|
152
152
|
|
|
153
|
-
|
|
153
|
+
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.
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
The way `ModuleConcatenationPlugin` works is that it merges multiple modules into a single one, and so that resulting module doesn't have edges anymore.
|
|
157
|
-
`Webpack 3` didn't provide any information about concatenated modules, but `Webpack 4` started including it into a `stats` files and `webpack-bundle-analyzer 2.11.0` learned to show it.
|
|
155
|
+
### Sidebar
|
|
158
156
|
|
|
159
|
-
|
|
157
|
+
The Sidebar Menu can be opened by clicking the `>` button at the top left of the report. You can select or deselect chunks to display under the "Show chunks" heading there.
|
|
160
158
|
|
|
161
|
-
|
|
162
|
-
```
|
|
163
|
-
ng build --stats-json --build-optimizer=false --vendor-chunk=true
|
|
164
|
-
```
|
|
165
|
-
The resulting stats.json can be found at `dist/stats.json`
|
|
159
|
+
### Chunk Context Menu
|
|
166
160
|
|
|
167
|
-
|
|
161
|
+
The Chunk Context Menu can be opened by right-clicking or `Ctrl`-clicking on a specific chunk in the report. It provides the following options:
|
|
162
|
+
|
|
163
|
+
* **Hide chunk:** Hides the selected chunk
|
|
164
|
+
* **Hide all other chunks:** Hides all chunks besides the selected one
|
|
165
|
+
* **Show all chunks:** Un-hides any hidden chunks, returning the report to its initial, unfiltered view
|
|
166
|
+
|
|
167
|
+
<h2 align="center">Troubleshooting</h2>
|
|
168
168
|
|
|
169
169
|
### I don't see `gzip` or `parsed` sizes, it only shows `stat` size
|
|
170
170
|
|
package/lib/analyzer.js
CHANGED
|
@@ -20,7 +20,8 @@ const {
|
|
|
20
20
|
createAssetsFilter
|
|
21
21
|
} = require('./utils');
|
|
22
22
|
|
|
23
|
-
const FILENAME_QUERY_REGEXP =
|
|
23
|
+
const FILENAME_QUERY_REGEXP = /\?[\0-\t\x0B\f\x0E-\u2027\u202A-\u{10FFFF}]*$/u;
|
|
24
|
+
const FILENAME_EXTENSIONS = /\.(js|mjs)$/iu;
|
|
24
25
|
module.exports = {
|
|
25
26
|
getViewerData,
|
|
26
27
|
readStatsFromFile
|
|
@@ -35,14 +36,14 @@ function getViewerData(bundleStats, bundleDir, opts) {
|
|
|
35
36
|
|
|
36
37
|
if (_.isEmpty(bundleStats.assets) && !_.isEmpty(bundleStats.children)) {
|
|
37
38
|
bundleStats = bundleStats.children[0];
|
|
38
|
-
} // Picking only `*.js` assets from bundle that has non-empty `chunks` array
|
|
39
|
+
} // Picking only `*.js or *.mjs` assets from bundle that has non-empty `chunks` array
|
|
39
40
|
|
|
40
41
|
|
|
41
42
|
bundleStats.assets = _.filter(bundleStats.assets, asset => {
|
|
42
43
|
// Removing query part from filename (yes, somebody uses it for some reason and Webpack supports it)
|
|
43
44
|
// See #22
|
|
44
45
|
asset.name = asset.name.replace(FILENAME_QUERY_REGEXP, '');
|
|
45
|
-
return
|
|
46
|
+
return FILENAME_EXTENSIONS.test(asset.name) && !_.isEmpty(asset.chunks) && isAssetIncluded(asset.name);
|
|
46
47
|
}); // Trying to parse bundle assets and get real module sizes if `bundleDir` is provided
|
|
47
48
|
|
|
48
49
|
let bundlesSources = null;
|
|
@@ -98,6 +99,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
|
|
|
98
99
|
return _.transform(assets, (result, asset, filename) => {
|
|
99
100
|
result.push({
|
|
100
101
|
label: filename,
|
|
102
|
+
isAsset: true,
|
|
101
103
|
// Not using `asset.size` here provided by Webpack because it can be very confusing when `UglifyJsPlugin` is used.
|
|
102
104
|
// In this case all module sizes from stats file will represent unminified module sizes, but `asset.size` will
|
|
103
105
|
// be the size of minified bundle.
|
package/lib/bin/analyzer.js
CHANGED
|
@@ -28,7 +28,9 @@ const program = commander.version(require('../../package.json').version).usage(`
|
|
|
28
28
|
bundleStatsFile Path to Webpack Stats JSON file.
|
|
29
29
|
bundleDir Directory containing all generated bundles.
|
|
30
30
|
You should provided it if you want analyzer to show you the real parsed module sizes.
|
|
31
|
-
By default a directory of stats file is used.`).option('-m, --mode <mode>', 'Analyzer mode. Should be `server` or `static`.' + br('In `server` mode analyzer will start HTTP server to show bundle report.') + br('In `static` mode single HTML file with bundle report will be generated.'), 'server').option(
|
|
31
|
+
By default a directory of stats file is used.`).option('-m, --mode <mode>', 'Analyzer mode. Should be `server` or `static`.' + br('In `server` mode analyzer will start HTTP server to show bundle report.') + br('In `static` mode single HTML file with bundle report will be generated.'), 'server').option( // Had to make `host` parameter optional in order to let `-h` flag output help message
|
|
32
|
+
// Fixes https://github.com/webpack-contrib/webpack-bundle-analyzer/issues/239
|
|
33
|
+
'-h, --host [host]', 'Host that will be used in `server` mode to start HTTP server.', '127.0.0.1').option('-p, --port <n>', 'Port that will be used in `server` mode to start HTTP server.', Number, 8888).option('-r, --report <file>', 'Path to bundle report file that will be generated in `static` mode.', 'report.html').option('-s, --default-sizes <type>', 'Module sizes to show in treemap by default.' + br(`Possible values: ${[...SIZES].join(', ')}`), 'parsed').option('-O, --no-open', "Don't open report in default browser automatically.").option('-e, --exclude <regexp>', 'Assets that should be excluded from the report.' + br('Can be specified multiple times.'), array()).option('-l, --log-level <level>', 'Log level.' + br(`Possible values: ${[...Logger.levels].join(', ')}`), Logger.defaultLevel).parse(process.argv);
|
|
32
34
|
let {
|
|
33
35
|
mode,
|
|
34
36
|
host,
|
|
@@ -80,7 +82,7 @@ if (mode === 'server') {
|
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
function showHelp(error) {
|
|
83
|
-
if (error) console.log(`\n ${magenta(error)}`);
|
|
85
|
+
if (error) console.log(`\n ${magenta(error)}\n`);
|
|
84
86
|
program.outputHelp();
|
|
85
87
|
process.exit(1);
|
|
86
88
|
}
|
package/lib/tree/utils.js
CHANGED
|
@@ -9,7 +9,7 @@ var _lodash = _interopRequireDefault(require("lodash"));
|
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
|
-
const MULTI_MODULE_REGEXP = /^multi
|
|
12
|
+
const MULTI_MODULE_REGEXP = /^multi /u;
|
|
13
13
|
|
|
14
14
|
function getModulePathParts(moduleData) {
|
|
15
15
|
if (MULTI_MODULE_REGEXP.test(moduleData.identifier)) {
|
package/lib/utils.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.createAssetsFilter = createAssetsFilter;
|
|
|
11
11
|
function createAssetsFilter(excludePatterns) {
|
|
12
12
|
const excludeFunctions = _(excludePatterns).castArray().compact().map(pattern => {
|
|
13
13
|
if (typeof pattern === 'string') {
|
|
14
|
-
pattern = new RegExp(pattern);
|
|
14
|
+
pattern = new RegExp(pattern, 'u');
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
if (_.isRegExp(pattern)) {
|
package/lib/viewer.js
CHANGED
|
@@ -31,6 +31,7 @@ const Logger = require('./Logger');
|
|
|
31
31
|
const analyzer = require('./analyzer');
|
|
32
32
|
|
|
33
33
|
const projectRoot = path.resolve(__dirname, '..');
|
|
34
|
+
const assetsRoot = path.join(projectRoot, 'public');
|
|
34
35
|
module.exports = {
|
|
35
36
|
startServer,
|
|
36
37
|
generateReport,
|
|
@@ -71,11 +72,13 @@ function _startServer() {
|
|
|
71
72
|
mode: 'server',
|
|
72
73
|
|
|
73
74
|
get chartData() {
|
|
74
|
-
return
|
|
75
|
+
return chartData;
|
|
75
76
|
},
|
|
76
77
|
|
|
77
|
-
defaultSizes
|
|
78
|
-
enableWebSocket: true
|
|
78
|
+
defaultSizes,
|
|
79
|
+
enableWebSocket: true,
|
|
80
|
+
// Helpers
|
|
81
|
+
escapeJson
|
|
79
82
|
});
|
|
80
83
|
});
|
|
81
84
|
const server = http.createServer(app);
|
|
@@ -145,10 +148,12 @@ function _generateReport() {
|
|
|
145
148
|
yield new Promise((resolve, reject) => {
|
|
146
149
|
ejs.renderFile(`${projectRoot}/views/viewer.ejs`, {
|
|
147
150
|
mode: 'static',
|
|
148
|
-
chartData
|
|
151
|
+
chartData,
|
|
152
|
+
defaultSizes,
|
|
153
|
+
enableWebSocket: false,
|
|
154
|
+
// Helpers
|
|
149
155
|
assetContent: getAssetContent,
|
|
150
|
-
|
|
151
|
-
enableWebSocket: false
|
|
156
|
+
escapeJson
|
|
152
157
|
}, (err, reportHtml) => {
|
|
153
158
|
try {
|
|
154
159
|
if (err) {
|
|
@@ -177,7 +182,21 @@ function _generateReport() {
|
|
|
177
182
|
}
|
|
178
183
|
|
|
179
184
|
function getAssetContent(filename) {
|
|
180
|
-
|
|
185
|
+
const assetPath = path.join(assetsRoot, filename);
|
|
186
|
+
|
|
187
|
+
if (!assetPath.startsWith(assetsRoot)) {
|
|
188
|
+
throw new Error(`"${filename}" is outside of the assets root`);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return fs.readFileSync(assetPath, 'utf8');
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Escapes `<` characters in JSON to safely use it in `<script>` tag.
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
function escapeJson(json) {
|
|
199
|
+
return JSON.stringify(json).replace(/</gu, '\\u003c');
|
|
181
200
|
}
|
|
182
201
|
|
|
183
202
|
function getChartData(analyzerOpts, ...args) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-bundle-analyzer",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.2",
|
|
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",
|
|
@@ -48,45 +48,46 @@
|
|
|
48
48
|
"ws": "^6.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@babel/core": "7.
|
|
52
|
-
"@babel/plugin-proposal-class-properties": "7.
|
|
53
|
-
"@babel/plugin-proposal-decorators": "7.
|
|
54
|
-
"@babel/plugin-transform-runtime": "7.
|
|
55
|
-
"@babel/polyfill": "7.
|
|
56
|
-
"@babel/preset-env": "7.
|
|
51
|
+
"@babel/core": "7.4.3",
|
|
52
|
+
"@babel/plugin-proposal-class-properties": "7.4.0",
|
|
53
|
+
"@babel/plugin-proposal-decorators": "7.4.0",
|
|
54
|
+
"@babel/plugin-transform-runtime": "7.4.3",
|
|
55
|
+
"@babel/polyfill": "7.4.3",
|
|
56
|
+
"@babel/preset-env": "7.4.3",
|
|
57
57
|
"@babel/preset-react": "7.0.0",
|
|
58
|
-
"@babel/register": "7.
|
|
59
|
-
"@babel/runtime": "7.
|
|
60
|
-
"babel-eslint": "
|
|
61
|
-
"babel-loader": "8.0.
|
|
58
|
+
"@babel/register": "7.4.0",
|
|
59
|
+
"@babel/runtime": "7.4.3",
|
|
60
|
+
"babel-eslint": "10.0.1",
|
|
61
|
+
"babel-loader": "8.0.5",
|
|
62
62
|
"babel-plugin-lodash": "3.3.4",
|
|
63
|
-
"chai": "4.
|
|
63
|
+
"chai": "4.2.0",
|
|
64
64
|
"chai-subset": "1.6.0",
|
|
65
65
|
"classnames": "2.2.6",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"eslint
|
|
71
|
-
"eslint-config-th0r
|
|
72
|
-
"eslint-
|
|
66
|
+
"core-js": "2.6.5",
|
|
67
|
+
"css-loader": "2.1.1",
|
|
68
|
+
"cssnano": "4.1.10",
|
|
69
|
+
"del": "4.1.0",
|
|
70
|
+
"eslint": "5.16.0",
|
|
71
|
+
"eslint-config-th0r": "2.0.0",
|
|
72
|
+
"eslint-config-th0r-react": "2.0.0",
|
|
73
|
+
"eslint-plugin-react": "7.12.4",
|
|
73
74
|
"exports-loader": "0.7.0",
|
|
74
75
|
"gulp": "4.0.0",
|
|
75
76
|
"gulp-babel": "8.0.0",
|
|
76
|
-
"mobx": "5.
|
|
77
|
+
"mobx": "5.9.4",
|
|
77
78
|
"mobx-preact": "3.0.0",
|
|
78
|
-
"mocha": "
|
|
79
|
+
"mocha": "6.1.2",
|
|
79
80
|
"nightmare": "3.0.1",
|
|
80
|
-
"postcss-icss-values": "2.0.
|
|
81
|
+
"postcss-icss-values": "2.0.2",
|
|
81
82
|
"postcss-loader": "3.0.0",
|
|
82
|
-
"preact": "8.
|
|
83
|
+
"preact": "8.4.2",
|
|
83
84
|
"stream-combiner2": "1.1.1",
|
|
84
|
-
"style-loader": "0.23.
|
|
85
|
-
"
|
|
86
|
-
"url-loader": "1.1.
|
|
87
|
-
"webpack": "4.
|
|
88
|
-
"webpack-cli": "3.
|
|
89
|
-
"webpack-dev-server": "3.1
|
|
85
|
+
"style-loader": "0.23.1",
|
|
86
|
+
"terser-webpack-plugin": "1.2.3",
|
|
87
|
+
"url-loader": "1.1.2",
|
|
88
|
+
"webpack": "4.29.6",
|
|
89
|
+
"webpack-cli": "3.3.0",
|
|
90
|
+
"webpack-dev-server": "3.3.1"
|
|
90
91
|
},
|
|
91
92
|
"keywords": [
|
|
92
93
|
"webpack",
|