refactor(deps): remove moment
dep and usage
#12611
Merged
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, but removing / replacing a large dep entirely.
chart.js
in the deps, so it instead got code-split into theReports
page bundle, see "Notes to Reviewers" belowFollow-up to #12097
Motivation
moment
has been deprecated since Sep 2020 and recommends using nativeIntl
or newer libraries that make use of nativeIntl
, such asluxon
andday.js
moment
is also a very large dependency and hence is ripe for pruning and replacement as wellshave off ~634KB / 260KB minified / 73KB gzipped from the main bundle by replacing ~15 LoC
Modifications
replace all usage of
moment
with regularDate
functionsvalueOf()
works the same way forDate
andmoment
diff
doesn't exist, but it's a one-liner helperformat
doesn't exist, but we can also use a simple helper for thatUpdate
argo-ui
to latest include refactor(deps)!: removemoment
dep and usage argo-ui#535. See full diff: argoproj/argo-ui@6de6bfe...54f36c7Verification
make start UI=true
View a specific node of a workflow;
workflow-node-info
looks correct to me. Screenshot:Bundle Analysis
before:
after:
Notes to Reviewers
moment
was removed as a dep in this PR from our own usage and fromargo-ui
's usage (argoproj/argo-ui#535), but apparently it is still depended on by the old version ofchart.js
in the deps, so it got code-split out to theReports
bundle from #12061.Future Work
chart.js
andreact-chartjs-2
to more modern versions with tree-shaking and no direct dependence onmoment