Skip to content

Commit

Permalink
clients(psi): expose the swapLocale types (#14062)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish authored and connorjclark committed Jun 8, 2022
1 parent 7892760 commit 29e78d3
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions build/build-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,42 @@ async function buildFlowReport() {
}

async function buildEsModulesBundle() {
// Include the type detail for bundle.esm.d.ts generation
const i18nModuleShim = `
/**
* Returns a new LHR with all strings changed to the new requestedLocale.
* @param {LH.Result} lhr
* @param {LH.Locale} requestedLocale
* @return {{lhr: LH.Result, missingIcuMessageIds: string[]}}
*/
export function swapLocale(lhr, requestedLocale) {
// Stub function only included for types
return {
lhr,
missingIcuMessageIds: [],
};
}
/**
* Populate the i18n string lookup dict with locale data
* Used when the host environment selects the locale and serves lighthouse the intended locale file
* @see https://docs.google.com/document/d/1jnt3BqKB-4q3AE94UWFA0Gqspx8Sd_jivlB7gQMlmfk/edit
* @param {LH.Locale} locale
* @param {Record<string, {message: string}>} lhlMessages
*/
function registerLocaleData(locale, lhlMessages) {
// Stub function only included for types
}
export const format = {registerLocaleData};
`;

const bundle = await rollup.rollup({
input: 'report/clients/bundle.js',
plugins: [
rollupPlugins.commonjs(),
// Exclude this 30kb from the devtools bundle for now.
rollupPlugins.shim({
[`${LH_ROOT}/shared/localization/i18n-module.js`]:
'export const swapLocale = _ => {}; export const format = _ => {};',
[`${LH_ROOT}/shared/localization/i18n-module.js`]: i18nModuleShim,
}),
],
});
Expand Down

0 comments on commit 29e78d3

Please sign in to comment.