webpack-bundle-analyzer 4.9.0 → 4.10.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 CHANGED
@@ -12,6 +12,23 @@ _Note: Gaps between patch versions are faulty, broken or test releases._
12
12
 
13
13
  ## UNRELEASED
14
14
 
15
+ ## 4.10.0
16
+
17
+ * **Improvement**
18
+ * Allows filtering the list of entrypoints ([#624](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/624) by [@chriskrogh](https://github.com/chriskrogh))
19
+
20
+ * **Internal**
21
+ * Make module much slimmer by replacing all `lodash.*` packages ([#612](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/612)) by [@sukkaw](https://github.com/sukkaw).
22
+
23
+ ## 4.9.1
24
+
25
+ * **Internal**
26
+ * Replace some lodash usages with JavaScript native API ([#505](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/505)) by [@sukkaw](https://github.com/sukkaw).
27
+ * Make module much slimmer ([#609](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/609)) by [@sukkaw](https://github.com/sukkaw).
28
+
29
+ * **Bug Fix**
30
+ * fix `analyzerMode: 'server'` on certain machines ([#611](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/611) by [@panbenson](https://github.com/panbenson))
31
+
15
32
  ## 4.9.0
16
33
 
17
34
  * **Improvement**
@@ -6,7 +6,7 @@ const path = require('path');
6
6
 
7
7
  const {
8
8
  bold
9
- } = require('chalk');
9
+ } = require('picocolors');
10
10
 
11
11
  const Logger = require('./Logger');
12
12
 
package/lib/analyzer.js CHANGED
@@ -4,8 +4,6 @@ const fs = require('fs');
4
4
 
5
5
  const path = require('path');
6
6
 
7
- const _ = require('lodash');
8
-
9
7
  const gzipSize = require('gzip-size');
10
8
 
11
9
  const {
@@ -38,7 +36,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
38
36
  } = opts || {};
39
37
  const isAssetIncluded = createAssetsFilter(excludeAssets); // Sometimes all the information is located in `children` array (e.g. problem in #10)
40
38
 
41
- if (_.isEmpty(bundleStats.assets) && !_.isEmpty(bundleStats.children)) {
39
+ if ((bundleStats.assets == null || bundleStats.assets.length === 0) && bundleStats.children && bundleStats.children.length > 0) {
42
40
  const {
43
41
  children
44
42
  } = bundleStats;
@@ -51,7 +49,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
51
49
  bundleStats.assets.push(asset);
52
50
  });
53
51
  }
54
- } else if (!_.isEmpty(bundleStats.children)) {
52
+ } else if (bundleStats.children && bundleStats.children.length > 0) {
55
53
  // Sometimes if there are additional child chunks produced add them as child assets
56
54
  bundleStats.children.forEach(child => {
57
55
  child.assets.forEach(asset => {
@@ -71,7 +69,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
71
69
 
72
70
 
73
71
  asset.name = asset.name.replace(FILENAME_QUERY_REGEXP, '');
74
- return FILENAME_EXTENSIONS.test(asset.name) && !_.isEmpty(asset.chunks) && isAssetIncluded(asset.name);
72
+ return FILENAME_EXTENSIONS.test(asset.name) && asset.chunks.length > 0 && isAssetIncluded(asset.name);
75
73
  }); // Trying to parse bundle assets and get real module sizes if `bundleDir` is provided
76
74
 
77
75
  let bundlesSources = null;
@@ -93,11 +91,14 @@ function getViewerData(bundleStats, bundleDir, opts) {
93
91
  continue;
94
92
  }
95
93
 
96
- bundlesSources[statAsset.name] = _.pick(bundleInfo, 'src', 'runtimeSrc');
94
+ bundlesSources[statAsset.name] = {
95
+ src: bundleInfo.src,
96
+ runtimeSrc: bundleInfo.runtimeSrc
97
+ };
97
98
  Object.assign(parsedModules, bundleInfo.modules);
98
99
  }
99
100
 
100
- if (_.isEmpty(bundlesSources)) {
101
+ if (Object.keys(bundlesSources).length === 0) {
101
102
  bundlesSources = null;
102
103
  parsedModules = null;
103
104
  logger.warn('\nNo bundles were parsed. Analyzer will show only original module sizes from stats file.\n');
@@ -108,10 +109,10 @@ function getViewerData(bundleStats, bundleDir, opts) {
108
109
  // If asset is a childAsset, then calculate appropriate bundle modules by looking through stats.children
109
110
  const assetBundles = statAsset.isChild ? getChildAssetBundles(bundleStats, statAsset.name) : bundleStats;
110
111
  const modules = assetBundles ? getBundleModules(assetBundles) : [];
111
-
112
- const asset = result[statAsset.name] = _.pick(statAsset, 'size');
113
-
114
- const assetSources = bundlesSources && _.has(bundlesSources, statAsset.name) ? bundlesSources[statAsset.name] : null;
112
+ const asset = result[statAsset.name] = {
113
+ size: statAsset.size
114
+ };
115
+ const assetSources = bundlesSources && Object.prototype.hasOwnProperty.call(bundlesSources, statAsset.name) ? bundlesSources[statAsset.name] : null;
115
116
 
116
117
  if (assetSources) {
117
118
  asset.parsedSize = Buffer.byteLength(assetSources.src);
@@ -119,7 +120,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
119
120
  } // Picking modules from current bundle script
120
121
 
121
122
 
122
- const assetModules = modules.filter(statModule => assetHasModule(statAsset, statModule)); // Adding parsed sources
123
+ let assetModules = modules.filter(statModule => assetHasModule(statAsset, statModule)); // Adding parsed sources
123
124
 
124
125
  if (parsedModules) {
125
126
  const unparsedEntryModules = [];
@@ -142,8 +143,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
142
143
  unparsedEntryModules[0].parsedSrc = assetSources.runtimeSrc;
143
144
  } else {
144
145
  // If there are multiple entry points we move all of them under synthetic concatenated module.
145
- _.pullAll(assetModules, unparsedEntryModules);
146
-
146
+ assetModules = assetModules.filter(mod => !unparsedEntryModules.includes(mod));
147
147
  assetModules.unshift({
148
148
  identifier: './entry modules',
149
149
  name: './entry modules',
@@ -173,7 +173,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
173
173
  statSize: asset.tree.size || asset.size,
174
174
  parsedSize: asset.parsedSize,
175
175
  gzipSize: asset.gzipSize,
176
- groups: _.invokeMap(asset.tree.children, 'toChartData'),
176
+ groups: Object.values(asset.tree.children).map(i => i.toChartData()),
177
177
  isInitialByEntrypoint: (_chunkToInitialByEntr = chunkToInitialByEntrypoint[filename]) !== null && _chunkToInitialByEntr !== void 0 ? _chunkToInitialByEntr : {}
178
178
  };
179
179
  });
@@ -186,12 +186,26 @@ function readStatsFromFile(filename) {
186
186
  }
187
187
 
188
188
  function getChildAssetBundles(bundleStats, assetName) {
189
- return (bundleStats.children || []).find(c => _(c.assetsByChunkName).values().flatten().includes(assetName));
189
+ return flatten((bundleStats.children || []).find(c => Object.values(c.assetsByChunkName))).includes(assetName);
190
190
  }
191
191
 
192
192
  function getBundleModules(bundleStats) {
193
- return _(bundleStats.chunks).map('modules').concat(bundleStats.modules).compact().flatten().uniqBy('id') // Filtering out Webpack's runtime modules as they don't have ids and can't be parsed (introduced in Webpack 5)
194
- .reject(isRuntimeModule).value();
193
+ var _bundleStats$chunks;
194
+
195
+ const seenIds = new Set();
196
+ return flatten((((_bundleStats$chunks = bundleStats.chunks) === null || _bundleStats$chunks === void 0 ? void 0 : _bundleStats$chunks.map(chunk => chunk.modules)) || []).concat(bundleStats.modules).filter(Boolean)).filter(mod => {
197
+ // Filtering out Webpack's runtime modules as they don't have ids and can't be parsed (introduced in Webpack 5)
198
+ if (isRuntimeModule(mod)) {
199
+ return false;
200
+ }
201
+
202
+ if (seenIds.has(mod.id)) {
203
+ return false;
204
+ }
205
+
206
+ seenIds.add(mod.id);
207
+ return true;
208
+ });
195
209
  }
196
210
 
197
211
  function assetHasModule(statAsset, statModule) {
@@ -231,4 +245,36 @@ function getChunkToInitialByEntrypoint(bundleStats) {
231
245
  return chunkToEntrypointInititalMap;
232
246
  }
233
247
 
234
- ;
248
+ ;
249
+ /**
250
+ * arr-flatten <https://github.com/jonschlinkert/arr-flatten>
251
+ *
252
+ * Copyright (c) 2014-2017, Jon Schlinkert.
253
+ * Released under the MIT License.
254
+ *
255
+ * Modified by Sukka <https://skk.moe>
256
+ *
257
+ * Replace recursively flatten with one-level deep flatten to match lodash.flatten
258
+ *
259
+ * TODO: replace with Array.prototype.flat once Node.js 10 support is dropped
260
+ */
261
+
262
+ function flatten(arr) {
263
+ if (!arr) return [];
264
+ const len = arr.length;
265
+ if (!len) return [];
266
+ let cur;
267
+ const res = [];
268
+
269
+ for (let i = 0; i < len; i++) {
270
+ cur = arr[i];
271
+
272
+ if (Array.isArray(cur)) {
273
+ res.push(...cur);
274
+ } else {
275
+ res.push(cur);
276
+ }
277
+ }
278
+
279
+ return res;
280
+ }
@@ -10,7 +10,7 @@ const commander = require('commander');
10
10
 
11
11
  const {
12
12
  magenta
13
- } = require('chalk');
13
+ } = require('picocolors');
14
14
 
15
15
  const analyzer = require('../analyzer');
16
16
 
package/lib/parseUtils.js CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  const fs = require('fs');
4
4
 
5
- const _ = require('lodash');
6
-
7
5
  const acorn = require('acorn');
8
6
 
9
7
  const walk = require('acorn-walk');
@@ -116,12 +114,12 @@ function parseBundle(bundlePath) {
116
114
  }
117
115
 
118
116
  });
119
- let modules;
117
+ const modules = {};
120
118
 
121
119
  if (walkState.locations) {
122
- modules = _.mapValues(walkState.locations, loc => content.slice(loc.start, loc.end));
123
- } else {
124
- modules = {};
120
+ Object.entries(walkState.locations).forEach(([id, loc]) => {
121
+ modules[id] = content.slice(loc.start, loc.end);
122
+ });
125
123
  }
126
124
 
127
125
  return {
package/lib/template.js CHANGED
@@ -5,7 +5,9 @@ const path = require('path');
5
5
 
6
6
  const fs = require('fs');
7
7
 
8
- const _ = require('lodash');
8
+ const {
9
+ escape
10
+ } = require('html-escaper');
9
11
 
10
12
  const projectRoot = path.resolve(__dirname, '..');
11
13
  const assetsRoot = path.join(projectRoot, 'public');
@@ -34,10 +36,10 @@ function html(strings, ...values) {
34
36
 
35
37
  function getScript(filename, mode) {
36
38
  if (mode === 'static') {
37
- return `<!-- ${_.escape(filename)} -->
39
+ return `<!-- ${escape(filename)} -->
38
40
  <script>${getAssetContent(filename)}</script>`;
39
41
  } else {
40
- return `<script src="${_.escape(filename)}"></script>`;
42
+ return `<script src="${escape(filename)}"></script>`;
41
43
  }
42
44
  }
43
45
 
@@ -54,7 +56,7 @@ function renderViewer({
54
56
  <head>
55
57
  <meta charset="UTF-8"/>
56
58
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
57
- <title>${_.escape(title)}</title>
59
+ <title>${escape(title)}</title>
58
60
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
59
61
 
60
62
  <script>
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
8
  var _Node = _interopRequireDefault(require("./Node"));
11
9
 
12
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -18,7 +16,7 @@ class BaseFolder extends _Node.default {
18
16
  }
19
17
 
20
18
  get src() {
21
- if (!_lodash.default.has(this, '_src')) {
19
+ if (!Object.prototype.hasOwnProperty.call(this, '_src')) {
22
20
  this._src = this.walk((node, src) => src += node.src || '', '', false);
23
21
  }
24
22
 
@@ -26,7 +24,7 @@ class BaseFolder extends _Node.default {
26
24
  }
27
25
 
28
26
  get size() {
29
- if (!_lodash.default.has(this, '_size')) {
27
+ if (!Object.prototype.hasOwnProperty.call(this, '_size')) {
30
28
  this._size = this.walk((node, size) => size + node.size, 0, false);
31
29
  }
32
30
 
@@ -117,7 +115,7 @@ class BaseFolder extends _Node.default {
117
115
  label: this.name,
118
116
  path: this.path,
119
117
  statSize: this.size,
120
- groups: _lodash.default.invokeMap(this.children, 'toChartData')
118
+ groups: Object.values(this.children).map(child => child.toChartData())
121
119
  };
122
120
  }
123
121
 
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
8
  var _Module = _interopRequireDefault(require("./Module"));
11
9
 
12
10
  var _ContentModule = _interopRequireDefault(require("./ContentModule"));
@@ -56,7 +54,7 @@ class ConcatenatedModule extends _Module.default {
56
54
  return;
57
55
  }
58
56
 
59
- const [folders, fileName] = [pathParts.slice(0, -1), _lodash.default.last(pathParts)];
57
+ const [folders, fileName] = [pathParts.slice(0, -1), pathParts[pathParts.length - 1]];
60
58
  let currentFolder = this;
61
59
  folders.forEach(folderName => {
62
60
  let childFolder = currentFolder.getChild(folderName);
@@ -88,13 +86,17 @@ class ConcatenatedModule extends _Module.default {
88
86
  }
89
87
 
90
88
  mergeNestedFolders() {
91
- _lodash.default.invokeMap(this.children, 'mergeNestedFolders');
89
+ Object.values(this.children).forEach(child => {
90
+ if (child.mergeNestedFolders) {
91
+ child.mergeNestedFolders();
92
+ }
93
+ });
92
94
  }
93
95
 
94
96
  toChartData() {
95
97
  return { ...super.toChartData(),
96
98
  concatenated: true,
97
- groups: _lodash.default.invokeMap(this.children, 'toChartData')
99
+ groups: Object.values(this.children).map(child => child.toChartData())
98
100
  };
99
101
  }
100
102
 
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
8
  var _gzipSize = _interopRequireDefault(require("gzip-size"));
11
9
 
12
10
  var _Module = _interopRequireDefault(require("./Module"));
@@ -25,7 +23,7 @@ class Folder extends _BaseFolder.default {
25
23
  }
26
24
 
27
25
  get gzipSize() {
28
- if (!_lodash.default.has(this, '_gzipSize')) {
26
+ if (!Object.prototype.hasOwnProperty.call(this, '_gzipSize')) {
29
27
  this._gzipSize = this.src ? _gzipSize.default.sync(this.src) : 0;
30
28
  }
31
29
 
@@ -39,7 +37,7 @@ class Folder extends _BaseFolder.default {
39
37
  return;
40
38
  }
41
39
 
42
- const [folders, fileName] = [pathParts.slice(0, -1), _lodash.default.last(pathParts)];
40
+ const [folders, fileName] = [pathParts.slice(0, -1), pathParts[pathParts.length - 1]];
43
41
  let currentFolder = this;
44
42
  folders.forEach(folderName => {
45
43
  let childNode = currentFolder.getChild(folderName);
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
- var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
8
  var _gzipSize = _interopRequireDefault(require("gzip-size"));
11
9
 
12
10
  var _Node = _interopRequireDefault(require("./Node"));
@@ -49,7 +47,7 @@ class Module extends _Node.default {
49
47
  }
50
48
 
51
49
  getGzipSize() {
52
- if (!_lodash.default.has(this, '_gzipSize')) {
50
+ if (!('_gzipSize' in this)) {
53
51
  this._gzipSize = this.src ? _gzipSize.default.sync(this.src) : undefined;
54
52
  }
55
53
 
package/lib/tree/utils.js CHANGED
@@ -4,11 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getModulePathParts = getModulePathParts;
7
-
8
- var _lodash = _interopRequireDefault(require("lodash"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
7
  const MULTI_MODULE_REGEXP = /^multi /u;
13
8
 
14
9
  function getModulePathParts(moduleData) {
@@ -16,11 +11,11 @@ function getModulePathParts(moduleData) {
16
11
  return [moduleData.identifier];
17
12
  }
18
13
 
19
- const parsedPath = _lodash.default // Removing loaders from module path: they're joined by `!` and the last part is a raw module path
20
- .last(moduleData.name.split('!')) // Splitting module path into parts
14
+ const loaders = moduleData.name.split('!'); // Removing loaders from module path: they're joined by `!` and the last part is a raw module path
15
+
16
+ const parsedPath = loaders[loaders.length - 1] // Splitting module path into parts
21
17
  .split('/') // Removing first `.`
22
18
  .slice(1) // Replacing `~` with `node_modules`
23
19
  .map(part => part === '~' ? 'node_modules' : part);
24
-
25
20
  return parsedPath.length ? parsedPath : null;
26
21
  }
package/lib/utils.js CHANGED
@@ -5,15 +5,13 @@ const {
5
5
  types
6
6
  } = require('util');
7
7
 
8
- const _ = require('lodash');
9
-
10
8
  const opener = require('opener');
11
9
 
12
10
  const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
13
11
  exports.createAssetsFilter = createAssetsFilter;
14
12
 
15
13
  function createAssetsFilter(excludePatterns) {
16
- const excludeFunctions = _(excludePatterns).castArray().compact().map(pattern => {
14
+ const excludeFunctions = (Array.isArray(excludePatterns) ? excludePatterns : [excludePatterns]).filter(Boolean).map(pattern => {
17
15
  if (typeof pattern === 'string') {
18
16
  pattern = new RegExp(pattern, 'u');
19
17
  }
@@ -29,7 +27,7 @@ function createAssetsFilter(excludePatterns) {
29
27
  }
30
28
 
31
29
  return pattern;
32
- }).value();
30
+ });
33
31
 
34
32
  if (excludeFunctions.length) {
35
33
  return asset => excludeFunctions.every(fn => fn(asset) !== true);
package/lib/viewer.js CHANGED
@@ -10,11 +10,13 @@ const WebSocket = require('ws');
10
10
 
11
11
  const sirv = require('sirv');
12
12
 
13
- const _ = require('lodash');
13
+ const {
14
+ isPlainObject
15
+ } = require('is-plain-object');
14
16
 
15
17
  const {
16
18
  bold
17
- } = require('chalk');
19
+ } = require('picocolors');
18
20
 
19
21
  const Logger = require('./Logger');
20
22
 
@@ -203,7 +205,7 @@ function getChartData(analyzerOpts, ...args) {
203
205
  chartData = null;
204
206
  }
205
207
 
206
- if (_.isPlainObject(chartData) && _.isEmpty(chartData)) {
208
+ if (isPlainObject(chartData) && Object.keys(chartData).length === 0) {
207
209
  logger.error("Could't find any javascript bundles in provided stats file");
208
210
  chartData = null;
209
211
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack-bundle-analyzer",
3
- "version": "4.9.0",
3
+ "version": "4.10.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",
@@ -18,6 +18,7 @@
18
18
  "engines": {
19
19
  "node": ">= 10.13.0"
20
20
  },
21
+ "packageManager": "npm@6.14.8",
21
22
  "scripts": {
22
23
  "start": "gulp watch",
23
24
  "build": "gulp build",
@@ -35,12 +36,15 @@
35
36
  "@discoveryjs/json-ext": "0.5.7",
36
37
  "acorn": "^8.0.4",
37
38
  "acorn-walk": "^8.0.0",
38
- "chalk": "^4.1.0",
39
39
  "commander": "^7.2.0",
40
+ "debounce": "^1.2.1",
41
+ "escape-string-regexp": "^4.0.0",
40
42
  "gzip-size": "^6.0.0",
41
- "lodash": "^4.17.20",
43
+ "html-escaper": "^2.0.2",
44
+ "is-plain-object": "^5.0.0",
42
45
  "opener": "^1.5.2",
43
- "sirv": "^1.0.7",
46
+ "picocolors": "^1.0.0",
47
+ "sirv": "^2.0.3",
44
48
  "ws": "^7.3.1"
45
49
  },
46
50
  "devDependencies": {
@@ -72,6 +76,9 @@
72
76
  "gulp": "4.0.2",
73
77
  "gulp-babel": "8.0.0",
74
78
  "jest": "27.2.2",
79
+ "lodash.memoize": "^4.1.2",
80
+ "lodash.merge": "^4.6.2",
81
+ "lodash.partial": "^4.2.1",
75
82
  "mobx": "5.15.7",
76
83
  "mobx-react": "6.3.1",
77
84
  "postcss": "8.3.0",