-
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
core(runner): split lhr, artifacts return, respect output type #4999
Conversation
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.
probably easier to still have the report generated outside of runner so that the devtools bundle doesn't need it (arguably cleaner that way than pruning via browserify, otoh doing it the other way moves us closer to the various background scripts just using the node interface)
also the lighthouse-background side will currently be broken
also, FWIW, "core(runner): respect output setting" is definitely not the most important change happening here :P |
what's the most important change?
I see, so against the feature existing or just proposing index.js? |
yes this was meant to be proposal, added [PROPOSAL] |
One option: add browserify ignore for lib/format-output.. and always check if it's truth before using it. But I should look closer before jumping to a solution |
splitting up the return value from the module :)
oh, I think 👍 👍, just |
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.
seems like you can add '../report/v2/report-generator' to browserify ignore, and we should be good.
and update the lh-bg files to request their intended output
lighthouse-core/index.js
Outdated
@@ -46,10 +46,12 @@ function lighthouse(url, flags = {}, configJSON) { | |||
// kick off a lighthouse run | |||
return Runner.run(connection, {url, config}) | |||
.then((lighthouseResults = {}) => { | |||
lighthouseResults.lhr = lighthouseResults.lhr || {}; |
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.
rename to runnerResult
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.
done
lighthouse-cli/run.js
Outdated
const artifacts = results.artifacts; | ||
delete results.artifacts; | ||
return saveResults(results, artifacts, flags).then(_ => results); | ||
return saveResults(results, flags).then(_ => results); |
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.
rename results
to runnerResult
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.
done
lighthouse-cli/run.js
Outdated
* @param {!LH.Flags} flags | ||
* @return {Promise<void>} | ||
*/ | ||
function saveResults(results, artifacts, flags) { | ||
function saveResults(results, flags) { | ||
const {lhr, artifacts} = results; |
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.
rename results
to runnerResult
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.
done
lighthouse-core/runner.js
Outdated
@@ -17,16 +17,15 @@ const fs = require('fs'); | |||
const path = require('path'); | |||
const URL = require('./lib/url-shim'); | |||
const Sentry = require('./lib/sentry'); | |||
const getFormattedReport = require('./lib/format-output').createOutput; |
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.
nearly all our source files are defined as nouns, so we should do lhr-formatter.js
or something.
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 +1 on the proposal.
extension needs it, though, it just (currently) uses it in |
lighthouse-core/lib/format-output.js
Outdated
@@ -0,0 +1,72 @@ | |||
/** |
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.
live under report/
?
aight folks ready for re-review! |
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.
implementation looks great! But bikeshedding...
-
do we want to refer to the final report string as the
formattedReport
instead of thegeneratedReport
? That makes a certain amount of sense, but I'd like to get rid of the one we don't use because they sound very similar (e.g. if we useformattedReport
, there shouldn't be areport-generator.js
:) -
one way of doing this would be to merge
report-formatter.js
andreport-generator.js
in this PR, a single file that makes reports, but kick out thefs.readFileSync()
calls andreportJs
/reportCss
/reportTemplates
getters to a different file that's just likehtml-report-assets.js
or whatever and we canbrowserify.ignore()
that file
/** | ||
* Creates the results output in a format based on the `mode`. | ||
* @param {LH.Result} lhr | ||
* @param {string} outputMode |
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.
'html'|'csv'|'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.
done
resolved on
great idea, done! 👍 |
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 love this
It's a party. |
jumped on @brendankenny's suggestion to make
{lhr, artifacts}
and a breaking feature in the process (#4333), having node module respect theoutput=html
settingalso I had a bug in config with default settings when undefined (mostly happens in tests, but could be user explicitly passing undefined) so fixing that was good 👍