Skip to content

Commit

Permalink
core(script-treemap-data): include unmapped bytes (#12452)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark committed May 11, 2021
1 parent 17e9a13 commit ae57fac
Show file tree
Hide file tree
Showing 5 changed files with 11,244 additions and 8,027 deletions.
11 changes: 11 additions & 0 deletions lighthouse-core/audits/script-treemap-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,17 @@ class ScriptTreemapDataAudit extends Audit {
sourcesData[source] = sourceData;
}

if (bundle.sizes.unmappedBytes) {
/** @type {SourceData} */
const sourceData = {
resourceBytes: bundle.sizes.unmappedBytes,
};
if (unusedJavascriptSummary.sourcesWastedBytes) {
sourceData.unusedBytes = unusedJavascriptSummary.sourcesWastedBytes['(unmapped)'];
}
sourcesData['(unmapped)'] = sourceData;
}

node = this.makeScriptNode(scriptElement.src, bundle.rawMap.sourceRoot || '', sourcesData);
} else {
// No valid source map for this script, so we can only produce a single node.
Expand Down
2 changes: 1 addition & 1 deletion lighthouse-core/computed/unused-javascript-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const makeComputedArtifact = require('./computed-artifact.js');
* @property {number} totalBytes
* @property {number} wastedBytes
* @property {number=} wastedPercent
* @property {Record<string, number>=} sourcesWastedBytes
* @property {Record<string, number>=} sourcesWastedBytes Keyed by file name. Includes (unmapped) key too.
*/

class UnusedJavascriptSummary {
Expand Down

0 comments on commit ae57fac

Please sign in to comment.