-
Notifications
You must be signed in to change notification settings - Fork 125
Open
Milestone
Description
Summary
Replace moment.js with day.js to reduce JavaScript bundle size. moment.js is deprecated and significantly larger than modern alternatives.
Why
| Library | Size (minified + gzip) | Status |
|---|---|---|
| moment.js | ~67 KB | Deprecated, in maintenance mode |
| day.js | ~2 KB | Active development, similar API |
Bundle impact: ~65 KB reduction (moment.js is currently in the vendor chunk)
Current Usage
// src/react/utils/extendedMoment.js
import moment from 'moment';
const date = moment(timestamp).fromNow();Used for:
- Relative timestamps ("5 minutes ago")
- Date formatting in entries
- Locale-aware date display
Migration Path
// After
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(relativeTime);
const date = dayjs(timestamp).fromNow();Potential Issues
- Locale handling - day.js loads locales separately (good for bundle size, but needs explicit import)
- Plugin system - Some moment features require day.js plugins:
relativeTime- for.fromNow()localizedFormat- for locale-aware formattingutc- for UTC operations (if used)
- API differences - Minor, but need to verify all usages:
- Both use
.format(),.fromNow(),.diff() - day.js is immutable by default (moment mutates)
- Both use
Tasks
- Audit all moment.js usage in codebase
- Install day.js:
npm install dayjs - Update
src/react/utils/extendedMoment.js - Test all date displays across locales
- Remove moment.js:
npm uninstall moment - Verify bundle size reduction
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels