diff --git a/build/build-report.js b/build/build-report.js index 2b16c5173de0..5f172b83b3c8 100644 --- a/build/build-report.js +++ b/build/build-report.js @@ -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: [], + }; +} + +/** + * 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} 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, }), ], });