-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
client(lr): add lightrider report-generator #8197
Conversation
…rates a report-generator for lightrider.
@@ -57,14 +57,14 @@ class ReportGenerator { | |||
* - the score value of the audit | |||
* | |||
* @param {LH.Result} lhr | |||
* @returns {string} | |||
* @return {string} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe when the dust settles, a tincy bit more background on why we're doing this would be helpful :)
I vaguely remember a discussion on a prior PR where we needed this for devtools about how the splitting of report generator would help LR maybe?
@@ -0,0 +1,25 @@ | |||
/** | |||
* Copyright 2019 Google Inc. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @override | ||
*/ | ||
getReportHtml() { | ||
// @ts-ignore This is only called in browser in Lightrider where this exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this comment. It's called in the browser as in the WRS devtools script? Or it's called in the browser as-in PSI front-end?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's called in the browser as-in something similar to the PSI front-end.
This ui-features is packaged with a report-generator for anyone trying to render a report internally on a front-end. In order to do that they need this overrided getReportHtml since we can't just outerHTML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhhhhh OK, the "in Lightrider" made that a bit confusing for me :)
this is happening in the consumers of the LR response just like in DevTools
/* global ReportUIFeatures */ | ||
|
||
/** | ||
* Extends ReportUIFeatures to use the saved report from a browserified ReportGenerator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"saved report" meaning the generic report assets, right? not like a saved report instance of a particular run that's somehow bundled in a way I don't know about :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh I think I get what you're asking? It is just me trying to say that this is used to get report HTML via a report generator and this.json instead of outerHTML like a reg report.
my understanding is @exterkamp needed a standalone report generator independent of the PSI UI so that it could render saved reports after the fact. He can correct me/fill in any other details, though. I was hoping the devtools and this one could be shared, but devtools wanted it to use the cached resources internal to devtools rather than bundle the whole thing. Ideally we could share something, but the files are so short and simple, it feels like anything we come up with is just going to be longer and more complicated than duplicating the file. A test isn't the worst idea, though, @exterkamp. Otherwise we could break you and we wouldn't find out until much later when you do the next import. Maybe we should file an issue? We've had an issue (in our heads, not filed, I believe) for a while now that we should take the puppeteer tests that validate that the extension and viewer can render a report correctly by having them run and then verifying the report is correct. Each does this separately; we could pull out the report verification part so it can be shared between them and then add the lr report generator to the mix. |
build/build-lightrider.js
Outdated
async function copyAssets() { | ||
return cpy([ | ||
'clients/lightrider/lightrider-ui-features.js', | ||
'lighthouse-core/lib/file-namer.js', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you also want to copy all the other renderer assets LR has copied out manually right now? Or wait on this because you don't want to rewrite the matching bash script on the other side :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this works for now, because that whole file portion is copied wholesale. Simplifying all of this syncing should def be a bug to track.
can you give us an update on what this is blocked on @exterkamp |
*/ | ||
getReportHtml() { | ||
// @ts-ignore ReportGenerator is put on window by the host page. | ||
return window.ReportGenerator.generateReportHtml(this.json); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the long term i'm interested in changing ReportUIFeatures.getReportHtml()
to be this instead. and we'd always ship reportgenerator inside of the HTML report.
but that requires some work. so it'll wait.
So based on the changes in #8228 I have modified the internal renderer to use that & the report-generator and therefore lgithrider-ui-features and file-namer are not needed at this time. So this should only make a report-generator for lr, and that should be all we need at this point in time. I was blocked by confusion around how we should render in Lightrider. But Paul cleared it up with his PR. |
Okay so I think I finally have this organized: report-generator only:
new™️ psi renderer uses these files:
current psi renderer uses these files:
The method of report-generating for Lightrider will transition to using this new LR report-generator for now. In the future, we may re-add a lightrider-ui-features + a new api to render reports more easily. PSI will move to a new psi renderer package that will include psi.js and not include report-ui-features. This will allow PSI and Lightrider to render reports simultaneously with 1 set of lib files, using 2 subsets of files. |
Summary
Add new build script to clients/ to build a report-generator for LR
and override ui-featuresto allow LR to use new report-generator.Also change
returns
->return
in report-generator b/c linter.