gomuks icon indicating copy to clipboard operation
gomuks copied to clipboard

web/intl: replace homegrown join functions with Intl

Open JadedBlueEyes opened this issue 1 year ago • 3 comments

This replaces the homegrown list-join functions with react-intl, which uses the browser Intl API under the hood. This is a first step to multilingual support.

This has no user-visible effect at the moment, as the locale is hardcoded to English.

JadedBlueEyes avatar Dec 08 '24 17:12 JadedBlueEyes

That takes 60kb of js 🙀

tulir avatar Dec 08 '24 17:12 tulir

Damn. I would expect that it shoud tree-shake just about all of that! The actual code under the hood isn't too complex - we're only really using https://github.com/formatjs/formatjs/blob/main/packages/intl/src/list.ts, so we could depend on that package directly or write our own wrapper over it.

JadedBlueEyes avatar Dec 08 '24 17:12 JadedBlueEyes

image

Actual file size diff is -0.06kb in one bundle, +60.34kB in another. Most of this is coming from their ICU messageformat parser, which we don't use here.

image

Using their provided method to remove that brings that diff down to +20.25 kB. Note that this will require precompiling the strings if we want to keep this setup, see https://formatjs.github.io/docs/guides/advanced-usage/

JadedBlueEyes avatar Dec 08 '24 19:12 JadedBlueEyes