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

web/intl: replace homegrown join functions with Intl #546

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

JadedBlueEyes
Copy link
Contributor

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.

@tulir
Copy link
Owner

tulir commented Dec 8, 2024

That takes 60kb of js 🙀

@JadedBlueEyes
Copy link
Contributor Author

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
Copy link
Contributor Author

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 JadedBlueEyes marked this pull request as draft December 11, 2024 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants