lighthouse 9.5.0-dev.20220316 → 9.5.0-dev.20220317
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-cli/test/smokehouse/core-tests.js +2 -0
- package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +1 -0
- package/lighthouse-core/audits/byte-efficiency/duplicated-javascript.js +2 -5
- package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +2 -5
- package/lighthouse-core/audits/byte-efficiency/unminified-javascript.js +2 -1
- package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +2 -1
- package/lighthouse-core/lib/script-helpers.js +22 -0
- package/package.json +3 -2
|
@@ -52,6 +52,7 @@ import pwaSvgomg from './test-definitions/pwa-svgomg.js';
|
|
|
52
52
|
import redirectsClientPaintServer from './test-definitions/redirects-client-paint-server.js';
|
|
53
53
|
import redirectsHistoryPushState from './test-definitions/redirects-history-push-state.js';
|
|
54
54
|
import redirectsMultipleServer from './test-definitions/redirects-multiple-server.js';
|
|
55
|
+
import redirectScripts from './test-definitions/redirects-scripts.js';
|
|
55
56
|
import redirectsSingleClient from './test-definitions/redirects-single-client.js';
|
|
56
57
|
import redirectsSingleServer from './test-definitions/redirects-single-server.js';
|
|
57
58
|
import redirectsSelf from './test-definitions/redirects-self.js';
|
|
@@ -112,6 +113,7 @@ const smokeTests = [
|
|
|
112
113
|
redirectsClientPaintServer,
|
|
113
114
|
redirectsHistoryPushState,
|
|
114
115
|
redirectsMultipleServer,
|
|
116
|
+
redirectScripts,
|
|
115
117
|
redirectsSingleClient,
|
|
116
118
|
redirectsSingleServer,
|
|
117
119
|
redirectsSelf,
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
const ByteEfficiencyAudit = require('./byte-efficiency-audit.js');
|
|
13
13
|
const ModuleDuplication = require('../../computed/module-duplication.js');
|
|
14
|
-
const NetworkAnalyzer = require('../../lib/dependency-graph/simulator/network-analyzer.js');
|
|
15
14
|
const i18n = require('../../lib/i18n/i18n.js');
|
|
15
|
+
const {getRequestForScript} = require('../../lib/script-helpers.js');
|
|
16
16
|
|
|
17
17
|
const UIStrings = {
|
|
18
18
|
/** Imperative title of a Lighthouse audit that tells the user to remove duplicate JavaScript from their code. This is displayed in a list of audit titles that Lighthouse generates. */
|
|
@@ -130,7 +130,6 @@ class DuplicatedJavascript extends ByteEfficiencyAudit {
|
|
|
130
130
|
context.options?.ignoreThresholdInBytes || IGNORE_THRESHOLD_IN_BYTES;
|
|
131
131
|
const duplication =
|
|
132
132
|
await DuplicatedJavascript._getDuplicationGroupedByNodeModules(artifacts, context);
|
|
133
|
-
const mainDocumentRecord = NetworkAnalyzer.findOptionalMainDocument(networkRecords);
|
|
134
133
|
|
|
135
134
|
/** @type {Map<string, number>} */
|
|
136
135
|
const transferRatioByUrl = new Map();
|
|
@@ -164,9 +163,7 @@ class DuplicatedJavascript extends ByteEfficiencyAudit {
|
|
|
164
163
|
/** @type {number|undefined} */
|
|
165
164
|
let transferRatio = transferRatioByUrl.get(url);
|
|
166
165
|
if (transferRatio === undefined) {
|
|
167
|
-
const networkRecord =
|
|
168
|
-
mainDocumentRecord :
|
|
169
|
-
networkRecords.find(n => n.url === url);
|
|
166
|
+
const networkRecord = getRequestForScript(networkRecords, script);
|
|
170
167
|
|
|
171
168
|
if (!script || script.length === undefined) {
|
|
172
169
|
// This should never happen because we found the wasted bytes from bundles, which required contents in a ScriptElement.
|
|
@@ -22,7 +22,7 @@ const ByteEfficiencyAudit = require('./byte-efficiency-audit.js');
|
|
|
22
22
|
const JsBundles = require('../../computed/js-bundles.js');
|
|
23
23
|
const i18n = require('../../lib/i18n/i18n.js');
|
|
24
24
|
const thirdPartyWeb = require('../../lib/third-party-web.js');
|
|
25
|
-
const
|
|
25
|
+
const {getRequestForScript} = require('../../lib/script-helpers.js');
|
|
26
26
|
|
|
27
27
|
const UIStrings = {
|
|
28
28
|
/** Title of a Lighthouse audit that tells the user about legacy polyfills and transforms used on the page. This is displayed in a list of audit titles that Lighthouse generates. */
|
|
@@ -372,11 +372,8 @@ class LegacyJavascript extends ByteEfficiencyAudit {
|
|
|
372
372
|
let transferRatio = transferRatioByUrl.get(url);
|
|
373
373
|
if (transferRatio !== undefined) return transferRatio;
|
|
374
374
|
|
|
375
|
-
const mainDocumentRecord = NetworkAnalyzer.findOptionalMainDocument(networkRecords);
|
|
376
375
|
const script = artifacts.Scripts.find(script => script.url === url);
|
|
377
|
-
const networkRecord =
|
|
378
|
-
mainDocumentRecord :
|
|
379
|
-
networkRecords.find(n => n.url === script?.url);
|
|
376
|
+
const networkRecord = getRequestForScript(networkRecords, script);
|
|
380
377
|
|
|
381
378
|
if (!script || script.content === null) {
|
|
382
379
|
// Can't find content, so just use 1.
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const ByteEfficiencyAudit = require('./byte-efficiency-audit.js');
|
|
9
9
|
const i18n = require('../../lib/i18n/i18n.js');
|
|
10
10
|
const computeTokenLength = require('../../lib/minification-estimator.js').computeJSTokenLength;
|
|
11
|
+
const {getRequestForScript} = require('../../lib/script-helpers.js');
|
|
11
12
|
|
|
12
13
|
const UIStrings = {
|
|
13
14
|
/** Imperative title of a Lighthouse audit that tells the user to minify the page’s JS code to reduce file size. This is displayed in a list of audit titles that Lighthouse generates. */
|
|
@@ -81,7 +82,7 @@ class UnminifiedJavaScript extends ByteEfficiencyAudit {
|
|
|
81
82
|
for (const script of artifacts.Scripts) {
|
|
82
83
|
if (!script.content) continue;
|
|
83
84
|
|
|
84
|
-
const networkRecord = networkRecords
|
|
85
|
+
const networkRecord = getRequestForScript(networkRecords, script);
|
|
85
86
|
const displayUrl = script.name === artifacts.URL.finalUrl ?
|
|
86
87
|
`inline: ${script.content.substring(0, 40)}...` :
|
|
87
88
|
script.url;
|
|
@@ -9,6 +9,7 @@ const ByteEfficiencyAudit = require('./byte-efficiency-audit.js');
|
|
|
9
9
|
const UnusedJavaScriptSummary = require('../../computed/unused-javascript-summary.js');
|
|
10
10
|
const JsBundles = require('../../computed/js-bundles.js');
|
|
11
11
|
const i18n = require('../../lib/i18n/i18n.js');
|
|
12
|
+
const {getRequestForScript} = require('../../lib/script-helpers.js');
|
|
12
13
|
|
|
13
14
|
const UIStrings = {
|
|
14
15
|
/** Imperative title of a Lighthouse audit that tells the user to reduce JavaScript that is never evaluated during page load. This is displayed in a list of audit titles that Lighthouse generates. */
|
|
@@ -90,7 +91,7 @@ class UnusedJavaScript extends ByteEfficiencyAudit {
|
|
|
90
91
|
const script = artifacts.Scripts.find(s => s.scriptId === scriptId);
|
|
91
92
|
if (!script) continue; // This should never happen.
|
|
92
93
|
|
|
93
|
-
const networkRecord = networkRecords
|
|
94
|
+
const networkRecord = getRequestForScript(networkRecords, script);
|
|
94
95
|
if (!networkRecord) continue;
|
|
95
96
|
|
|
96
97
|
const bundle = bundles.find(b => b.script.scriptId === scriptId);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright 2022 The Lighthouse Authors. All Rights Reserved.
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
4
|
+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
5
|
+
*/
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {LH.Artifacts.NetworkRequest[]} networkRecords
|
|
10
|
+
* @param {LH.Artifacts.Script|undefined} script
|
|
11
|
+
* @return {LH.Artifacts.NetworkRequest|undefined}
|
|
12
|
+
*/
|
|
13
|
+
function getRequestForScript(networkRecords, script) {
|
|
14
|
+
if (!script) return;
|
|
15
|
+
let networkRequest = networkRecords.find(request => request.url === script.url);
|
|
16
|
+
while (networkRequest?.redirectDestination) {
|
|
17
|
+
networkRequest = networkRequest.redirectDestination;
|
|
18
|
+
}
|
|
19
|
+
return networkRequest;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = {getRequestForScript};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lighthouse",
|
|
3
|
-
"version": "9.5.0-dev.
|
|
3
|
+
"version": "9.5.0-dev.20220317",
|
|
4
4
|
"description": "Automated auditing, performance metrics, and best practices for the web.",
|
|
5
5
|
"main": "./lighthouse-core/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -75,13 +75,14 @@
|
|
|
75
75
|
"update:lantern-baseline": "node lighthouse-core/scripts/lantern/update-baseline-lantern-values.js",
|
|
76
76
|
"update:sample-artifacts": "node lighthouse-core/scripts/update-report-fixtures.js",
|
|
77
77
|
"update:sample-json": "yarn i18n:collect-strings && node ./lighthouse-cli -A=./lighthouse-core/test/results/artifacts --config-path=./lighthouse-core/test/results/sample-config.js --output=json --output-path=./lighthouse-core/test/results/sample_v2.json && node lighthouse-core/scripts/cleanup-LHR-for-diff.js ./lighthouse-core/test/results/sample_v2.json --only-remove-timing",
|
|
78
|
-
"update:flow-sample-json": "node ./lighthouse-core/scripts/update-flow-fixtures.js",
|
|
78
|
+
"update:flow-sample-json": "yarn i18n:collect-strings && node ./lighthouse-core/scripts/update-flow-fixtures.js",
|
|
79
79
|
"update:snapshot-sample-json": "node ./lighthouse-core/scripts/update-snapshot-sample.js",
|
|
80
80
|
"update:test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh --reset-results",
|
|
81
81
|
"test-devtools": "bash lighthouse-core/test/chromium-web-tests/test-locally.sh",
|
|
82
82
|
"open-devtools": "bash lighthouse-core/scripts/open-devtools.sh",
|
|
83
83
|
"run-devtools": "node lighthouse-core/scripts/pptr-run-devtools.js",
|
|
84
84
|
"diff:sample-json": "yarn i18n:checks && bash lighthouse-core/scripts/assert-golden-lhr-unchanged.sh",
|
|
85
|
+
"diff:flow-sample-json": "yarn i18n:collect-strings && bash lighthouse-core/scripts/assert-baseline-flow-result-unchanged.sh",
|
|
85
86
|
"computeBenchmarkIndex": "./lighthouse-core/scripts/benchmark.js",
|
|
86
87
|
"minify-latest-run": "./lighthouse-core/scripts/lantern/minify-trace.js ./latest-run/defaultPass.trace.json ./latest-run/defaultPass.trace.min.json && ./lighthouse-core/scripts/lantern/minify-devtoolslog.js ./latest-run/defaultPass.devtoolslog.json ./latest-run/defaultPass.devtoolslog.min.json",
|
|
87
88
|
"save-latest-run": "./lighthouse-core/scripts/save-latest-run.sh",
|