webpack-bundle-analyzer 2.9.2 → 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 +25 -0
- package/README.md +4 -2
- package/lib/BundleAnalyzerPlugin.js +35 -12
- package/lib/Logger.js +4 -3
- package/lib/analyzer.js +4 -31
- package/lib/bin/analyzer.js +11 -4
- package/lib/parseUtils.js +18 -0
- package/lib/tree/BaseFolder.js +139 -0
- package/lib/tree/ConcatenatedModule.js +122 -0
- package/lib/tree/ContentFolder.js +69 -0
- package/lib/tree/ContentModule.js +67 -0
- package/lib/tree/Folder.js +114 -0
- package/lib/tree/Module.js +101 -0
- package/lib/tree/Node.js +38 -0
- package/lib/tree/utils.js +34 -0
- package/lib/viewer.js +1 -0
- package/package.json +32 -32
- package/public/viewer.js +1 -1
- package/public/viewer.js.map +1 -1
- package/src/BundleAnalyzerPlugin.js +26 -12
- package/src/Logger.js +4 -1
- package/src/analyzer.js +3 -28
- package/src/bin/analyzer.js +20 -13
- package/src/parseUtils.js +30 -0
- package/src/tree/BaseFolder.js +95 -0
- package/src/tree/ConcatenatedModule.js +68 -0
- package/src/tree/ContentFolder.js +35 -0
- package/src/tree/ContentModule.js +33 -0
- package/src/tree/Folder.js +64 -0
- package/src/tree/Module.js +63 -0
- package/src/tree/Node.js +20 -0
- package/src/tree/utils.js +21 -0
- package/src/viewer.js +1 -0
- package/lib/tree.js +0 -304
- package/src/tree.js +0 -248
package/lib/tree.js
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
4
|
-
|
|
5
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
6
|
-
|
|
7
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
8
|
-
|
|
9
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
10
|
-
|
|
11
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
|
-
|
|
13
|
-
var _ = require('lodash');
|
|
14
|
-
var filesize = require('filesize');
|
|
15
|
-
var gzipSize = require('gzip-size');
|
|
16
|
-
|
|
17
|
-
var Node = function () {
|
|
18
|
-
function Node(name, parent) {
|
|
19
|
-
_classCallCheck(this, Node);
|
|
20
|
-
|
|
21
|
-
this.name = name;
|
|
22
|
-
this.parent = parent;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
_createClass(Node, [{
|
|
26
|
-
key: 'toString',
|
|
27
|
-
value: function toString(indent) {
|
|
28
|
-
indent = indent || '|';
|
|
29
|
-
|
|
30
|
-
return `${indent} ${this.name}`;
|
|
31
|
-
}
|
|
32
|
-
}, {
|
|
33
|
-
key: 'path',
|
|
34
|
-
get: function get() {
|
|
35
|
-
var path = [];
|
|
36
|
-
var node = this;
|
|
37
|
-
|
|
38
|
-
while (node) {
|
|
39
|
-
path.push(node.name);
|
|
40
|
-
node = node.parent;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return path.reverse().join('/');
|
|
44
|
-
}
|
|
45
|
-
}]);
|
|
46
|
-
|
|
47
|
-
return Node;
|
|
48
|
-
}();
|
|
49
|
-
|
|
50
|
-
var Module = function (_Node) {
|
|
51
|
-
_inherits(Module, _Node);
|
|
52
|
-
|
|
53
|
-
function Module(name, data, parent) {
|
|
54
|
-
_classCallCheck(this, Module);
|
|
55
|
-
|
|
56
|
-
var _this = _possibleConstructorReturn(this, (Module.__proto__ || Object.getPrototypeOf(Module)).call(this, name, parent));
|
|
57
|
-
|
|
58
|
-
_this.data = data;
|
|
59
|
-
return _this;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
_createClass(Module, [{
|
|
63
|
-
key: 'mergeData',
|
|
64
|
-
value: function mergeData(data) {
|
|
65
|
-
if (data.size) {
|
|
66
|
-
this.size += data.size;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (data.parsedSrc) {
|
|
70
|
-
this.src = (this.src || '') + data.parsedSrc;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: 'toString',
|
|
75
|
-
value: function toString(indent) {
|
|
76
|
-
return `${_get(Module.prototype.__proto__ || Object.getPrototypeOf(Module.prototype), 'toString', this).call(this, indent)} [${this.data.id}] (${filesize(this.size)})`;
|
|
77
|
-
}
|
|
78
|
-
}, {
|
|
79
|
-
key: 'toChartData',
|
|
80
|
-
value: function toChartData() {
|
|
81
|
-
return {
|
|
82
|
-
id: this.data.id,
|
|
83
|
-
label: this.name,
|
|
84
|
-
path: this.path,
|
|
85
|
-
statSize: this.size,
|
|
86
|
-
parsedSize: this.parsedSize,
|
|
87
|
-
gzipSize: this.gzipSize
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
}, {
|
|
91
|
-
key: 'src',
|
|
92
|
-
get: function get() {
|
|
93
|
-
return this.data.parsedSrc;
|
|
94
|
-
},
|
|
95
|
-
set: function set(value) {
|
|
96
|
-
this.data.parsedSrc = value;
|
|
97
|
-
delete this._gzipSize;
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
key: 'size',
|
|
101
|
-
get: function get() {
|
|
102
|
-
return this.data.size;
|
|
103
|
-
},
|
|
104
|
-
set: function set(value) {
|
|
105
|
-
this.data.size = value;
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
key: 'parsedSize',
|
|
109
|
-
get: function get() {
|
|
110
|
-
return this.src ? this.src.length : undefined;
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
key: 'gzipSize',
|
|
114
|
-
get: function get() {
|
|
115
|
-
if (!_.has(this, '_gzipSize')) {
|
|
116
|
-
this._gzipSize = this.src ? gzipSize.sync(this.src) : undefined;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return this._gzipSize;
|
|
120
|
-
}
|
|
121
|
-
}]);
|
|
122
|
-
|
|
123
|
-
return Module;
|
|
124
|
-
}(Node);
|
|
125
|
-
|
|
126
|
-
var Folder = function (_Node2) {
|
|
127
|
-
_inherits(Folder, _Node2);
|
|
128
|
-
|
|
129
|
-
function Folder(name, parent) {
|
|
130
|
-
_classCallCheck(this, Folder);
|
|
131
|
-
|
|
132
|
-
var _this2 = _possibleConstructorReturn(this, (Folder.__proto__ || Object.getPrototypeOf(Folder)).call(this, name, parent));
|
|
133
|
-
|
|
134
|
-
_this2.children = Object.create(null);
|
|
135
|
-
return _this2;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
_createClass(Folder, [{
|
|
139
|
-
key: 'getChild',
|
|
140
|
-
value: function getChild(name) {
|
|
141
|
-
return this.children[name];
|
|
142
|
-
}
|
|
143
|
-
}, {
|
|
144
|
-
key: 'addFolder',
|
|
145
|
-
value: function addFolder(name) {
|
|
146
|
-
var folder = new Folder(name, this);
|
|
147
|
-
|
|
148
|
-
this.children[name] = folder;
|
|
149
|
-
delete this._size;
|
|
150
|
-
delete this._src;
|
|
151
|
-
|
|
152
|
-
return folder;
|
|
153
|
-
}
|
|
154
|
-
}, {
|
|
155
|
-
key: 'addModule',
|
|
156
|
-
value: function addModule(name, data) {
|
|
157
|
-
var node = this.children[name];
|
|
158
|
-
|
|
159
|
-
// For some reason we already have this node in children and it's a folder.
|
|
160
|
-
if (node && node instanceof Folder) return false;
|
|
161
|
-
|
|
162
|
-
if (node) {
|
|
163
|
-
// We already have this node in children and it's a module.
|
|
164
|
-
// Merging it's data.
|
|
165
|
-
node.mergeData(data);
|
|
166
|
-
} else {
|
|
167
|
-
// Creating new module.
|
|
168
|
-
node = new Module(name, data, this);
|
|
169
|
-
this.children[name] = node;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
delete this._size;
|
|
173
|
-
delete this._src;
|
|
174
|
-
|
|
175
|
-
return true;
|
|
176
|
-
}
|
|
177
|
-
}, {
|
|
178
|
-
key: 'addModuleByPath',
|
|
179
|
-
value: function addModuleByPath(path, data) {
|
|
180
|
-
var _ref = [path.slice(0, -1), _.last(path)],
|
|
181
|
-
pathParts = _ref[0],
|
|
182
|
-
fileName = _ref[1];
|
|
183
|
-
|
|
184
|
-
var currentFolder = this;
|
|
185
|
-
|
|
186
|
-
_.each(pathParts, function (pathPart) {
|
|
187
|
-
var childNode = currentFolder.getChild(pathPart);
|
|
188
|
-
|
|
189
|
-
if (
|
|
190
|
-
// Folder is not created yet
|
|
191
|
-
!childNode ||
|
|
192
|
-
// In some situations (invalid usage of dynamic `require()`) webpack generates a module with empty require
|
|
193
|
-
// context, but it's moduleId points to a directory in filesystem.
|
|
194
|
-
// In this case we replace this `File` node with `Folder`.
|
|
195
|
-
// See `test/stats/with-invalid-dynamic-require.json` as an example.
|
|
196
|
-
!(childNode instanceof Folder)) {
|
|
197
|
-
childNode = currentFolder.addFolder(pathPart);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
currentFolder = childNode;
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
currentFolder.addModule(fileName, data);
|
|
204
|
-
}
|
|
205
|
-
}, {
|
|
206
|
-
key: 'walk',
|
|
207
|
-
value: function walk(walker) {
|
|
208
|
-
var state = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
209
|
-
var deep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
210
|
-
|
|
211
|
-
var stopped = false;
|
|
212
|
-
|
|
213
|
-
_.each(this.children, function (child) {
|
|
214
|
-
if (deep && child.walk) {
|
|
215
|
-
state = child.walk(walker, state, stop);
|
|
216
|
-
} else {
|
|
217
|
-
state = walker(child, state, stop);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (stopped) return false;
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
return state;
|
|
224
|
-
|
|
225
|
-
function stop(finalState) {
|
|
226
|
-
stopped = true;
|
|
227
|
-
return finalState;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}, {
|
|
231
|
-
key: 'toString',
|
|
232
|
-
value: function toString(indent, opts) {
|
|
233
|
-
var _ref2 = opts || {},
|
|
234
|
-
sortBy = _ref2.sortBy;
|
|
235
|
-
|
|
236
|
-
indent = indent || '|';
|
|
237
|
-
|
|
238
|
-
var str = `${indent} ${this.name} (${filesize(this.size)})\n`;
|
|
239
|
-
|
|
240
|
-
str += _(this.children).sortBy(sortBy).reverse().map(function (child) {
|
|
241
|
-
return child.toString(`${indent} |`, opts);
|
|
242
|
-
}).join('\n');
|
|
243
|
-
|
|
244
|
-
return str;
|
|
245
|
-
}
|
|
246
|
-
}, {
|
|
247
|
-
key: 'toChartData',
|
|
248
|
-
value: function toChartData() {
|
|
249
|
-
return {
|
|
250
|
-
label: this.name,
|
|
251
|
-
path: this.path,
|
|
252
|
-
statSize: this.size,
|
|
253
|
-
parsedSize: this.parsedSize,
|
|
254
|
-
gzipSize: this.gzipSize,
|
|
255
|
-
groups: _.invokeMap(this.children, 'toChartData')
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
}, {
|
|
259
|
-
key: 'src',
|
|
260
|
-
get: function get() {
|
|
261
|
-
if (!_.has(this, '_src')) {
|
|
262
|
-
this._src = this.walk(function (node, src, stop) {
|
|
263
|
-
if (node.src === undefined) return stop(undefined);
|
|
264
|
-
return src += node.src;
|
|
265
|
-
}, '', false);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
return this._src;
|
|
269
|
-
}
|
|
270
|
-
}, {
|
|
271
|
-
key: 'size',
|
|
272
|
-
get: function get() {
|
|
273
|
-
if (!_.has(this, '_size')) {
|
|
274
|
-
this._size = this.walk(function (node, size) {
|
|
275
|
-
return size + node.size;
|
|
276
|
-
}, 0, false);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return this._size;
|
|
280
|
-
}
|
|
281
|
-
}, {
|
|
282
|
-
key: 'parsedSize',
|
|
283
|
-
get: function get() {
|
|
284
|
-
return this.src ? this.src.length : undefined;
|
|
285
|
-
}
|
|
286
|
-
}, {
|
|
287
|
-
key: 'gzipSize',
|
|
288
|
-
get: function get() {
|
|
289
|
-
if (!_.has(this, '_gzipSize')) {
|
|
290
|
-
this._gzipSize = this.src ? gzipSize.sync(this.src) : undefined;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
return this._gzipSize;
|
|
294
|
-
}
|
|
295
|
-
}]);
|
|
296
|
-
|
|
297
|
-
return Folder;
|
|
298
|
-
}(Node);
|
|
299
|
-
|
|
300
|
-
module.exports = {
|
|
301
|
-
Node,
|
|
302
|
-
Module,
|
|
303
|
-
Folder
|
|
304
|
-
};
|
package/src/tree.js
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
const _ = require('lodash');
|
|
2
|
-
const filesize = require('filesize');
|
|
3
|
-
const gzipSize = require('gzip-size');
|
|
4
|
-
|
|
5
|
-
class Node {
|
|
6
|
-
|
|
7
|
-
constructor(name, parent) {
|
|
8
|
-
this.name = name;
|
|
9
|
-
this.parent = parent;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
get path() {
|
|
13
|
-
const path = [];
|
|
14
|
-
let node = this;
|
|
15
|
-
|
|
16
|
-
while (node) {
|
|
17
|
-
path.push(node.name);
|
|
18
|
-
node = node.parent;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return path.reverse().join('/');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
toString(indent) {
|
|
25
|
-
indent = indent || '|';
|
|
26
|
-
|
|
27
|
-
return `${indent} ${this.name}`;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
class Module extends Node {
|
|
33
|
-
|
|
34
|
-
constructor(name, data, parent) {
|
|
35
|
-
super(name, parent);
|
|
36
|
-
this.data = data;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
get src() {
|
|
40
|
-
return this.data.parsedSrc;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
set src(value) {
|
|
44
|
-
this.data.parsedSrc = value;
|
|
45
|
-
delete this._gzipSize;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
get size() {
|
|
49
|
-
return this.data.size;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
set size(value) {
|
|
53
|
-
this.data.size = value;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
get parsedSize() {
|
|
57
|
-
return this.src ? this.src.length : undefined;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
get gzipSize() {
|
|
61
|
-
if (!_.has(this, '_gzipSize')) {
|
|
62
|
-
this._gzipSize = this.src ? gzipSize.sync(this.src) : undefined;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return this._gzipSize;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
mergeData(data) {
|
|
69
|
-
if (data.size) {
|
|
70
|
-
this.size += data.size;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (data.parsedSrc) {
|
|
74
|
-
this.src = (this.src || '') + data.parsedSrc;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
toString(indent) {
|
|
79
|
-
return `${super.toString(indent)} [${this.data.id}] (${filesize(this.size)})`;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
toChartData() {
|
|
83
|
-
return {
|
|
84
|
-
id: this.data.id,
|
|
85
|
-
label: this.name,
|
|
86
|
-
path: this.path,
|
|
87
|
-
statSize: this.size,
|
|
88
|
-
parsedSize: this.parsedSize,
|
|
89
|
-
gzipSize: this.gzipSize
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
class Folder extends Node {
|
|
97
|
-
|
|
98
|
-
constructor(name, parent) {
|
|
99
|
-
super(name, parent);
|
|
100
|
-
this.children = Object.create(null);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
get src() {
|
|
104
|
-
if (!_.has(this, '_src')) {
|
|
105
|
-
this._src = this.walk((node, src, stop) => {
|
|
106
|
-
if (node.src === undefined) return stop(undefined);
|
|
107
|
-
return (src += node.src);
|
|
108
|
-
}, '', false);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return this._src;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
get size() {
|
|
115
|
-
if (!_.has(this, '_size')) {
|
|
116
|
-
this._size = this.walk((node, size) => (size + node.size), 0, false);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return this._size;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
get parsedSize() {
|
|
123
|
-
return this.src ? this.src.length : undefined;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
get gzipSize() {
|
|
127
|
-
if (!_.has(this, '_gzipSize')) {
|
|
128
|
-
this._gzipSize = this.src ? gzipSize.sync(this.src) : undefined;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return this._gzipSize;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
getChild(name) {
|
|
135
|
-
return this.children[name];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
addFolder(name) {
|
|
139
|
-
const folder = new Folder(name, this);
|
|
140
|
-
|
|
141
|
-
this.children[name] = folder;
|
|
142
|
-
delete this._size;
|
|
143
|
-
delete this._src;
|
|
144
|
-
|
|
145
|
-
return folder;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
addModule(name, data) {
|
|
149
|
-
let node = this.children[name];
|
|
150
|
-
|
|
151
|
-
// For some reason we already have this node in children and it's a folder.
|
|
152
|
-
if (node && node instanceof Folder) return false;
|
|
153
|
-
|
|
154
|
-
if (node) {
|
|
155
|
-
// We already have this node in children and it's a module.
|
|
156
|
-
// Merging it's data.
|
|
157
|
-
node.mergeData(data);
|
|
158
|
-
} else {
|
|
159
|
-
// Creating new module.
|
|
160
|
-
node = new Module(name, data, this);
|
|
161
|
-
this.children[name] = node;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
delete this._size;
|
|
165
|
-
delete this._src;
|
|
166
|
-
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
addModuleByPath(path, data) {
|
|
171
|
-
const [pathParts, fileName] = [path.slice(0, -1), _.last(path)];
|
|
172
|
-
let currentFolder = this;
|
|
173
|
-
|
|
174
|
-
_.each(pathParts, pathPart => {
|
|
175
|
-
let childNode = currentFolder.getChild(pathPart);
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
// Folder is not created yet
|
|
179
|
-
!childNode ||
|
|
180
|
-
// In some situations (invalid usage of dynamic `require()`) webpack generates a module with empty require
|
|
181
|
-
// context, but it's moduleId points to a directory in filesystem.
|
|
182
|
-
// In this case we replace this `File` node with `Folder`.
|
|
183
|
-
// See `test/stats/with-invalid-dynamic-require.json` as an example.
|
|
184
|
-
!(childNode instanceof Folder)
|
|
185
|
-
) {
|
|
186
|
-
childNode = currentFolder.addFolder(pathPart);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
currentFolder = childNode;
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
currentFolder.addModule(fileName, data);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
walk(walker, state = {}, deep = true) {
|
|
196
|
-
let stopped = false;
|
|
197
|
-
|
|
198
|
-
_.each(this.children, child => {
|
|
199
|
-
if (deep && child.walk) {
|
|
200
|
-
state = child.walk(walker, state, stop);
|
|
201
|
-
} else {
|
|
202
|
-
state = walker(child, state, stop);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (stopped) return false;
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
return state;
|
|
209
|
-
|
|
210
|
-
function stop(finalState) {
|
|
211
|
-
stopped = true;
|
|
212
|
-
return finalState;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
toString(indent, opts) {
|
|
217
|
-
const { sortBy } = opts || {};
|
|
218
|
-
indent = indent || '|';
|
|
219
|
-
|
|
220
|
-
let str = `${indent} ${this.name} (${filesize(this.size)})\n`;
|
|
221
|
-
|
|
222
|
-
str += _(this.children)
|
|
223
|
-
.sortBy(sortBy)
|
|
224
|
-
.reverse()
|
|
225
|
-
.map(child => child.toString(`${indent} |`, opts))
|
|
226
|
-
.join('\n');
|
|
227
|
-
|
|
228
|
-
return str;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
toChartData() {
|
|
232
|
-
return {
|
|
233
|
-
label: this.name,
|
|
234
|
-
path: this.path,
|
|
235
|
-
statSize: this.size,
|
|
236
|
-
parsedSize: this.parsedSize,
|
|
237
|
-
gzipSize: this.gzipSize,
|
|
238
|
-
groups: _.invokeMap(this.children, 'toChartData')
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
module.exports = {
|
|
245
|
-
Node,
|
|
246
|
-
Module,
|
|
247
|
-
Folder
|
|
248
|
-
};
|