Skip to content

Commit c531af9

Browse files
authored
Remove is-plain-object (#627)
1 parent 197510d commit c531af9

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

package-lock.json

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"escape-string-regexp": "^4.0.0",
4242
"gzip-size": "^6.0.0",
4343
"html-escaper": "^2.0.2",
44-
"is-plain-object": "^5.0.0",
4544
"opener": "^1.5.2",
4645
"picocolors": "^1.0.0",
4746
"sirv": "^2.0.3",

src/viewer.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const http = require('http');
44

55
const WebSocket = require('ws');
66
const sirv = require('sirv');
7-
const {isPlainObject} = require('is-plain-object');
87
const {bold} = require('picocolors');
98

109
const Logger = require('./Logger');
@@ -190,7 +189,12 @@ function getChartData(analyzerOpts, ...args) {
190189
chartData = null;
191190
}
192191

193-
if (isPlainObject(chartData) && Object.keys(chartData).length === 0) {
192+
// chartData can either be an array (bundleInfo[]) or null. It can't be an plain object anyway
193+
if (
194+
// analyzer.getViewerData() doesn't failed in the previous step
195+
chartData
196+
&& !Array.isArray(chartData)
197+
) {
194198
logger.error("Could't find any javascript bundles in provided stats file");
195199
chartData = null;
196200
}
@@ -199,8 +203,8 @@ function getChartData(analyzerOpts, ...args) {
199203
}
200204

201205
function getEntrypoints(bundleStats) {
202-
if (bundleStats === null || bundleStats === undefined) {
206+
if (bundleStats === null || bundleStats === undefined || !bundleStats.entrypoints) {
203207
return [];
204208
}
205-
return Object.values(bundleStats.entrypoints || {}).map(entrypoint => entrypoint.name);
209+
return Object.values(bundleStats.entrypoints).map(entrypoint => entrypoint.name);
206210
}

0 commit comments

Comments
 (0)