webpack-bundle-analyzer 3.7.0 → 3.8.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 +11 -0
- package/lib/parseUtils.js +32 -3
- package/package.json +1 -1
- package/src/parseUtils.js +37 -8
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,17 @@ _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.8.0
|
|
18
|
+
|
|
19
|
+
* **Improvement**
|
|
20
|
+
* Added support for exports.modules when webpack target = node ([#345](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/345) by [@Spikef](https://github.com/Spikef))
|
|
21
|
+
|
|
22
|
+
* **New Feature**
|
|
23
|
+
* Support [WebWorkerChunkTemplatePlugin](https://github.com/webpack/webpack/blob/c9d4ff7b054fc581c96ce0e53432d44f9dd8ca72/lib/webworker/WebWorkerChunkTemplatePlugin.js) ([#353](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/353) by [@Gongreg](https://github.com/Gongreg))
|
|
24
|
+
|
|
25
|
+
* **Bug Fix**
|
|
26
|
+
* Support any custom `globalObject` option in Webpack Config. ([#352](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/352) by [@Gongreg](https://github.com/Gongreg))
|
|
27
|
+
|
|
17
28
|
## 3.7.0
|
|
18
29
|
|
|
19
30
|
* **New Feature**
|
package/lib/parseUtils.js
CHANGED
|
@@ -25,6 +25,20 @@ function parseBundle(bundlePath) {
|
|
|
25
25
|
locations: null
|
|
26
26
|
};
|
|
27
27
|
walk.recursive(ast, walkState, {
|
|
28
|
+
AssignmentExpression(node, state) {
|
|
29
|
+
if (state.locations) return; // Modules are stored in exports.modules:
|
|
30
|
+
// exports.modules = {};
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
left,
|
|
34
|
+
right
|
|
35
|
+
} = node;
|
|
36
|
+
|
|
37
|
+
if (left && left.object && left.object.name === 'exports' && left.property && left.property.name === 'modules' && isModulesHash(right)) {
|
|
38
|
+
state.locations = getModulesLocations(right);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
|
|
28
42
|
CallExpression(node, state, c) {
|
|
29
43
|
if (state.locations) return;
|
|
30
44
|
const args = node.arguments; // Main chunk with webpack loader.
|
|
@@ -50,6 +64,14 @@ function parseBundle(bundlePath) {
|
|
|
50
64
|
if (isAsyncChunkPushExpression(node)) {
|
|
51
65
|
state.locations = getModulesLocations(args[0].elements[1]);
|
|
52
66
|
return;
|
|
67
|
+
} // Webpack v4 WebWorkerChunkTemplatePlugin
|
|
68
|
+
// globalObject.chunkCallbackName([<chunks>],<modules>, ...);
|
|
69
|
+
// Both globalObject and chunkCallbackName can be changed through the config, so we can't check them.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if (isAsyncWebWorkerChunkExpression(node)) {
|
|
73
|
+
state.locations = getModulesLocations(args[1]);
|
|
74
|
+
return;
|
|
53
75
|
} // Walking into arguments because some of plugins (e.g. `DedupePlugin`) or some Webpack
|
|
54
76
|
// features (e.g. `umd` library output) can wrap modules list into additional IIFE.
|
|
55
77
|
|
|
@@ -129,15 +151,22 @@ function isAsyncChunkPushExpression(node) {
|
|
|
129
151
|
callee,
|
|
130
152
|
arguments: args
|
|
131
153
|
} = node;
|
|
132
|
-
return callee.type === 'MemberExpression' && callee.property.name === 'push' && callee.object.type === 'AssignmentExpression' &&
|
|
133
|
-
callee.object.left.object.name === 'self' || // Webpack 4 uses `this` instead of `window`
|
|
134
|
-
callee.object.left.object.type === 'ThisExpression') && args.length === 1 && args[0].type === 'ArrayExpression' && mayBeAsyncChunkArguments(args[0].elements) && isModulesList(args[0].elements[1]);
|
|
154
|
+
return callee.type === 'MemberExpression' && callee.property.name === 'push' && callee.object.type === 'AssignmentExpression' && args.length === 1 && args[0].type === 'ArrayExpression' && mayBeAsyncChunkArguments(args[0].elements) && isModulesList(args[0].elements[1]);
|
|
135
155
|
}
|
|
136
156
|
|
|
137
157
|
function mayBeAsyncChunkArguments(args) {
|
|
138
158
|
return args.length >= 2 && isChunkIds(args[0]);
|
|
139
159
|
}
|
|
140
160
|
|
|
161
|
+
function isAsyncWebWorkerChunkExpression(node) {
|
|
162
|
+
const {
|
|
163
|
+
callee,
|
|
164
|
+
type,
|
|
165
|
+
arguments: args
|
|
166
|
+
} = node;
|
|
167
|
+
return type === 'CallExpression' && callee.type === 'MemberExpression' && args.length === 2 && isChunkIds(args[0]) && isModulesList(args[1]);
|
|
168
|
+
}
|
|
169
|
+
|
|
141
170
|
function getModulesLocations(node) {
|
|
142
171
|
if (node.type === 'ObjectExpression') {
|
|
143
172
|
// Modules hash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpack-bundle-analyzer",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.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",
|
package/src/parseUtils.js
CHANGED
|
@@ -25,6 +25,22 @@ function parseBundle(bundlePath) {
|
|
|
25
25
|
ast,
|
|
26
26
|
walkState,
|
|
27
27
|
{
|
|
28
|
+
AssignmentExpression(node, state) {
|
|
29
|
+
if (state.locations) return;
|
|
30
|
+
|
|
31
|
+
// Modules are stored in exports.modules:
|
|
32
|
+
// exports.modules = {};
|
|
33
|
+
const {left, right} = node;
|
|
34
|
+
|
|
35
|
+
if (
|
|
36
|
+
left &&
|
|
37
|
+
left.object && left.object.name === 'exports' &&
|
|
38
|
+
left.property && left.property.name === 'modules' &&
|
|
39
|
+
isModulesHash(right)
|
|
40
|
+
) {
|
|
41
|
+
state.locations = getModulesLocations(right);
|
|
42
|
+
}
|
|
43
|
+
},
|
|
28
44
|
CallExpression(node, state, c) {
|
|
29
45
|
if (state.locations) return;
|
|
30
46
|
|
|
@@ -63,6 +79,15 @@ function parseBundle(bundlePath) {
|
|
|
63
79
|
return;
|
|
64
80
|
}
|
|
65
81
|
|
|
82
|
+
// Webpack v4 WebWorkerChunkTemplatePlugin
|
|
83
|
+
// globalObject.chunkCallbackName([<chunks>],<modules>, ...);
|
|
84
|
+
// Both globalObject and chunkCallbackName can be changed through the config, so we can't check them.
|
|
85
|
+
if (isAsyncWebWorkerChunkExpression(node)) {
|
|
86
|
+
state.locations = getModulesLocations(args[1]);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
66
91
|
// Walking into arguments because some of plugins (e.g. `DedupePlugin`) or some Webpack
|
|
67
92
|
// features (e.g. `umd` library output) can wrap modules list into additional IIFE.
|
|
68
93
|
_.each(args, arg => c(arg, state));
|
|
@@ -182,14 +207,6 @@ function isAsyncChunkPushExpression(node) {
|
|
|
182
207
|
callee.type === 'MemberExpression' &&
|
|
183
208
|
callee.property.name === 'push' &&
|
|
184
209
|
callee.object.type === 'AssignmentExpression' &&
|
|
185
|
-
callee.object.left.object &&
|
|
186
|
-
(
|
|
187
|
-
callee.object.left.object.name === 'window' ||
|
|
188
|
-
// `self` is a common output.globalObject value used to support both workers and browsers
|
|
189
|
-
callee.object.left.object.name === 'self' ||
|
|
190
|
-
// Webpack 4 uses `this` instead of `window`
|
|
191
|
-
callee.object.left.object.type === 'ThisExpression'
|
|
192
|
-
) &&
|
|
193
210
|
args.length === 1 &&
|
|
194
211
|
args[0].type === 'ArrayExpression' &&
|
|
195
212
|
mayBeAsyncChunkArguments(args[0].elements) &&
|
|
@@ -204,6 +221,18 @@ function mayBeAsyncChunkArguments(args) {
|
|
|
204
221
|
);
|
|
205
222
|
}
|
|
206
223
|
|
|
224
|
+
function isAsyncWebWorkerChunkExpression(node) {
|
|
225
|
+
const {callee, type, arguments: args} = node;
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
type === 'CallExpression' &&
|
|
229
|
+
callee.type === 'MemberExpression' &&
|
|
230
|
+
args.length === 2 &&
|
|
231
|
+
isChunkIds(args[0]) &&
|
|
232
|
+
isModulesList(args[1])
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
207
236
|
function getModulesLocations(node) {
|
|
208
237
|
if (node.type === 'ObjectExpression') {
|
|
209
238
|
// Modules hash
|