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

core(script-treemap-data): default config #12494

Merged
merged 11 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions lighthouse-cli/test/cli/__snapshots__/index-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ Object {
Object {
"path": "full-page-screenshot",
},
Object {
"path": "script-treemap-data",
},
Object {
"path": "manual/pwa-cross-browser",
},
Expand Down
9 changes: 4 additions & 5 deletions lighthouse-core/audits/script-treemap-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,12 @@ class ScriptTreemapDataAudit extends Audit {
* @return {Promise<LH.Audit.Product>}
*/
static async audit(artifacts, context) {
const treemapData = await ScriptTreemapDataAudit.makeNodes(artifacts, context);
const nodes = await ScriptTreemapDataAudit.makeNodes(artifacts, context);

// TODO: when out of experimental should make a new detail type.
/** @type {LH.Audit.Details.DebugData} */
/** @type {LH.Audit.Details.TreemapData} */
const details = {
type: 'debugdata',
treemapData,
type: 'treemap-data',
nodes,
};

return {
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ const defaultConfig = {
'valid-source-maps',
'preload-lcp-image',
'full-page-screenshot',
'script-treemap-data',
'manual/pwa-cross-browser',
'manual/pwa-page-transitions',
'manual/pwa-each-page-has-url',
Expand Down
1 change: 0 additions & 1 deletion lighthouse-core/config/experimental-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const config = {
audits: [
'autocomplete',
'large-javascript-libraries',
'script-treemap-data',
'csp-xss',
],
categories: {
Expand Down
1 change: 1 addition & 0 deletions lighthouse-core/report/html/renderer/details-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class DetailsRenderer {
case 'screenshot':
case 'debugdata':
case 'full-page-screenshot':
case 'treemap-data':
return null;

default: {
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/report/html/renderer/report-ui-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,9 +546,9 @@ class ReportUIFeatures {
* @param {LH.Result} json
*/
static openTreemap(json) {
const treemapDebugData = /** @type {LH.Audit.Details.DebugData} */ (
const treemapData = /** @type {LH.Audit.Details.TreemapData} */ (
json.audits['script-treemap-data'].details);
if (!treemapDebugData) {
if (!treemapData) {
connorjclark marked this conversation as resolved.
Show resolved Hide resolved
throw new Error('no script treemap data found');
}

Expand Down
54 changes: 54 additions & 0 deletions lighthouse-core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2505,6 +2505,42 @@
}
}
},
"script-treemap-data": {
"id": "script-treemap-data",
"title": "Script Treemap Data",
"description": "Used for treemap app",
"score": null,
"scoreDisplayMode": "informative",
"details": {
"type": "treemap-data",
"nodes": [
{
"name": "http://localhost:10200/dobetterweb/dbw_tester.html",
"resourceBytes": 5806
},
{
"name": "http://localhost:10200/dobetterweb/dbw_tester.js",
"resourceBytes": 48
},
{
"name": "http://localhost:10200/dobetterweb/empty_module.js?delay=500",
"resourceBytes": 60
},
{
"name": "http://localhost:10200/dobetterweb/fcp-delayer.js?delay=5000",
"resourceBytes": 60
},
{
"name": "http://localhost:10200/zone.js",
"resourceBytes": 30
},
{
"name": "http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js",
"resourceBytes": 63
}
]
}
},
"pwa-cross-browser": {
"id": "pwa-cross-browser",
"title": "Site works cross-browser",
Expand Down Expand Up @@ -6396,6 +6432,24 @@
"duration": 100,
"entryType": "measure"
},
{
"startTime": 0,
"name": "lh:audit:script-treemap-data",
"duration": 100,
"entryType": "measure"
},
{
"startTime": 0,
"name": "lh:computed:JSBundles",
"duration": 100,
"entryType": "measure"
},
{
"startTime": 0,
"name": "lh:computed:ModuleDuplication",
"duration": 100,
"entryType": "measure"
},
{
"startTime": 0,
"name": "lh:audit:pwa-cross-browser",
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-treemap/app/debug.json
Original file line number Diff line number Diff line change
Expand Up @@ -12077,8 +12077,8 @@
"score": null,
"scoreDisplayMode": "informative",
"details": {
"type": "debugdata",
"treemapData": [
"type": "treemap-data",
"nodes": [
{
"name": "https://www.coursehero.com/",
"resourceBytes": 69863
Expand Down
9 changes: 3 additions & 6 deletions lighthouse-treemap/app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,15 @@ class TreemapViewer {
* @param {HTMLElement} el
*/
constructor(options, el) {
const treemapDebugData = /** @type {LH.Audit.Details.DebugData} */ (
const scriptTreemapData = /** @type {LH.Audit.Details.TreemapData} */ (
options.lhr.audits['script-treemap-data'].details);
connorjclark marked this conversation as resolved.
Show resolved Hide resolved
if (!treemapDebugData || !treemapDebugData.treemapData) {
if (!scriptTreemapData || !scriptTreemapData.nodes) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth accepting both? I don't suppose we expect many treemap reports to have made it out into the wild thusfar, but it would be nice if they weren't bricked (or maybe file issue to add treemap UI message about compat when an unrecognized payload comes in?) :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth accepting both? I don't suppose we expect many treemap reports to have made it out into the wild thusfar

I think it isn't because I think there are none. I shared some but it was as a standalone HTML file.

throw new Error('missing script-treemap-data');
}

/** @type {LH.Treemap.Node[]} */
const scriptNodes = treemapDebugData.treemapData;

/** @type {{[group: string]: LH.Treemap.Node[]}} */
this.depthOneNodesByGroup = {
scripts: scriptNodes,
scripts: scriptTreemapData.nodes,
};

/**
Expand Down
6 changes: 6 additions & 0 deletions types/audit-details.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ declare global {
export type Details =
Details.CriticalRequestChain |
Details.DebugData |
Details.TreemapData |
Details.Filmstrip |
Details.List |
Details.Opportunity |
Expand Down Expand Up @@ -97,6 +98,11 @@ declare global {
[p: string]: any;
}

export interface TreemapData {
type: 'treemap-data';
nodes: LH.Treemap.Node[];
}

/** String enum of possible types of values found within table items. */
type ItemValueType = 'bytes' | 'code' | 'link' | 'ms' | 'multi' | 'node' | 'source-location' | 'numeric' | 'text' | 'thumbnail' | 'timespanMs' | 'url';

Expand Down