[PF-2296] Upgrade date-fns to latest v4.x - #5076
Open
azebich wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: 9e95aeb The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
|
📖 Storybook Preview 🚀 Your Storybook preview is ready: View Storybook 📍 Preview URL: This preview is updated automatically when you push changes to this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PF-2296
Description
Upgrade
date-fns^2.30.0→^4.1.0anddate-fns-tz^2.0.0→^3.2.0across the workspace. v2 is unmaintained, and
@base-ui/react— the primitivelayer the kit is migrating to — peers
date-fns: ^4.0.0, which v2 did not satisfy.Two breaking changes, both verified against the installed packages:
import isWeekend from 'date-fns/isWeekend'now resolves toundefined, so all 10 move to namedimports from the barrel. The 7 sites already using the barrel are untouched.
date-fns-tzv3 renamed its exports — 1 site.utcToZonedTime→toZonedTime. Confirmed a pure rename: identical results across 9 casesincluding both US DST transitions, +09:30 / +05:45 offsets and a date-line
crossing.
formatandtoDateare unchanged.The peer trade-off — the part worth reviewing.
react-day-picker@8.xpeersdate-fns: ^2.28.0 || ^3.0.0and no 8.x release admits v4, while@base-ui/reactpeers
^4.0.0. No version satisfies both; Base UI wins, since react-day-picker v8is end-of-life. The unsatisfied peer is recorded as a commented exception in
pnpm-workspace.yamlrather than left silent, and is verified safe —react-day-picker reaches date-fns only through named barrel imports, and all 31
functions it uses are unchanged in v4.
This is lateral, not a regression: a consumer
pnpm installalready fails today onv2 from the Base UI side (confirmed against master's versions). v4 flips which side
is unsatisfied — it fixes Base UI's conflict and introduces react-day-picker's. The
exception disappears with the react-day-picker v9+ migration, where date-fns stops
being a peer of that package entirely.
Also widens timezone test coverage from 7 tests to 37. The
America/New_Yorkcasedeclared
-05:00on a June date, when New York is-04:00(EDT) — it landed anhour past the boundary it appeared to probe and passed while testing nothing. Fixed,
and added both sides of midnight for Shanghai
+08:00and Los Angeles-08:00(PST, winter date), plus the PDT and EST counterparts.
Not in scope:
react-day-pickerv9/v10 (tracked separately; it retires the peerexception) and adopting v4's
TZDatemodel — this is a like-for-like port.How to test
timezonebetweenAsia/Shanghai,America/Los_AngelesandAsia/Tokyo; confirm the input and the selected dayagree and neither is a day off.
the local day, not the UTC day.
intervals —
isWeekend,isSameMonthandformatall changed import form here.parseandisValidchanged import form.triage.
Verified locally:
pnpm typecheckandtsc -bexit 0 · full Jest suite 306 suites/ 1441 tests / 274 snapshots pass with zero snapshot churn (up from 1411) · the new
timezone tests are mutation-tested, so they are not decorative — removing the
conversion, reversing its direction, and forcing a DST-blind fixed offset each fail
the expected cases · the
@base-ui/reactunmet-peer warning is gone from installoutput · ESLint 0 errors, prettier clean. Cypress could not run locally (Electron
will not start in WSL2);
DatePicker.spec.tsxandCalendar.spec.tsxare on CI.Screenshots
No visual change intended — only import form, one rename and dependency ranges.
Note on the changeset tier
patch, on the guidelines' "change which does not affect Picasso users" — no APIor behaviour change, matching how PF-2289 tiered its equivalent bump. But the
guidelines also make
majormean "users need to take action", and a consumer maynow need
--legacy-peer-depsfor the react-day-picker peer (they arguably alreadydo, for Base UI). If you read that as new action, say so and I will rewrite it as
major.@topkit/analytics-chartsand the repo root carry date-fns as adevDependency, so neither needs a changeset.
Development checks
picasso-tailwind-mergerequires major update (check itsREADME.md) — n/a, no styling changespropsin component with documentation — n/a, no props changedexamplesfor component — n/a, no new component or behaviourBreaking change
Not a breaking change to any Picasso API — no codemod needed. See the changeset
tier note above.