webpack-bundle-analyzer 4.9.0 → 4.9.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 +9 -0
- package/lib/BundleAnalyzerPlugin.js +1 -1
- package/lib/analyzer.js +26 -16
- package/lib/bin/analyzer.js +1 -1
- package/lib/parseUtils.js +4 -6
- package/lib/template.js +4 -4
- package/lib/tree/BaseFolder.js +4 -4
- package/lib/tree/ConcatenatedModule.js +4 -4
- package/lib/tree/Folder.js +2 -4
- package/lib/tree/Module.js +1 -3
- package/lib/tree/utils.js +3 -8
- package/lib/utils.js +2 -4
- package/lib/viewer.js +5 -3
- package/package.json +14 -4
- package/public/viewer.js +21 -3
- package/public/viewer.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,15 @@ _Note: Gaps between patch versions are faulty, broken or test releases._
|
|
|
12
12
|
|
|
13
13
|
## UNRELEASED
|
|
14
14
|
|
|
15
|
+
## 4.9.1
|
|
16
|
+
|
|
17
|
+
* **Internal**
|
|
18
|
+
* 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).
|
|
19
|
+
* Make module much slimmer ([#609](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/609)) by [@sukkaw](https://github.com/sukkaw).
|
|
20
|
+
|
|
21
|
+
* **Bug Fix**
|
|
22
|
+
* fix `analyzerMode: 'server'` on certain machines ([#611](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/611) by [@panbenson](https://github.com/panbenson))
|
|
23
|
+
|
|
15
24
|
## 4.9.0
|
|
16
25
|
|
|
17
26
|
* **Improvement**
|
package/lib/analyzer.js
CHANGED
|
@@ -4,7 +4,13 @@ const fs = require('fs');
|
|
|
4
4
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const pullAll = require('lodash.pullall');
|
|
8
|
+
|
|
9
|
+
const invokeMap = require('lodash.invokemap');
|
|
10
|
+
|
|
11
|
+
const uniqBy = require('lodash.uniqby');
|
|
12
|
+
|
|
13
|
+
const flatten = require('lodash.flatten');
|
|
8
14
|
|
|
9
15
|
const gzipSize = require('gzip-size');
|
|
10
16
|
|
|
@@ -38,7 +44,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
|
|
|
38
44
|
} = opts || {};
|
|
39
45
|
const isAssetIncluded = createAssetsFilter(excludeAssets); // Sometimes all the information is located in `children` array (e.g. problem in #10)
|
|
40
46
|
|
|
41
|
-
if (
|
|
47
|
+
if ((bundleStats.assets == null || bundleStats.assets.length === 0) && bundleStats.children && bundleStats.children.length > 0) {
|
|
42
48
|
const {
|
|
43
49
|
children
|
|
44
50
|
} = bundleStats;
|
|
@@ -51,7 +57,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
|
|
|
51
57
|
bundleStats.assets.push(asset);
|
|
52
58
|
});
|
|
53
59
|
}
|
|
54
|
-
} else if (
|
|
60
|
+
} else if (bundleStats.children && bundleStats.children.length > 0) {
|
|
55
61
|
// Sometimes if there are additional child chunks produced add them as child assets
|
|
56
62
|
bundleStats.children.forEach(child => {
|
|
57
63
|
child.assets.forEach(asset => {
|
|
@@ -71,7 +77,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
|
|
|
71
77
|
|
|
72
78
|
|
|
73
79
|
asset.name = asset.name.replace(FILENAME_QUERY_REGEXP, '');
|
|
74
|
-
return FILENAME_EXTENSIONS.test(asset.name) &&
|
|
80
|
+
return FILENAME_EXTENSIONS.test(asset.name) && asset.chunks.length > 0 && isAssetIncluded(asset.name);
|
|
75
81
|
}); // Trying to parse bundle assets and get real module sizes if `bundleDir` is provided
|
|
76
82
|
|
|
77
83
|
let bundlesSources = null;
|
|
@@ -93,11 +99,14 @@ function getViewerData(bundleStats, bundleDir, opts) {
|
|
|
93
99
|
continue;
|
|
94
100
|
}
|
|
95
101
|
|
|
96
|
-
bundlesSources[statAsset.name] =
|
|
102
|
+
bundlesSources[statAsset.name] = {
|
|
103
|
+
src: bundleInfo.src,
|
|
104
|
+
runtimeSrc: bundleInfo.runtimeSrc
|
|
105
|
+
};
|
|
97
106
|
Object.assign(parsedModules, bundleInfo.modules);
|
|
98
107
|
}
|
|
99
108
|
|
|
100
|
-
if (
|
|
109
|
+
if (Object.keys(bundlesSources).length === 0) {
|
|
101
110
|
bundlesSources = null;
|
|
102
111
|
parsedModules = null;
|
|
103
112
|
logger.warn('\nNo bundles were parsed. Analyzer will show only original module sizes from stats file.\n');
|
|
@@ -108,10 +117,10 @@ function getViewerData(bundleStats, bundleDir, opts) {
|
|
|
108
117
|
// If asset is a childAsset, then calculate appropriate bundle modules by looking through stats.children
|
|
109
118
|
const assetBundles = statAsset.isChild ? getChildAssetBundles(bundleStats, statAsset.name) : bundleStats;
|
|
110
119
|
const modules = assetBundles ? getBundleModules(assetBundles) : [];
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const assetSources = bundlesSources &&
|
|
120
|
+
const asset = result[statAsset.name] = {
|
|
121
|
+
size: statAsset.size
|
|
122
|
+
};
|
|
123
|
+
const assetSources = bundlesSources && Object.prototype.hasOwnProperty.call(bundlesSources, statAsset.name) ? bundlesSources[statAsset.name] : null;
|
|
115
124
|
|
|
116
125
|
if (assetSources) {
|
|
117
126
|
asset.parsedSize = Buffer.byteLength(assetSources.src);
|
|
@@ -142,8 +151,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
|
|
|
142
151
|
unparsedEntryModules[0].parsedSrc = assetSources.runtimeSrc;
|
|
143
152
|
} else {
|
|
144
153
|
// If there are multiple entry points we move all of them under synthetic concatenated module.
|
|
145
|
-
|
|
146
|
-
|
|
154
|
+
pullAll(assetModules, unparsedEntryModules);
|
|
147
155
|
assetModules.unshift({
|
|
148
156
|
identifier: './entry modules',
|
|
149
157
|
name: './entry modules',
|
|
@@ -173,7 +181,7 @@ function getViewerData(bundleStats, bundleDir, opts) {
|
|
|
173
181
|
statSize: asset.tree.size || asset.size,
|
|
174
182
|
parsedSize: asset.parsedSize,
|
|
175
183
|
gzipSize: asset.gzipSize,
|
|
176
|
-
groups:
|
|
184
|
+
groups: invokeMap(asset.tree.children, 'toChartData'),
|
|
177
185
|
isInitialByEntrypoint: (_chunkToInitialByEntr = chunkToInitialByEntrypoint[filename]) !== null && _chunkToInitialByEntr !== void 0 ? _chunkToInitialByEntr : {}
|
|
178
186
|
};
|
|
179
187
|
});
|
|
@@ -186,12 +194,14 @@ function readStatsFromFile(filename) {
|
|
|
186
194
|
}
|
|
187
195
|
|
|
188
196
|
function getChildAssetBundles(bundleStats, assetName) {
|
|
189
|
-
return (bundleStats.children || []).find(c =>
|
|
197
|
+
return flatten((bundleStats.children || []).find(c => Object.values(c.assetsByChunkName))).includes(assetName);
|
|
190
198
|
}
|
|
191
199
|
|
|
192
200
|
function getBundleModules(bundleStats) {
|
|
193
|
-
|
|
194
|
-
|
|
201
|
+
var _bundleStats$chunks;
|
|
202
|
+
|
|
203
|
+
return uniqBy(flatten((((_bundleStats$chunks = bundleStats.chunks) === null || _bundleStats$chunks === void 0 ? void 0 : _bundleStats$chunks.map(chunk => chunk.modules)) || []).concat(bundleStats.modules).filter(Boolean)), 'id' // Filtering out Webpack's runtime modules as they don't have ids and can't be parsed (introduced in Webpack 5)
|
|
204
|
+
).filter(m => !isRuntimeModule(m));
|
|
195
205
|
}
|
|
196
206
|
|
|
197
207
|
function assetHasModule(statAsset, statModule) {
|
package/lib/bin/analyzer.js
CHANGED
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
|
-
|
|
117
|
+
const modules = {};
|
|
120
118
|
|
|
121
119
|
if (walkState.locations) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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,7 @@ const path = require('path');
|
|
|
5
5
|
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const escape = require('lodash.escape');
|
|
9
9
|
|
|
10
10
|
const projectRoot = path.resolve(__dirname, '..');
|
|
11
11
|
const assetsRoot = path.join(projectRoot, 'public');
|
|
@@ -34,10 +34,10 @@ function html(strings, ...values) {
|
|
|
34
34
|
|
|
35
35
|
function getScript(filename, mode) {
|
|
36
36
|
if (mode === 'static') {
|
|
37
|
-
return `<!-- ${
|
|
37
|
+
return `<!-- ${escape(filename)} -->
|
|
38
38
|
<script>${getAssetContent(filename)}</script>`;
|
|
39
39
|
} else {
|
|
40
|
-
return `<script src="${
|
|
40
|
+
return `<script src="${escape(filename)}"></script>`;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -54,7 +54,7 @@ function renderViewer({
|
|
|
54
54
|
<head>
|
|
55
55
|
<meta charset="UTF-8"/>
|
|
56
56
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
57
|
-
<title>${
|
|
57
|
+
<title>${escape(title)}</title>
|
|
58
58
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H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UBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
59
59
|
|
|
60
60
|
<script>
|
package/lib/tree/BaseFolder.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash.invokemap"));
|
|
9
9
|
|
|
10
10
|
var _Node = _interopRequireDefault(require("./Node"));
|
|
11
11
|
|
|
@@ -18,7 +18,7 @@ class BaseFolder extends _Node.default {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
get src() {
|
|
21
|
-
if (!
|
|
21
|
+
if (!Object.prototype.hasOwnProperty.call(this, '_src')) {
|
|
22
22
|
this._src = this.walk((node, src) => src += node.src || '', '', false);
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -26,7 +26,7 @@ class BaseFolder extends _Node.default {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
get size() {
|
|
29
|
-
if (!
|
|
29
|
+
if (!Object.prototype.hasOwnProperty.call(this, '_size')) {
|
|
30
30
|
this._size = this.walk((node, size) => size + node.size, 0, false);
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -117,7 +117,7 @@ class BaseFolder extends _Node.default {
|
|
|
117
117
|
label: this.name,
|
|
118
118
|
path: this.path,
|
|
119
119
|
statSize: this.size,
|
|
120
|
-
groups: _lodash.default
|
|
120
|
+
groups: (0, _lodash.default)(this.children, 'toChartData')
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
8
|
+
var _lodash = _interopRequireDefault(require("lodash.invokemap"));
|
|
9
9
|
|
|
10
10
|
var _Module = _interopRequireDefault(require("./Module"));
|
|
11
11
|
|
|
@@ -56,7 +56,7 @@ class ConcatenatedModule extends _Module.default {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const [folders, fileName] = [pathParts.slice(0, -1),
|
|
59
|
+
const [folders, fileName] = [pathParts.slice(0, -1), pathParts[pathParts.length - 1]];
|
|
60
60
|
let currentFolder = this;
|
|
61
61
|
folders.forEach(folderName => {
|
|
62
62
|
let childFolder = currentFolder.getChild(folderName);
|
|
@@ -88,13 +88,13 @@ class ConcatenatedModule extends _Module.default {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
mergeNestedFolders() {
|
|
91
|
-
_lodash.default
|
|
91
|
+
(0, _lodash.default)(this.children, 'mergeNestedFolders');
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
toChartData() {
|
|
95
95
|
return { ...super.toChartData(),
|
|
96
96
|
concatenated: true,
|
|
97
|
-
groups: _lodash.default
|
|
97
|
+
groups: (0, _lodash.default)(this.children, 'toChartData')
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
|
package/lib/tree/Folder.js
CHANGED
|
@@ -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 (!
|
|
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),
|
|
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);
|
package/lib/tree/Module.js
CHANGED
|
@@ -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 (!
|
|
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
|
|
20
|
-
|
|
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 =
|
|
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
|
-
})
|
|
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
|
|
13
|
+
const {
|
|
14
|
+
isPlainObject
|
|
15
|
+
} = require('is-plain-object');
|
|
14
16
|
|
|
15
17
|
const {
|
|
16
18
|
bold
|
|
17
|
-
} = require('
|
|
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 (
|
|
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.
|
|
3
|
+
"version": "4.9.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",
|
|
@@ -35,12 +35,19 @@
|
|
|
35
35
|
"@discoveryjs/json-ext": "0.5.7",
|
|
36
36
|
"acorn": "^8.0.4",
|
|
37
37
|
"acorn-walk": "^8.0.0",
|
|
38
|
-
"chalk": "^4.1.0",
|
|
39
38
|
"commander": "^7.2.0",
|
|
39
|
+
"escape-string-regexp": "^4.0.0",
|
|
40
40
|
"gzip-size": "^6.0.0",
|
|
41
|
-
"
|
|
41
|
+
"is-plain-object": "^5.0.0",
|
|
42
|
+
"lodash.debounce": "^4.0.8",
|
|
43
|
+
"lodash.escape": "^4.0.1",
|
|
44
|
+
"lodash.flatten": "^4.4.0",
|
|
45
|
+
"lodash.invokemap": "^4.6.0",
|
|
46
|
+
"lodash.pullall": "^4.2.0",
|
|
47
|
+
"lodash.uniqby": "^4.7.0",
|
|
42
48
|
"opener": "^1.5.2",
|
|
43
|
-
"
|
|
49
|
+
"picocolors": "^1.0.0",
|
|
50
|
+
"sirv": "^2.0.3",
|
|
44
51
|
"ws": "^7.3.1"
|
|
45
52
|
},
|
|
46
53
|
"devDependencies": {
|
|
@@ -72,6 +79,9 @@
|
|
|
72
79
|
"gulp": "4.0.2",
|
|
73
80
|
"gulp-babel": "8.0.0",
|
|
74
81
|
"jest": "27.2.2",
|
|
82
|
+
"lodash.memoize": "^4.1.2",
|
|
83
|
+
"lodash.merge": "^4.6.2",
|
|
84
|
+
"lodash.partial": "^4.2.1",
|
|
75
85
|
"mobx": "5.15.7",
|
|
76
86
|
"mobx-react": "6.3.1",
|
|
77
87
|
"postcss": "8.3.0",
|