Skip to content

Commit

Permalink
core(stacks): match against js-lib-detector with id property (#9888)
Browse files Browse the repository at this point in the history
  • Loading branch information
housseindjirdeh authored and paulirish committed Oct 30, 2019
1 parent 7fab7e2 commit 3f74f33
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const expectations = [
Stacks: [{
id: 'jquery',
}, {
id: 'jquery',
id: 'jquery-fast',
name: 'jQuery (Fast path)',
}, {
id: 'wordpress',
Expand Down
9 changes: 5 additions & 4 deletions lighthouse-core/lib/stack-collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ 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
* @property {string|null} npm
*/
Expand All @@ -53,8 +54,8 @@ async function detectLibraries() {
const result = await lib.test(window);
if (result) {
libraries.push({
id: lib.id,
name: name,
icon: lib.icon,
version: result.version,
npm: lib.npm,
});
Expand All @@ -80,7 +81,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
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4679,10 +4679,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.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/js-library-detector/-/js-library-detector-5.5.0.tgz#3cf17128f6eaaf594d3d6b4c631d18eca059bfdc"
integrity sha512-rLRizuKBAYFmCQM7Efjdbf8u8EoJnfuTlKYUBLQ/2bj9Raw2tr09guQoto/4NIOGmpAYLrzJQ0fmPUqxABCM5w==
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-tokens@^1.0.1:
version "1.0.3"
Expand Down

0 comments on commit 3f74f33

Please sign in to comment.