-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
deps: remove intl polyfill #12426
deps: remove intl polyfill #12426
Conversation
.github/workflows/ci.yml
Outdated
@@ -87,10 +87,10 @@ jobs: | |||
# Depth of at least 2 for codecov coverage diffs. See https://github.com/GoogleChrome/lighthouse/pull/12079 | |||
fetch-depth: 2 | |||
|
|||
- name: Use Node.js 12.x |
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.
just updating to demonstrate that everything works as expected in the current node LTS (14). Otherwise, there's a few lookupLocale
tests that fail in node 12 because they all return 'en'
.
If we maintain Node 12 support, we could e.g. unit test on Node 12 and node 14, and assert either the correct locale is returned or we're in a small-icu
build of node and a warning was logged.
This is ready for review. In addition to the log messages linking to the |
this should wait on #12513 because we should have a test for Node 12 behavior (warning that it's running with |
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.
lgtm
readme.md
Outdated
@@ -26,6 +26,7 @@ | |||
* [Can I configure the lighthouse run?](#can-i-configure-the-lighthouse-run) | |||
* [How does Lighthouse use network throttling, and how can I make it better?](#how-does-lighthouse-use-network-throttling-and-how-can-i-make-it-better) | |||
* [Are results sent to a remote server?](#are-results-sent-to-a-remote-server) | |||
* [How do I get localized Lighthouse results?](#how-do-i-get-localized-lighthouse-results) |
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.
bad link
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.
bad link
haha, how on earth did you notice that :)
thanks!
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 few suggestions…
the plan is to have a release with these warnings (and the 'en' fallback) and next major will remove node 12 support and we'll also then remove all the ifNode12() checks in tests, yes?
lighthouse-core/lib/i18n/i18n.js
Outdated
if (!closestLocale) { | ||
// Log extra info if we're pretty sure this version of Node was built with `--with-intl=small-icu`. | ||
if (Intl.NumberFormat.supportedLocalesOf('es').length === 0) { | ||
log.warn('i18n', 'Requested locale not available in this version of node. The `full-icu` npm module can provide additional locales. See https://nodejs.org/api/intl.html#intl_providing_icu_data_at_runtime for help.'); |
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.
let's link to https://github.com/GoogleChrome/lighthouse/blob/master/readme.md#how-do-i-get-localized-lighthouse-results-via-the-cli instead?
This is probably the first error message that node 12 users will see so we'll route them to our FAQ first.
readme.md
Outdated
@@ -442,6 +443,10 @@ Read more in our [guide to network throttling](./docs/throttling.md). | |||
Nope. Lighthouse runs locally, auditing a page using a local version of the Chrome browser installed on the | |||
machine. Report results are never processed or beaconed to a remote server. | |||
|
|||
### How do I get localized Lighthouse results via the CLI? | |||
|
|||
Starting in Lighthouse 8.0, the `Intl` API is no longer polyfilled. If you're using Node 13 or later there should be no issue because Node is now [built with `full-icu` by default](https://nodejs.medium.com/node-js-12-to-lts-and-node-js-13-is-here-e28d6a4a2bd#9514), but if you're somehow stuck with `small-icu` and see Lighthouse log messages about your locale not being available, you can manually install ICU data by using the [`full-icu`](https://www.npmjs.com/package/full-icu) module and the [`--icu-data-dir` node flag](https://nodejs.org/api/intl.html#intl_providing_icu_data_at_runtime) at launch. |
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.
Starting in Lighthouse 8.0, the `Intl` API is no longer polyfilled. If you're using Node 13 or later there should be no issue because Node is now [built with `full-icu` by default](https://nodejs.medium.com/node-js-12-to-lts-and-node-js-13-is-here-e28d6a4a2bd#9514), but if you're somehow stuck with `small-icu` and see Lighthouse log messages about your locale not being available, you can manually install ICU data by using the [`full-icu`](https://www.npmjs.com/package/full-icu) module and the [`--icu-data-dir` node flag](https://nodejs.org/api/intl.html#intl_providing_icu_data_at_runtime) at launch. | |
Starting in Lighthouse 8.0, Lighthouse relies entirely on native `Intl` support and no longer uses an `Intl` polyfill. If you're using Node 13 or later, there should be no issue because Node is now [built with `full-icu` by default](https://nodejs.medium.com/node-js-12-to-lts-and-node-js-13-is-here-e28d6a4a2bd#9514). | |
However, if you're using Node 12 (when `small-icu` was the default) or another `small-icu` situation, you may see Lighthouse log messages about your locale not being available. To remedy this, you can upgrade to Node 14+ or manually install ICU data by using the [`full-icu`](https://www.npmjs.com/package/full-icu) module and the [`--icu-data-dir` node flag](https://nodejs.org/api/intl.html#intl_providing_icu_data_at_runtime) at launch. |
yes indeed |
Remove
intl
in Lighthouse's next major releasefull-icu
by defaultintl
polyfill is archived and was last updated almost five years ago. Already out of date on some languages and severalIntl
featuressmall-icu
is to save disk space (e.g. for use in a docker image), which we immediately negate by including a 25 MiB polyfill :)I suggest we lose the dependency:
small-icu
, we should honor the choice of keeping a slim build and just supporten
as advertised. We can log that we're doing so.small-icu
build (if we still want to support Node 12 in LH8), we can advise the use of the officialfull-icu
package, which downloads the latest ICU files and gives instructions on how to get Node to use them.full-icu
is also about half the size of theintl
polyfill :)More Node ICU background: https://nodejs.org/api/intl.html