Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove is-plain-object #627

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"escape-string-regexp": "^4.0.0",
"gzip-size": "^6.0.0",
"html-escaper": "^2.0.2",
"is-plain-object": "^5.0.0",
"opener": "^1.5.2",
"picocolors": "^1.0.0",
"sirv": "^2.0.3",
Expand Down
12 changes: 8 additions & 4 deletions src/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const http = require('http');

const WebSocket = require('ws');
const sirv = require('sirv');
const {isPlainObject} = require('is-plain-object');
const {bold} = require('picocolors');

const Logger = require('./Logger');
Expand Down Expand Up @@ -190,7 +189,12 @@ function getChartData(analyzerOpts, ...args) {
chartData = null;
}

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

function getEntrypoints(bundleStats) {
if (bundleStats === null || bundleStats === undefined) {
if (bundleStats === null || bundleStats === undefined || !bundleStats.entrypoints) {
return [];
}
return Object.values(bundleStats.entrypoints || {}).map(entrypoint => entrypoint.name);
return Object.values(bundleStats.entrypoints).map(entrypoint => entrypoint.name);
}
Loading