Skip to content
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

clients(psi): expose the swapLocale types #14062

Merged
merged 7 commits into from
Jun 7, 2022
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions build/build-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,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: [],
};
}

paulirish marked this conversation as resolved.
Show resolved Hide resolved
/**
* 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({
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