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

client(lr): add lightrider report-generator #8197

Merged
merged 14 commits into from
Apr 16, 2019
Merged

client(lr): add lightrider report-generator #8197

merged 14 commits into from
Apr 16, 2019

Conversation

exterkamp
Copy link
Member

@exterkamp exterkamp commented Apr 11, 2019

Summary
Add new build script to clients/ to build a report-generator for LR and override ui-features to allow LR to use new report-generator.

Also change returns -> return in report-generator b/c linter.

@@ -57,14 +57,14 @@ class ReportGenerator {
* - the score value of the audit
*
* @param {LH.Result} lhr
* @returns {string}
* @return {string}
Copy link
Member

Choose a reason for hiding this comment

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

👍

clients/lightrider/lightrider-ui-features.js Outdated Show resolved Hide resolved
clients/lightrider/lightrider-ui-features.js Outdated Show resolved Hide resolved
clients/lightrider/lightrider-file-namer.js Outdated Show resolved Hide resolved
clients/lightrider/lightrider-ui-features.js Outdated Show resolved Hide resolved
build/build-lr-files.js Outdated Show resolved Hide resolved
Copy link
Collaborator

@patrickhulce patrickhulce left a 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.
Copy link
Collaborator

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.
Copy link
Collaborator

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?

Copy link
Member Author

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.

Copy link
Collaborator

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.
Copy link
Collaborator

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 :)

Copy link
Member Author

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.

lighthouse-core/lib/file-namer.js Show resolved Hide resolved
@brendankenny
Copy link
Member

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?

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.

async function copyAssets() {
return cpy([
'clients/lightrider/lightrider-ui-features.js',
'lighthouse-core/lib/file-namer.js',
Copy link
Member

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 :)

Copy link
Member Author

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.

clients/lightrider/lightrider-ui-features.js Outdated Show resolved Hide resolved
clients/lightrider/lightrider-ui-features.js Outdated Show resolved Hide resolved
@exterkamp exterkamp changed the title client(lr): add lightrider report-generator and ui-features [DNM] client(lr): add lightrider report-generator and ui-features Apr 12, 2019
@brendankenny
Copy link
Member

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);
Copy link
Member

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.

@exterkamp
Copy link
Member Author

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.

@exterkamp exterkamp changed the title [DNM] client(lr): add lightrider report-generator and ui-features client(lr): add lightrider report-generator Apr 15, 2019
@exterkamp exterkamp changed the title client(lr): add lightrider report-generator [DNM again :(] client(lr): add lightrider report-generator Apr 16, 2019
@exterkamp
Copy link
Member Author

exterkamp commented Apr 16, 2019

Okay so I think I finally have this organized:

report-generator only:

report-generator.js

new™️ psi renderer uses these files:

util.js
dom.js
details-renderer.js
crc-details-renderer.js
category-renderer.js
pwa-category-renderer.js
performance-category-renderer.js
report-renderer.js
psi.js
snippet-renderer.js
(notice lack of report-ui-features, as it doesn't need it)

current psi renderer uses these files:

util.js
dom.js
details-renderer.js
crc-details-renderer.js
category-renderer.js
pwa-category-renderer.js
performance-category-renderer.js
report-renderer.js
psi.js
report-ui-features.js
file-namer.js
lightrider-ui-features.js
report-generator.js

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.

@exterkamp exterkamp changed the title [DNM again :(] client(lr): add lightrider report-generator client(lr): add lightrider report-generator Apr 16, 2019
@paulirish paulirish mentioned this pull request Apr 16, 2019
67 tasks
package.json Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants