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(stacks): match against js-lib-detector with id property #9888

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions lighthouse-core/lib/stack-collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ const libDetectorSource = fs.readFileSync(
/** @typedef {false | {version: string|null}} JSLibraryDetectorTestResult */
/**
* @typedef JSLibraryDetectorTest
* @property {string} icon Essentially an id, useful if no npm name is detected.
* @property {string} id
* @property {string} icon
* @property {string} url
* @property {string|null} npm npm module name, if applicable to library.
* @property {function(Window): JSLibraryDetectorTestResult | Promise<JSLibraryDetectorTestResult>} test Returns false if library is not present, otherwise returns an object that contains the library version (set to null if the version is not detected).
*/

/**
* @typedef JSLibrary
* @property {string} id
* @property {string} name
* @property {string} icon
* @property {string|null} version
Expand All @@ -53,6 +55,7 @@ async function detectLibraries() {
const result = await lib.test(window);
if (result) {
libraries.push({
id: lib.id,
name: name,
icon: lib.icon,
Copy link
Member

Choose a reason for hiding this comment

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

we can drop icon from here now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated 👍

version: result.version,
Expand Down Expand Up @@ -80,7 +83,7 @@ async function collectStacks(passContext) {

return jsLibraries.map(lib => ({
detector: /** @type {'js'} */ ('js'),
id: lib.npm || lib.icon,
id: lib.id,
name: lib.name,
version: lib.version || undefined,
npm: lib.npm || undefined,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"intl-messageformat": "^4.4.0",
"intl-pluralrules": "^1.0.3",
"jpeg-js": "0.1.2",
"js-library-detector": "^5.5.0",
"js-library-detector": "^5.6.0",
"jsonld": "^1.5.0",
"jsonlint-mod": "^1.7.5",
"lighthouse-logger": "^1.2.0",
Expand Down