chore: Allow dynamic deferred loading of internationalization#4237
Draft
avinashbot wants to merge 1 commit intomainfrom
Draft
chore: Allow dynamic deferred loading of internationalization#4237avinashbot wants to merge 1 commit intomainfrom
avinashbot wants to merge 1 commit intomainfrom
Conversation
6af9e51 to
65f497e
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4237 +/- ##
==========================================
- Coverage 97.19% 97.18% -0.01%
==========================================
Files 886 889 +3
Lines 26021 26049 +28
Branches 9433 9438 +5
==========================================
+ Hits 25291 25317 +26
+ Misses 724 685 -39
- Partials 6 47 +41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
b380ceb to
107d893
Compare
107d893 to
a270b41
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Partial implementation of dynamically loaded internationalization. This lets us more readily embed the I18nProvider into performance-sensitive parts of the code (like the app layout toolbar) without worrying so much about added bundle size of the intl library, intl-messageformat (34.3 kB, 9.83 kB gzip) and the locale files (465kB, 68kB gzip). This also avoids dealing with any additional build-time considerations (intl-messageformat raises our bare minimum TypeScript version requirement, which we don't document publicly, though we do call out the raised minimum in our documentation).
The added cost is one asynchronously triggered full-application rerender.
"Dynamic loading" of the internationalization bundle isn't all that complicated, it's just a runtime import of
I18nFormatter(which this PR refactors out) preloaded with the appropriate locale file (which are already exposed under/messages/all.<locale>.js).Possible optimizations (either later in this PR or after release):
Wrapping the app rerender in a React transition: For React versions that support it, it avoids our rerender from blocking user actions and affecting web vitals.Removing ICU parser from the remote bundle (reference): If we can safely guarantee that the remote provider only accepts and handles pre-parsed AST-only strings, we can remove the parser from the dynamically loaded bundle and reduce the dynamic bundle's file size by 26.34 kB (7.1 kB gzip). But this is a non-blocking network request, so it's not high priority.See CR-253557644.Related links, issue #, if available: AWSUI-61508
How has this been tested?
Existing tests for locally (i.e. application) provided strings, additional tests for remote inclusion of logic will follow.
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.