Skip to content

refactor: Replace date-fns with dayjs for smaller bundle size #21

Description

@Abdelkaderbzz

Description

Replace date-fns with dayjs for date/time handling to reduce bundle size while maintaining functionality.

Comparison

Feature date-fns dayjs
Bundle Size ~75KB ~2KB
Tree-shakeable Yes Plugin-based
Immutable Yes Yes
i18n support Yes Yes (plugins)
API style Functional Chainable

Implementation

1. Install dayjs

bun add dayjs
bun remove date-fns

2. Migration example

// Before (date-fns)
import { format, parseISO } from 'date-fns';
const formatted = format(parseISO(date), 'PPP');

// After (dayjs)
import dayjs from 'dayjs';
const formatted = dayjs(date).format('MMMM D, YYYY');

3. Add locale support if needed

import dayjs from 'dayjs';
import 'dayjs/locale/ar';

dayjs.locale('ar'); // Set locale globally or per instance

Files to update

  • All files importing from date-fns
  • package.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions