webpack-bundle-analyzer 2.11.0 → 2.11.1
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 +5 -0
- package/lib/parseUtils.js +18 -0
- package/package.json +1 -1
- package/src/parseUtils.js +30 -0
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,11 @@ _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
|
+
## 2.11.1
|
|
18
|
+
|
|
19
|
+
* **Improvement**
|
|
20
|
+
* Add support for parsing Webpack 4's chunked modules ([#159](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/159), [@jdelStrother](https://github.com/jdelStrother))
|
|
21
|
+
|
|
17
22
|
## 2.11.0
|
|
18
23
|
|
|
19
24
|
* **Improvement**
|
package/lib/parseUtils.js
CHANGED
|
@@ -55,6 +55,13 @@ function parseBundle(bundlePath) {
|
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
// Additional bundles with webpack 4 are loaded with:
|
|
59
|
+
// (window.webpackJsonp=window.webpackJsonp||[]).push([[chunkId], [<module>, <module>], [[optional_entries]]]);
|
|
60
|
+
if (isWindowPropertyPushExpression(node) && args.length === 1 && isArgumentContainingChunkIdsAndModulesList(args[0])) {
|
|
61
|
+
state.locations = getModulesLocationFromFunctionArgument(args[0].elements[1]);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
58
65
|
// Walking into arguments because some of plugins (e.g. `DedupePlugin`) or some Webpack
|
|
59
66
|
// features (e.g. `umd` library output) can wrap modules list into additional IIFE.
|
|
60
67
|
_.each(args, function (arg) {
|
|
@@ -99,6 +106,13 @@ function isArgumentContainsModulesList(arg) {
|
|
|
99
106
|
return false;
|
|
100
107
|
}
|
|
101
108
|
|
|
109
|
+
function isArgumentContainingChunkIdsAndModulesList(arg) {
|
|
110
|
+
if (arg.type === 'ArrayExpression' && arg.elements.length >= 2 && isArgumentContainsChunkIds(arg.elements[0]) && isArgumentContainsModulesList(arg.elements[1])) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
|
|
102
116
|
function isArgumentArrayConcatContainingChunks(arg) {
|
|
103
117
|
if (arg.type === 'CallExpression' && arg.callee.type === 'MemberExpression' &&
|
|
104
118
|
// Make sure the object called is `Array(<some number>)`
|
|
@@ -116,6 +130,10 @@ function isArgumentArrayConcatContainingChunks(arg) {
|
|
|
116
130
|
return false;
|
|
117
131
|
}
|
|
118
132
|
|
|
133
|
+
function isWindowPropertyPushExpression(node) {
|
|
134
|
+
return node.callee.type === 'MemberExpression' && node.callee.property.name === 'push' && node.callee.object.type === 'AssignmentExpression' && node.callee.object.left.object.name === 'window';
|
|
135
|
+
}
|
|
136
|
+
|
|
119
137
|
function isModuleWrapper(node) {
|
|
120
138
|
return (
|
|
121
139
|
// It's an anonymous function expression that wraps module
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-bundle-analyzer",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.1",
|
|
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",
|
package/src/parseUtils.js
CHANGED
|
@@ -71,6 +71,17 @@ function parseBundle(bundlePath) {
|
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
// Additional bundles with webpack 4 are loaded with:
|
|
75
|
+
// (window.webpackJsonp=window.webpackJsonp||[]).push([[chunkId], [<module>, <module>], [[optional_entries]]]);
|
|
76
|
+
if (
|
|
77
|
+
isWindowPropertyPushExpression(node) &&
|
|
78
|
+
args.length === 1 &&
|
|
79
|
+
isArgumentContainingChunkIdsAndModulesList(args[0])
|
|
80
|
+
) {
|
|
81
|
+
state.locations = getModulesLocationFromFunctionArgument(args[0].elements[1]);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
74
85
|
// Walking into arguments because some of plugins (e.g. `DedupePlugin`) or some Webpack
|
|
75
86
|
// features (e.g. `umd` library output) can wrap modules list into additional IIFE.
|
|
76
87
|
_.each(args, arg => c(arg, state));
|
|
@@ -115,6 +126,18 @@ function isArgumentContainsModulesList(arg) {
|
|
|
115
126
|
return false;
|
|
116
127
|
}
|
|
117
128
|
|
|
129
|
+
function isArgumentContainingChunkIdsAndModulesList(arg) {
|
|
130
|
+
if (
|
|
131
|
+
arg.type === 'ArrayExpression' &&
|
|
132
|
+
arg.elements.length >= 2 &&
|
|
133
|
+
isArgumentContainsChunkIds(arg.elements[0]) &&
|
|
134
|
+
isArgumentContainsModulesList(arg.elements[1])
|
|
135
|
+
) {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
|
|
118
141
|
function isArgumentArrayConcatContainingChunks(arg) {
|
|
119
142
|
if (
|
|
120
143
|
arg.type === 'CallExpression' &&
|
|
@@ -141,6 +164,13 @@ function isArgumentArrayConcatContainingChunks(arg) {
|
|
|
141
164
|
return false;
|
|
142
165
|
}
|
|
143
166
|
|
|
167
|
+
function isWindowPropertyPushExpression(node) {
|
|
168
|
+
return node.callee.type === 'MemberExpression' &&
|
|
169
|
+
node.callee.property.name === 'push' &&
|
|
170
|
+
node.callee.object.type === 'AssignmentExpression' &&
|
|
171
|
+
node.callee.object.left.object.name === 'window';
|
|
172
|
+
}
|
|
173
|
+
|
|
144
174
|
function isModuleWrapper(node) {
|
|
145
175
|
return (
|
|
146
176
|
// It's an anonymous function expression that wraps module
|