RFC: core(runner): move non-audit code to index and gather-runner#12393
RFC: core(runner): move non-audit code to index and gather-runner#12393brendankenny wants to merge 1 commit into
Conversation
|
I'm totally into this and think it rationalizes things quite a bit. The churn doesnt feel too bad from here. i can't speak to how this plays into the FR world, but it feels like a partial win there. i'll defer to patrick, clearly. general 👍 from me
eh. i expect the churn is a bit much. i'm fine punting this for a while
yeah... in fact.. this PR lays perfect groundwork to finally do cli(lifecycle): introduce report-only runs · #4210! we'd then have core/index calling
yeah i'm a 👎 on this. i like our CLI being as dumb as we can allow. |
|
Things I love:
Things I don't love:
I think those are all resolved while preserving my favorite parts if instead of moving the logic directly to
I've been thinking we really want 3 modules:
Much of the CLI work belongs in a node package and these core utilities you mention belong in a node package, but I definitely wouldn't want to remove capability from node module use, in general I think we should be aligning even more the CLI and node capabilities.
I agree not worth it.
This is kinda close to my counter-proposal above.
This seems annoying from a shared FR perspective and not sure it's that valuable in the short term, especially given the test surface changes. Maybe worth tackling as part of a legacy winddown once FR is default? Paul seems excited about this, but I'm not sure what need we've really had for report only mode lately :)
👍 see above :D |
yeah, i was thinking the same. it might as well get a proper name. possibilities:
tbh the only need is when we're hacking on the report. superfast iteration of just JSON->HTML repeatedly. (my hack has been |
|
Should we take another look at this during next eng sync? |
|
This reorg still seem good, but so much is changed since this was opened that we likely wouldn't use any of the code here so closing |
Externally we've long had a separation between gathering and auditing that's beneficial both conceptually and practically (for things like testing). Internally, though,
runner.jshas mixed things up, being responsible for auditing as well as dealing with loading/saving-GAstages, constructing aDriverfor the gathering stage, etc.This PR takes the general "marshalling" code and bumps it up to
lighthouse-core/index.jsand moves the gathering-specific code over togather-runner.js, leavingrunner.jswith auditing and lhr/report generation.The general move was last discussed in #11623 (review), and includes uninverting the
gatherFncallback to instead passing inartifactsdirectly as discussed there.Because this is internally rearranging things, smoke tests are all passing, and with the changes to the FR runners included here (popping the gathering code out of callbacks and running it in place) all the FR and other unit tests are passing except
runner-testandgather-runner-test, which will need to have some tests moved to different files. I wanted to get feedback before I embarked on that part :)Easier to review (and significantly shorter) if whitespace is ignored due to the moved
try/catchindentation changes.Other things that could be good but not currently included:
runner.jstoaudit-runner.jsindex.js.Runner.run()would return just an lhr, andlighthouse()inindex.jswould be the one to put together the{lhr, artifacts, report}RunnerResult. This would require a bit more test changes due to theRunner.run()return type change.Other considered ideas that we probably shouldn't do but included in case they jog anyone's thoughts:
audit()method inindex.js. This would let FR runners use our core entry point instead of callingRunnerdirectly. Something like this seems worthwhile but probably better to think about when we start nailing down the FR module API.runner. Doesn't seem worth it because the LHR is the only audit output we ever care about, and there's some internal details (like handling ICU types beforei18n.replaceIcuMessages()is called) that are currently encapsulated but would have to be exposed-GAartifact loading/saving out oflighthouse-core/altogether and move them tolighthouse-cli/. This would bringlighthouse-corecloser to the actual core shared between all our clients (and prevent unexpected bundle includes like cli(asset-saver): print one devtoolsLog event per line #12348 (comment)), but it stretches the definition of "CLI" since we'd want node modules to still be able to use it. Our testing also often relies onauditModebeing available to load artifacts from disk, which would have to be done manually instead. Doesn't seem worth it (for now?).