-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Conversation
build/build-report.js
Outdated
@@ -96,8 +96,32 @@ async function buildEsModulesBundle() { | |||
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`]: ` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems ridiculous but I can't think of a better way to do accomplish this. Better to be ridiculous than to overengineer it :)
For readability, would this string be better in a variable than inline? Alternatively should we make a build/shims/
directory and rollupPlugins.alias()
i18n-module.js
to point there? I'm assuming that would work but it may not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a shims/i18nmodule.js
sg. then it's at least lintable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i tried a shim file and it's terrible. ends up creating more cruft. so.. leaving as is.
(extracted to a var actually)
We're in a funny situation, so here's the backstory...
node ./node_modules/.bin/tsc --allowJs --declaration --emitDeclarationOnly ./dist/report/bundle.esm.js
<== the ESM version!{}
for devtools to save 30kb.A more reasonable solution is generating a ~lighthousereportrenderer.types.d.ts file the "right" way.
tsc
can generate quality.d.ts
files - but its 1:1 against source files.There are a few projects that can consume all of those and generate a single file. 1)
dts-gen
by microsoft is at the module level and doesnt really make sense for this usecase. (probably). 2) dts-generator isn't maintained and dun work. 3) dts-bundle is also dead. 4) dts-bundle-generator seems like the best one, but unfortunately it explicitly doesnt support composite projects. To me, situation is enough justification to justify oursed
BS plus this unattractive solution. Ah well, I expect this situation will improve with the arch refactor + dts-bundle-generator adding support.also there's https://api-extractor.com/pages/setup/invoking/ which does this.
an alternative is to only compile with TSC and do declaration emitting. and don't bundle into 1 file, but.. that may not be an option for this reportrenderer case.