Skip to content

Conversation

@TrevorBurnham
Copy link
Contributor

@TrevorBurnham TrevorBurnham commented Aug 22, 2025

Description

This PR replaces the date-fns dependency with dayjs, a more lightweight alternative. This should not affect any functionality. The intent is purely to reduce bundle size and, secondarily, node_modules weight.

Estimated performance impact

For a production site that doesn't use date-fns outside of Cloudscape, this change should reduce the size of the minified JavaScript bundle by ~40 KB, enough to improve page load times by ~10ms for a typical user.

How has this been tested?

All unit tests are passing. I haven't been able to run the integration tests on my machine, so please let me know if there are any issues with those.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.17%. Comparing base (59b27e4) to head (60c5338).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3786   +/-   ##
=======================================
  Coverage   97.17%   97.17%           
=======================================
  Files         856      856           
  Lines       25241    25276   +35     
  Branches     8939     8969   +30     
=======================================
+ Hits        24527    24562   +35     
- Misses        665      708   +43     
+ Partials       49        6   -43     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TrevorBurnham TrevorBurnham changed the title perf: Replace date-fns with dayjs feat: Replace date-fns with dayjs Sep 2, 2025
@TrevorBurnham TrevorBurnham force-pushed the dayjs branch 3 times, most recently from 9c8d018 to 42a8166 Compare September 5, 2025 01:48
@pan-kot
Copy link
Member

pan-kot commented Sep 10, 2025

Hi @TrevorBurnham ,

There is one failing unit test:

FAIL src/internal/utils/date-time/__tests__/format-date-localized.test.ts
  ● formatDateLocalized › handles invalid date strings by falling back to Date constructor

    RangeError: Invalid time value

      39 |     year: 'numeric',
      40 |     day: 'numeric',
    > 41 |   }).format(date.toDate());
         |      ^
      42 |
      43 |   if (isDateOnly) {
      44 |     return formattedDate;

@TrevorBurnham
Copy link
Contributor Author

@pan-kot Thanks! I've updated this branch.

@pan-kot
Copy link
Member

pan-kot commented Oct 22, 2025

@TrevorBurnham ,

There are integration tests failing with:

    Expected: "January 2018 — January 2018"
    Received: "December 2017 — December 2017"

@TrevorBurnham
Copy link
Contributor Author

@pan-kot I've updated and rebased the branch. I've tried to address the integration test issue, but I'm unable to run those tests on my machine, so please kick off the CI build to verify the fix.

@TrevorBurnham
Copy link
Contributor Author

I saw that the CI failed because the chart-components package has an implicit dependency on date-fns. I've submitted a small PR there to unblock this: cloudscape-design/chart-components#144

This PR replaces the date-fns dependency with dayjs, a more lightweight alternative.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants