chore: import date-fns functions from subpaths instead of the barrel - #42093
chore: import date-fns functions from subpaths instead of the barrel#42093KevLehman wants to merge 4 commits into
Conversation
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.
|
Looks like this PR is ready to merge! 🎉 |
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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)
|
| 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.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
All reported issues were addressed across 47 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Proposed changes (including videos or screenshots)
Meteor's bundler (
standard-minifier-js) does not tree-shake (seedocs/bundle-optimization-react-aria.md). Everyimport { 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 forimport { enUS } from 'date-fns/locale', which drags in every locale.This PR rewrites all 47 direct barrel imports to per-function subpath imports:
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 buildandtsc --noEmitpass for every touched workspace.yarn testunitinapps/meteorpasses (327 suites).Further comments
A follow-up could add an
no-restricted-importsESLint rule for thedate-fnsbarrel to prevent regressions; left out to keep this PR mechanical.Summary by CodeRabbit