Closed calebeby closed 2 years ago
Latest commit: 9377898b108f21a874f0915d788c4d56362505be
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Overview
There is a lot of new code here! Happy to do a video walkthrough if that is helpful.
Here is what stayed mostly the same:
createUrlFilter
to a separate file without changing it.Everything else was rewritten:
lighthouse.ts
now manages a pool ofworker_threads
(Node's version of web workers). Each worker thread runs thelighthouse-worker.ts
file. It figures out which worker is available to handle a lighthouse run, and tells it to run it.lighthouse-worker.ts
launches a chrome instance, and runs lighthouse whenever it is requested to.async-iterator-queue
is a data structure that has an async iterator that loops through its items, yielding as many as it has. It will pause when it runs out of items. Aspush
is called more, the new items are yielded as well. Whenfinish
is called, the iterator exits. It is used to adapt the simplecrawler output to an async iterator for use inmain.ts
main.ts
wires everything together. It is called from thecli
code. It manages the state and pulls in the URLs from the crawler, requests a worker fromlighthouse.ts
, and sends the URL to the worker. Then it takes the result and updates the state, and passes the result to theOutputWriter
.output-writer/index.ts
contains theOutputWriter
interface. Right now there is a CSVOutputWriter
and a stub for agoogle-sheets
OutputWriter
. It also has a function to merge severalOutputWriter
s together so the code inmain
can pretend as though there is only oneOutputWriter
even when there are distinct outputs.This PR targets
next
. Here are other upcoming changes I'm hoping to do in separate PR's before release:google-sheets
output formatsimplecrawler
tsc
For review
I would suggest turning off whitespace changes, which will help just a little bit. Also GitHub has the nice new file tree on the left of the review page, it is probably helpful to use that.
Testing
Create a baseline lighthouse run to compare against:
git checkout main
npm i
npm run build
npm i -g lighthouse-parade
npm link
lighthouse-parade ...
Try the new changes
git checkout lighthouse-node-api
npm i
npm run build
npm link
lighthouse-parade ...
Then you can compare the generated CSV data and make sure the differences are minor. The new CSV format won't work with the existing google sheets template, so you can just review the CSV directly or in Numbers or something for now.