lighthouse 9.5.0-dev.20220327 → 9.5.0-dev.20220328
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/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +0 -1
- package/lighthouse-core/audits/byte-efficiency/duplicated-javascript.js +1 -1
- package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +15 -16
- package/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js +1 -1
- package/package.json +1 -1
|
@@ -158,7 +158,6 @@ class UnusedBytes extends Audit {
|
|
|
158
158
|
|
|
159
159
|
const simulationBeforeChanges = simulator.simulate(graph, {label: beforeLabel});
|
|
160
160
|
|
|
161
|
-
// TODO: change this to wastedBytesByScriptId
|
|
162
161
|
const wastedBytesByUrl = options.providedWastedBytesByUrl || new Map();
|
|
163
162
|
if (!options.providedWastedBytesByUrl) {
|
|
164
163
|
for (const {url, wastedBytes} of results) {
|
|
@@ -164,7 +164,7 @@ class DuplicatedJavascript extends ByteEfficiencyAudit {
|
|
|
164
164
|
let transferRatio = transferRatioByUrl.get(url);
|
|
165
165
|
if (transferRatio === undefined) {
|
|
166
166
|
if (!script || script.length === undefined) {
|
|
167
|
-
// This should never happen because we found the wasted bytes from bundles, which required contents in a
|
|
167
|
+
// This should never happen because we found the wasted bytes from bundles, which required contents in a Script.
|
|
168
168
|
continue;
|
|
169
169
|
}
|
|
170
170
|
|
|
@@ -277,21 +277,21 @@ class LegacyJavascript extends ByteEfficiencyAudit {
|
|
|
277
277
|
* @param {LH.Artifacts['Scripts']} scripts
|
|
278
278
|
* @param {LH.Artifacts.NetworkRequest[]} networkRecords
|
|
279
279
|
* @param {LH.Artifacts.Bundle[]} bundles
|
|
280
|
-
* @return {Map<
|
|
280
|
+
* @return {Map<LH.Artifacts.Script, PatternMatchResult[]>}
|
|
281
281
|
*/
|
|
282
282
|
static detectAcrossScripts(matcher, scripts, networkRecords, bundles) {
|
|
283
|
-
/** @type {Map<
|
|
284
|
-
const
|
|
283
|
+
/** @type {Map<LH.Artifacts.Script, PatternMatchResult[]>} */
|
|
284
|
+
const scriptToMatchResults = new Map();
|
|
285
285
|
const polyfillData = this.getPolyfillData();
|
|
286
286
|
|
|
287
|
-
for (const
|
|
288
|
-
if (!content) continue;
|
|
287
|
+
for (const script of Object.values(scripts)) {
|
|
288
|
+
if (!script.content) continue;
|
|
289
289
|
|
|
290
290
|
// Start with pattern matching against the downloaded script.
|
|
291
|
-
const matches = matcher.match(content);
|
|
291
|
+
const matches = matcher.match(script.content);
|
|
292
292
|
|
|
293
293
|
// If it's a bundle with source maps, add in the polyfill modules by name too.
|
|
294
|
-
const bundle = bundles.find(b => b.script.scriptId === scriptId);
|
|
294
|
+
const bundle = bundles.find(b => b.script.scriptId === script.scriptId);
|
|
295
295
|
if (bundle) {
|
|
296
296
|
for (const {coreJs2Module, coreJs3Module, name} of polyfillData) {
|
|
297
297
|
// Skip if the pattern matching found a match for this polyfill.
|
|
@@ -311,11 +311,10 @@ class LegacyJavascript extends ByteEfficiencyAudit {
|
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
if (!matches.length) continue;
|
|
314
|
-
|
|
315
|
-
urlToMatchResults.set(url, matches);
|
|
314
|
+
scriptToMatchResults.set(script, matches);
|
|
316
315
|
}
|
|
317
316
|
|
|
318
|
-
return
|
|
317
|
+
return scriptToMatchResults;
|
|
319
318
|
}
|
|
320
319
|
|
|
321
320
|
/**
|
|
@@ -410,15 +409,15 @@ class LegacyJavascript extends ByteEfficiencyAudit {
|
|
|
410
409
|
/** @type {Map<string, number>} */
|
|
411
410
|
const transferRatioByUrl = new Map();
|
|
412
411
|
|
|
413
|
-
const
|
|
412
|
+
const scriptToMatchResults =
|
|
414
413
|
this.detectAcrossScripts(matcher, artifacts.Scripts, networkRecords, bundles);
|
|
415
|
-
for (const [
|
|
414
|
+
for (const [script, matches] of scriptToMatchResults.entries()) {
|
|
416
415
|
const transferRatio = await this.estimateTransferRatioForScript(
|
|
417
|
-
transferRatioByUrl, url, artifacts, networkRecords);
|
|
416
|
+
transferRatioByUrl, script.url, artifacts, networkRecords);
|
|
418
417
|
const wastedBytes = Math.round(this.estimateWastedBytes(matches) * transferRatio);
|
|
419
418
|
/** @type {typeof items[number]} */
|
|
420
419
|
const item = {
|
|
421
|
-
url,
|
|
420
|
+
url: script.url,
|
|
422
421
|
wastedBytes,
|
|
423
422
|
subItems: {
|
|
424
423
|
type: 'subitems',
|
|
@@ -428,13 +427,13 @@ class LegacyJavascript extends ByteEfficiencyAudit {
|
|
|
428
427
|
totalBytes: 0,
|
|
429
428
|
};
|
|
430
429
|
|
|
431
|
-
const bundle = bundles.find(bundle => bundle.script.
|
|
430
|
+
const bundle = bundles.find(bundle => bundle.script.scriptId === script.scriptId);
|
|
432
431
|
for (const match of matches) {
|
|
433
432
|
const {name, line, column} = match;
|
|
434
433
|
/** @type {SubItem} */
|
|
435
434
|
const subItem = {
|
|
436
435
|
signal: name,
|
|
437
|
-
location: ByteEfficiencyAudit.makeSourceLocation(url, line, column, bundle),
|
|
436
|
+
location: ByteEfficiencyAudit.makeSourceLocation(script.url, line, column, bundle),
|
|
438
437
|
};
|
|
439
438
|
item.subItems.items.push(subItem);
|
|
440
439
|
}
|
package/package.json
CHANGED