Open brendankenny opened 3 years ago
for next steps: happy to open a WIP PR for https://github.com/GoogleChrome/lighthouse/compare/master...shared-i18n for more concrete discussion, or we can save for the next eng sync
Possible dir structure:
lighthouse-core/lib
to lib
lib/shared
, lib/node
, etclighthouse-logger
to lib/shared/lighthouse-logger
.
tl;dr: our formatting code +
intl-messageformat
is relatively small. At the very least we can rearrange it to easily ship withswap-locale
(#10148), but we should seriously consider shipping it with the main report as well.This came up in https://github.com/GoogleChrome/lighthouse/pull/10148#discussion_r713454527 most recently, but also just came up in the context of the flow-report (https://github.com/GoogleChrome/lighthouse/pull/13034#discussion_r708637669). We've also had a few instances where we've wanted to format strings in the standalone report with replacement values and haven't been able to.
Starting with concrete plans and moving to more fanciful ideas:
move formatting code to a new directory so it can be easily shared by core and report-adjacent code. This solves the
tsc
issues in https://github.com/GoogleChrome/lighthouse/pull/10148#discussion_r713454527, and makes the rolluping more straightforward: it's not reaching deep in core for files to bundle and it's clearer from file location that what's imported/required needs to be kept compatible across environments.shared/localization/
isIcuMessage
,getFormatted
,replaceIcuMessages
, etc)path
orlighthouse-logger
)registerLocaleData
seems 👍format.js
bundle. The swap-locale bundle is already down to 34KiB (10KiB after gzip) just droppingpath
andlighthouse-logger
, should be smaller without the extrastr_
/UIStrings functionality that will be in a different file now, and will be even smaller with no swap-locale (which means no_.get
/_.set
, another 4+KiB each)format.js
, but laterintl-messageformat
versions ship ESM builds. They are bigger overall, but that means they can be tree shaken, so it's possibly a win.'{replacement}'
and will have to be updated and/or dealt with so old LHRs aren't brokenflow-report
. No reason to artificially limit the text we want to show. Even if we only got it down to 25KiB (w/o gzip) that's tiny compared to a series of LHRs :)