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(js-libraries): hide fast path items from table, put all in debugData #10176

Merged
merged 9 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,6 @@ const expectations = [
items: [{
name: 'jQuery',
},
{
name: 'jQuery (Fast path)',
},
{
name: 'WordPress',
}],
Expand Down
17 changes: 16 additions & 1 deletion lighthouse-core/audits/dobetterweb/js-libraries.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class JsLibrariesAudit extends Audit {
static audit(artifacts) {
const libDetails = artifacts.Stacks
.filter(stack => stack.detector === 'js')
// Don't show the fast paths in the table.
.filter(stack => !stack.id.endsWith('-fast'))
.map(stack => ({
name: stack.name,
version: stack.version,
Expand All @@ -57,9 +59,22 @@ class JsLibrariesAudit extends Audit {
];
const details = Audit.makeTableDetails(headings, libDetails, {});

const debugData = {
type: /** @type {'debugdata'} */ ('debugdata'),
stacks: artifacts.Stacks.map(stack => {
return {
id: stack.id,
version: stack.version,
};
}),
};

return {
score: 1, // Always pass for now.
details,
details: {
...details,
debugData,
},
};
}
}
Expand Down
18 changes: 9 additions & 9 deletions lighthouse-core/test/audits/dobetterweb/js-libraries-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ describe('Returns detected front-end JavaScript libraries', () => {
// duplicates. TODO: consider failing in this case
const auditResult2 = JsLibrariesAudit.audit({
Stacks: [
{detector: 'js', name: 'lib1', version: '3.10.1', npm: 'lib1'},
{detector: 'js', name: 'lib2', version: undefined, npm: 'lib2'},
{detector: 'js', id: 'lib1', name: 'lib1', version: '3.10.1', npm: 'lib1'},
{detector: 'js', id: 'lib2', name: 'lib2', version: undefined, npm: 'lib2'},
],
});
assert.equal(auditResult2.score, 1);

// LOTS of frontend libs
const auditResult3 = JsLibrariesAudit.audit({
Stacks: [
{detector: 'js', name: 'React', version: undefined, npm: 'react'},
{detector: 'js', name: 'Polymer', version: undefined, npm: 'polymer-core'},
{detector: 'js', name: 'Preact', version: undefined, npm: 'preact'},
{detector: 'js', name: 'Angular', version: undefined, npm: 'angular'},
{detector: 'js', name: 'jQuery', version: undefined, npm: 'jquery'},
{detector: 'js', id: 'react', name: 'React', version: undefined, npm: 'react'},
{detector: 'js', id: 'polymer', name: 'Polymer', version: undefined, npm: 'polymer-core'},
{detector: 'js', id: 'preact', name: 'Preact', version: undefined, npm: 'preact'},
{detector: 'js', id: 'angular', name: 'Angular', version: undefined, npm: 'angular'},
{detector: 'js', id: 'jquery', name: 'jQuery', version: undefined, npm: 'jquery'},
],
});
assert.equal(auditResult3.score, 1);
Expand All @@ -42,8 +42,8 @@ describe('Returns detected front-end JavaScript libraries', () => {
it('generates expected details', () => {
const auditResult = JsLibrariesAudit.audit({
Stacks: [
{detector: 'js', name: 'lib1', version: '3.10.1', npm: 'lib1'},
{detector: 'js', name: 'lib2', version: undefined, npm: 'lib2'},
{detector: 'js', id: 'lib1', name: 'lib1', version: '3.10.1', npm: 'lib1'},
{detector: 'js', id: 'lib2', name: 'lib2', version: undefined, npm: 'lib2'},
],
});
const expected = [
Expand Down
17 changes: 16 additions & 1 deletion lighthouse-core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -2997,7 +2997,22 @@
"name": "WordPress"
}
],
"summary": {}
"summary": {},
"debugData": {
"type": "debugdata",
"stacks": [
{
"id": "jquery",
"version": "2.1.1"
},
{
"id": "jquery"
},
{
"id": "wordpress"
}
]
}
}
},
"notification-on-start": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"intl-messageformat": "^4.4.0",
"intl-pluralrules": "^1.0.3",
"jpeg-js": "0.1.2",
"js-library-detector": "^5.6.0",
"js-library-detector": "^5.7.0",
"jsonld": "^1.5.0",
"jsonlint-mod": "^1.7.5",
"lighthouse-logger": "^1.2.0",
Expand Down
15 changes: 15 additions & 0 deletions proto/sample_v2_round_trip.json
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,21 @@
"js-libraries": {
"description": "All front-end JavaScript libraries detected on the page. [Learn more](https://web.dev/js-libraries).",
"details": {
"debugData": {
"stacks": [
{
"id": "jquery",
"version": "2.1.1"
},
{
"id": "jquery"
},
{
"id": "wordpress"
}
],
"type": "debugdata"
},
"headings": [
{
"itemType": "text",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4783,10 +4783,10 @@ [email protected], jpeg-js@^0.1.2:
resolved "https://registry.yarnpkg.com/jpeg-js/-/jpeg-js-0.1.2.tgz#135b992c0575c985cfa0f494a3227ed238583ece"
integrity sha1-E1uZLAV1yYXPoPSUoyJ+0jhYPs4=

js-library-detector@^5.6.0:
version "5.6.0"
resolved "https://registry.yarnpkg.com/js-library-detector/-/js-library-detector-5.6.0.tgz#a44c95237870b5e4f66f0aff948270df7ec9f277"
integrity sha512-s9LeTXee2J+7qXQHJ1EHPbK4Mk5ZU820Wrw+EOxDRQcn2Tay4n+SvZaqJa6T8UpKu5mIomSh6nXoyuP1j2DzUw==
js-library-detector@^5.7.0:
version "5.7.0"
resolved "https://registry.yarnpkg.com/js-library-detector/-/js-library-detector-5.7.0.tgz#27199e0728273de9333d69b2be92f144cad94380"
integrity sha512-pUHR7ryXqiew2agkQ3NppopqJDi5qkJtI86PyQ9LLtg1iGzwIsMz+QNq3ky5bPogSie7AkL/xvcObXu3Veh61Q==

js-tokens@^1.0.1:
version "1.0.3"
Expand Down