Conversation
…dles don't ship the timezone database
jaskfla
force-pushed
the
database-drop-moment
branch
from
August 26, 2026 00:52
dbcedc2 to
87cfef1
Compare
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.
Summary
Part 2 of the DataTrak startup-JS series. Fully independent of the other PRs.
@tupaia/database's browser entry pulls in every model, somoment-timezone(and its ~800 KB timezone database) shipped to every DataTrak user. There were three import paths, all now replaced with thedate-fns/date-fns-tzequivalents that are already dependencies:SurveyResponse/saveToDatabase.js—momentTimezone(value).tz(tz).format()→ the existingformatDateInTimezone(value, tz)helper from@tupaia/utils, whose default format produces byte-identical output (verified below).OneTimeLogin.js—moment().subtract(1, 'h').isAfter(...)→isAfter(subHours(new Date(), 1), ...).FeedItem.js—moment(...).format('Y-MM-DD HH:mm:ss.SSSZZ')→format(..., 'yyyy-MM-dd HH:mm:ss.SSSxx').tsutils/datetime.ts—getTimezoneNameFromTimestampwas itself implemented withmomentTimezone.tz.names(); reimplemented withIntl.supportedValuesOf('timeZone')+getTimezoneOffsetfrom date-fns-tz. Same contract (first zone name whose current offset matches the timestamp's offset); the zone list source changes from moment's tzdb to the runtime's ICU data, so the exact name picked can differ in edge cases, but any matching name was always acceptable here.utils/addExportDateAndOriginInExcelExportData.js— the lastmoment-timezoneimport reachable from the@tupaia/utilsbarrel; converted toformat/formatInTimeZone.moment-timezoneis removed from thedatabase,utilsandtsutilsdependency lists (plainmomentremains, it's still used elsewhere).This is the one PR in the series that changes server behaviour too —
saveToDatabase.jsis on the central-server survey response write path.Output equivalence (old vs new, byte-for-byte)
Measured effect on
packages/datatrak-web/dist(raw, pre-gzip)The 846 KB
momentTimezonechunk is gone entirely; the entry chunk is marginally smaller (8,402 → 8,368 KB). About −880 KB.Test plan
yarn workspace @tupaia/tsutils test(includes thegetTimezoneNameFromTimestamptest) — 17 passedyarn workspace @tupaia/utils test— 512 passedyarn workspace @tupaia/database test— could not complete locally (dev RDS test database is currently broken: tableentity_parent_child_relationmissing); needs CI