-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
refactor(ui): replace moment-timezone
with native Intl
#12097
Merged
terrytangyuan
merged 2 commits into
argoproj:master
from
agilgur5:refactor-remove-moment-tz
Nov 5, 2023
Merged
refactor(ui): replace moment-timezone
with native Intl
#12097
terrytangyuan
merged 2 commits into
argoproj:master
from
agilgur5:refactor-remove-moment-tz
Nov 5, 2023
Conversation
This file contains 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
- `moment-timezone` is a very large dependency, currently the second largest in the codebase - `moment` is [deprecated](https://momentjs.com/docs/#/-project-status/) and recommends using `Intl`, which is supported in all modern browsers (c.f. [MDN compatibility matrix](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#browser_compatibility)) - `moment` was announced as deprecated in Sep 2020, so we should be more careful with commits like 8e7c734 that introduce new dependencies - rather than code-splitting it, we can just replace it with native code in the one place it's used - equivalently get a list of all timezones from the browser - equivalently convert ISO strings with TZ (thanks Canada) - remove `useEffect` code that is no longer needed and should've been a `useMemo` - shave off 775KB / 760KB minified / 36KB gzipped Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
agilgur5
added
type/dependencies
PRs and issues specific to updating dependencies
area/ui
javascript
Pull requests that update Javascript dependencies
labels
Oct 28, 2023
agilgur5
commented
Oct 28, 2023
isubasinghe
approved these changes
Oct 28, 2023
Signed-off-by: Anton Gilgur <4970083+agilgur5@users.noreply.github.com>
@terrytangyuan any chance you could merge this soon? Its already been approved and is getting merge conflicts with dependabot 😕 |
terrytangyuan
approved these changes
Nov 5, 2023
terrytangyuan
pushed a commit
that referenced
this pull request
Nov 27, 2023
Signed-off-by: Anton Gilgur <agilgur5@gmail.com> Signed-off-by: Anton Gilgur <4970083+agilgur5@users.noreply.github.com>
This was referenced Feb 1, 2024
This was referenced Feb 12, 2024
19 tasks
8 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/ui
javascript
Pull requests that update Javascript dependencies
type/dependencies
PRs and issues specific to updating dependencies
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.
Partial fix for #12059; this replaces a dep instead of code-splitting it out
Motivation
moment-timezone
is a very large dependency, currently the second largest in the codebasemoment
is deprecated and recommends usingIntl
, which is supported in all modern browsers (c.f. MDN compatibility matrix)moment
was announced as deprecated in Sep 2020; we should be more careful with PRs like feat: allow switching timezone for date rendering. Fixes #3474 #10120 that introduce new dependenciesshave off 775KB / 760KB minified / 36KB gzipped
Modifications
rather than code-splitting
moment-timezone
, we can just replace it with native code in the one place it's usedremove
useEffect
code that is no longer needed (and really should've been auseMemo
)Verification
Confirmed that behavior was equivalent on two known TZs (NYC and LA). Screenshots:
Bundle Analysis
before removal of
moment-timezone
:after removal of
moment-timezone
: