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

Load the Intl.Segmenter and Intl.DurationFormat polyfills only if needed #2778

Merged
merged 5 commits into from
Nov 14, 2024

Conversation

sandhose
Copy link
Member

This removes around 200Kb of the main bundle.

It will still load the polyfill if needed (notably the previous Firefox ESR), but skips on modern browsers.

@sandhose sandhose requested a review from a team as a code owner November 14, 2024 11:35
@sandhose sandhose force-pushed the quenting/lazy-load-polyfills branch from 6492ce0 to ab3a322 Compare November 14, 2024 11:37
@sandhose sandhose changed the title Load the Intl.Segmenter polyfill only if needed Load the Intl.Segmenter and Intl.DurationFormat polyfills only if needed Nov 14, 2024
import { useTranslation } from "react-i18next";

import { ReactionIndicator } from "./ReactionIndicator";

const durationFormatter = new DurationFormat(undefined, {
const durationFormatter = new Intl.DurationFormat(undefined, {
Copy link
Member

Choose a reason for hiding this comment

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

This landed in Node 23, so we will need to polyfill the tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed! I also had to embed the translations in tests, as now the initializer waits for i18next to initialise now before continuing

Copy link
Member

Choose a reason for hiding this comment

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

Oh but your polyfill code should actually be doing this, ugh??

Copy link
Member Author

Choose a reason for hiding this comment

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

initializeBeforeReact isn't necessarily being run in tests

Verified

This commit was signed with the committer’s verified signature.
sandhose Quentin Gliech

Verified

This commit was signed with the committer’s verified signature.
sandhose Quentin Gliech

Verified

This commit was signed with the committer’s verified signature.
sandhose Quentin Gliech

Verified

This commit was signed with the committer’s verified signature.
sandhose Quentin Gliech

Verified

This commit was signed with the committer’s verified signature.
sandhose Quentin Gliech
@hughns hughns merged commit 137a53d into livekit Nov 14, 2024
7 checks passed
@hughns hughns deleted the quenting/lazy-load-polyfills branch November 14, 2024 18:07
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.

None yet

3 participants