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

deps: remove intl polyfill #12426

Merged
merged 5 commits into from
May 25, 2021
Merged

deps: remove intl polyfill #12426

merged 5 commits into from
May 25, 2021

Conversation

brendankenny
Copy link
Member

Remove intl in Lighthouse's next major release

  • No effect on bundled clients, only CLI and node usage
  • Node 13+ is now built with full-icu by default
  • The intl polyfill is archived and was last updated almost five years ago. Already out of date on some languages and several Intl features
  • the primary reason someone would now use e.g. small-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:

  • for almost everyone on Node 13+ there will be no change in behavior
  • for anyone on Node 13+ built with small-icu, we should honor the choice of keeping a slim build and just support en as advertised. We can log that we're doing so.
  • for anyone somehow stuck on Node 12 and a default small-icu build (if we still want to support Node 12 in LH8), we can advise the use of the official full-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 the intl polyfill :)

More Node ICU background: https://nodejs.org/api/intl.html

@brendankenny brendankenny requested a review from paulirish April 29, 2021 22:14
@brendankenny brendankenny requested a review from a team as a code owner April 29, 2021 22:14
@google-cla google-cla bot added the cla: yes label Apr 29, 2021
@google-cla google-cla bot added the cla: yes label Apr 29, 2021
@brendankenny brendankenny added 8.0 i18n internationalization thangs and removed cla: yes labels Apr 29, 2021
@google-cla google-cla bot added the cla: yes label Apr 29, 2021
@@ -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
Copy link
Member Author

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.

@brendankenny brendankenny mentioned this pull request Apr 29, 2021
17 tasks
@GoogleChrome GoogleChrome deleted a comment from mspaansen May 4, 2021
@GoogleChrome GoogleChrome deleted a comment from mspaansen May 4, 2021
@brendankenny brendankenny changed the title proposal: deps: remove intl polyfill deps: remove intl polyfill May 18, 2021
@brendankenny
Copy link
Member Author

This is ready for review. In addition to the log messages linking to the full-icu explanation when it looks like you're running a small-icu build of node, also added a readme faq entry.

@brendankenny
Copy link
Member Author

this should wait on #12513 because we should have a test for Node 12 behavior (warning that it's running with small-icu and what to do about it) and a few of our existing localization tests will only work as currently expected in Node 13+ with full-icu available

Copy link
Collaborator

@connorjclark connorjclark left a 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad link

Copy link
Member Author

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!

Copy link
Member

@paulirish paulirish left a 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?

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.');
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@brendankenny
Copy link
Member Author

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?

yes indeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants