Skip to content

chore: import date-fns functions from subpaths instead of the barrel - #42093

Open
KevLehman wants to merge 4 commits into
developfrom
chore/date-fns-subpath-imports
Open

chore: import date-fns functions from subpaths instead of the barrel#42093
KevLehman wants to merge 4 commits into
developfrom
chore/date-fns-subpath-imports

Conversation

@KevLehman

@KevLehman KevLehman commented Sep 10, 2026

Copy link
Copy Markdown
Member

Proposed changes (including videos or screenshots)

Meteor's bundler (standard-minifier-js) does not tree-shake (see docs/bundle-optimization-react-aria.md). Every import { format } from 'date-fns' resolves the barrel entry point, which re-exports all ~250 functions, so the whole library lands in the main client bundle regardless of what is actually used. Same for import { enUS } from 'date-fns/locale', which drags in every locale.

This PR rewrites all 47 direct barrel imports to per-function subpath imports:

// Before
import { differenceInDays, addDays, format } from 'date-fns';
import { enUS } from 'date-fns/locale';

// After
import { differenceInDays } from 'date-fns/differenceInDays';
import { addDays } from 'date-fns/addDays';
import { format } from 'date-fns/format';
import { enUS } from 'date-fns/locale/en-US';

Type-only imports (import type { Locale } from 'date-fns') are left as-is since they are erased at compile time.

No behavior change; only module resolution paths differ. Touches apps/meteor, apps/uikit-playground, packages/gazzodown, packages/livechat, packages/models, packages/ui-voip.

Issue(s)

https://rocketchat.atlassian.net/browse/CORE-1546

Steps to test or reproduce

  • yarn build and tsc --noEmit pass for every touched workspace.
  • yarn testunit in apps/meteor passes (327 suites).
  • Any date-rendering UI (message timestamps, engagement dashboard, omnichannel analytics date pickers, audit log) behaves the same as before.

Further comments

A follow-up could add an no-restricted-imports ESLint rule for the date-fns barrel to prevent regressions; left out to keep this PR mechanical.

Review in cubic

Summary by CodeRabbit

  • Refactor
    • Reorganized date and time utility imports across the application and supporting packages to use focused module paths.
    • Preserved existing date formatting, filtering, timestamps, dashboards, and message behavior.

Meteor's bundler does not tree-shake, so importing from the 'date-fns' entry
point pulls the entire library (and 'date-fns/locale' pulls every locale)
into the main client bundle. Import each function from its own subpath and
the English locale from 'date-fns/locale/en-US' so only what is used ships.
@dionisio-bot

dionisio-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b09d8f7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: c99319c2-0dbc-4260-9650-95959b40d801

📥 Commits

Reviewing files that changed from the base of the PR and between c575271 and b09d8f7.

📒 Files selected for processing (1)
  • packages/livechat/src/components/Messages/MessageList/index.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/livechat/src/components/Messages/MessageList/index.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (3)
  • GitHub Check: cubic · AI code reviewer
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
⚠️ CI failures not shown inline (4)

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ✅ **QA assured**
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ✅ **QA assured**
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ✅ **QA assured**
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

GitHub Check: Dionisio QA: Some checks did not pass

Conclusion: failure

View job details

**Conclusion:** failure
### Steps
- ✅ **No merge conflicts**
- ✅ **QA assured**
- ✅ **Mergeable**
- ✅ **Has milestone or project**
- ✅ **Valid PR title**
- ✅ **Correct target version**

Walkthrough

This change replaces date-fns package-root imports with function-specific subpath imports across client, playground, and package code. Runtime behavior remains unchanged.

Changes

date-fns import migration

Layer / File(s) Summary
Update client core date imports
apps/meteor/client/components/..., apps/meteor/client/hooks/..., apps/meteor/client/lib/..., apps/meteor/lib/...
Client components, hooks, libraries, and locale handling now use dedicated date-fns subpath imports.
Update admin and audit date imports
apps/meteor/client/views/admin/..., apps/meteor/client/views/audit/..., apps/meteor/client/views/marketplace/..., apps/meteor/client/views/omnichannel/...
Admin, audit, marketplace, and omnichannel code now imports date utilities from dedicated subpaths.
Update shared package date imports
apps/uikit-playground/..., packages/gazzodown/..., packages/livechat/..., packages/models/..., packages/ui-voip/...
Shared packages and the playground now use function-specific date-fns imports.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: type: chore

Merge Risk: ⚪ Minimal · up to b09d8

This change only narrows date-fns import paths, with no indicated behavior change or remaining merge-blocking risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: replacing root date-fns barrel imports with subpath imports.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 4…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch

Warning

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@KevLehman KevLehman added this to the 8.9.0 milestone Sep 10, 2026
@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label Sep 10, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Sep 10, 2026
@KevLehman
KevLehman marked this pull request as ready for review September 10, 2026 17:42
@KevLehman
KevLehman requested review from a team as code owners September 10, 2026 17:42

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 47 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/livechat/src/components/Messages/MessageList/index.tsx Outdated
@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.60%. Comparing base (781a3bc) to head (b09d8f7).
⚠️ Report is 9 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #42093      +/-   ##
===========================================
- Coverage    69.60%   69.60%   -0.01%     
===========================================
  Files         4305     4306       +1     
  Lines       172300   172289      -11     
  Branches     31319    31233      -86     
===========================================
- Hits        119927   119914      -13     
- Misses       47172    47179       +7     
+ Partials      5201     5196       -5     
Flag Coverage Δ
unit 71.33% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 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.

@alfredodelfabro alfredodelfabro modified the milestones: 8.9.0, 9.0.0 Sep 11, 2026
@dionisio-bot dionisio-bot Bot removed the stat: ready to merge PR tested and approved waiting for merge label Sep 11, 2026
@alfredodelfabro alfredodelfabro modified the milestones: 9.0.0, 8.9.0 Sep 11, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants