Skip to content

perf: remove momentjs#16615

Merged
benjiaming merged 14 commits into
masterfrom
CAT-1534-remove-momentjs
Mar 23, 2026
Merged

perf: remove momentjs#16615
benjiaming merged 14 commits into
masterfrom
CAT-1534-remove-momentjs

Conversation

@benjiaming

@benjiaming benjiaming commented Mar 16, 2026

Copy link
Copy Markdown
Contributor

Replace moment.js with day.js.

Scope: 30 files use moment, 11 use moment-timezone. API is nearly identical.

Net saving: ~318 KB gz. Risk: Low (API compatible, dayjs already in bundle, timezone plugin already used in 3 places).

@github-actions github-actions Bot added the product PR or Issue related to the DataHub UI/UX label Mar 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Linear: CAT-1535

@alwaysmeticulous

alwaysmeticulous Bot commented Mar 16, 2026

Copy link
Copy Markdown

✅ Meticulous spotted 0 visual differences across 1523 screens tested: view results.

Meticulous evaluated ~9 hours of user flows against your PR.

Expected differences? Click here. Last updated for commit 4477b54. This comment will update as new commits are pushed.

@codecov

codecov Bot commented Mar 16, 2026

Copy link
Copy Markdown

Bundle Report

Changes will decrease total bundle size by 234.63kB (-1.02%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
datahub-react-web-esm 22.73MB -234.63kB (-1.02%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: datahub-react-web-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index-*.js -315.72kB 12.5MB -2.46%
assets/flinklogo-*.svg (New) 81.09kB 81.09kB 100.0% 🚀

Files in assets/index-*.js:

  • ./src/app/entityV2/shared/tabs/Dataset/Schema/components/SchemaFieldDrawer/StatsV2/components/sections/ChartsSection/charts/components/MetricChartPopover.tsx → Total Size: 435 bytes

  • ./src/alchemy-components/components/DatePicker/components.tsx → Total Size: 908 bytes

  • ./src/app/entityV2/shared/notes/NotesSection.tsx → Total Size: 5.27kB

  • ./src/app/entity/shared/containers/profile/sidebar/FormInfo/VerificationAuditStamp.tsx → Total Size: 700 bytes

  • ./src/app/analyticsDashboardV2/components/AnalyticsChart.tsx → Total Size: 16.12kB

  • ./src/app/entityV2/shared/sidebarSection/SidebarNotesSection.tsx → Total Size: 401 bytes

  • ./src/app/entityV2/shared/containers/profile/sidebar/shared/utils.tsx → Total Size: 2.27kB

  • ./src/app/entityV2/document/changeHistory/DocumentChangeTimelineContent.tsx → Total Size: 1.57kB

  • ./src/app/entityV2/shared/tabs/Dataset/Schema/components/SchemaFieldDrawer/StatsV2/components/sections/ChartsSection/charts/hooks/useGetBottomAxisPropsByLookbackWindowType.ts → Total Size: 480 bytes

  • ./src/alchemy-components/components/LineChart/defaults.tsx → Total Size: 1.82kB

  • ./src/app/entityV2/shared/EntityDropdown/UpdateDeprecationModal.tsx → Total Size: 5.61kB

  • ./src/app/entityV2/shared/tabs/Dataset/Schema/components/SchemaFieldDrawer/SchemaFieldQueriesSidebarTab.tsx → Total Size: 4.78kB

  • ./src/app/entityV2/shared/graphs/RowCountGraph.tsx → Total Size: 1.58kB

  • ./src/alchemy-components/components/BarChart/defaults.ts → Total Size: 959 bytes

  • ./src/app/entityV2/shared/components/styled/DeprecationIcon.tsx → Total Size: 6.11kB

  • ./src/app/entity/shared/containers/profile/sidebar/LastIngested.tsx → Total Size: 5.96kB

  • ./src/app/entityV2/shared/containers/profile/sidebar/shared/TimeProperty.tsx → Total Size: 857 bytes

  • ./src/app/entity/shared/EntityDropdown/UpdateDeprecationModal.tsx → Total Size: 2.3kB

  • ./src/app/entityV2/shared/tabs/Dataset/Schema/components/SchemaFieldDrawer/AboutFieldTab.tsx → Total Size: 3.32kB

  • ./src/app/entityV2/shared/tabs/Dataset/Schema/components/SchemaFieldDrawer/StatsV2/utils.ts → Total Size: 421 bytes

  • ./src/app/entityV2/shared/tabs/Dataset/Queries/useQueryTableColumns.tsx → Total Size: 4.64kB

  • ./src/alchemy-components/components/BarChart/utils.ts → Total Size: 506 bytes

  • ./src/app/entity/shared/components/styled/StructuredProperty/DateInput.tsx → Total Size: 330 bytes

  • ./src/alchemy-components/components/CalendarChart/utils.ts → Total Size: 3.31kB

@codecov

codecov Bot commented Mar 17, 2026

Copy link
Copy Markdown

@maggiehays maggiehays added the needs-review Label for PRs that need review from a maintainer. label Mar 17, 2026
Comment thread datahub-web-react/src/alchemy-components/components/CalendarChart/utils.ts Outdated
Comment thread datahub-web-react/.eslintrc.js

@ani-malgari ani-malgari 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.

Looks like we're also importing dayjs directly in some places and when we call it's functions, it silently depends on it's plugins having to be imported in @utils/dayjs and might throw an error if dayjs hasn't been mutated already. The patterns are also inconsistent in some places.

The ideal case is to use @utils/dayjs in all imports, and enforce a ESLint rule to import from utils. It can increase the scope of the PR, and it's okay if we want to do a separate immediate follow-up PR.

@benjiaming

Copy link
Copy Markdown
Contributor Author

Looks like we're also importing dayjs directly in some places and when we call it's functions, it silently depends on it's plugins having to be imported in @utils/dayjs and might throw an error if dayjs hasn't been mutated already. The patterns are also inconsistent in some places.

The ideal case is to use @utils/dayjs in all imports, and enforce a ESLint rule to import from utils. It can increase the scope of the PR, and it's okay if we want to do a separate immediate follow-up PR.

I agree! Thanks for flagging this.

Comment thread datahub-web-react/src/utils/dayjs.ts Outdated

@ani-malgari ani-malgari 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.

the PR looks great except i have two comments:

  1. In datahub-web-react/src/app/search/filters/utils.tsx, we've replaced a constant with a prop and not passing this prop from the callers. i'm afraid this will break or return an undesired color, we need to fix this before we merge.
  2. also curious why we still have moment in lock file. is it a caching issue?

moment ">= 2.9.0"

"moment@>= 2.9.0", moment@^2.24.0, moment@^2.29.2, moment@^2.29.4:
moment@^2.24.0, moment@^2.29.2:

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.

do you know what this is for?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

moment is still pulled in by Antd. The 360kB reduction in bundle is from dropping moment-timezone.

filterEntity: Entity | null,
entityRegistry: EntityRegistry,
size?: number,
iconColor?: string,

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.

why are we creating a new prop for iconColor, which was earlier a constant?

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.

and we haven't updated iconColor to the caller of this function. this i'm afraid will break or return an undesired default color at the entityRegistry.getIcon call.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right. The proper fix would be to useTheme and get color from there in all locations but that's outside of the scope of this PR. Since the eslint rule is now disabled, I will revert to original code.

Comment thread datahub-web-react/src/app/entityV2/shared/versioning/VersionsDrawer.tsx Outdated

export const TimezoneSelect = ({ value, onChange }: Props) => {
const timezones = moment.tz.names();
const timezones = (Intl as any).supportedValuesOf('timeZone') as string[];

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.

why do we need to do a cast here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We use Typescript 4.8.4 and according to microsoft/TypeScript#49231 supportedValuesOf landed somewhere in 5.x. I suppose we could extend Intl namespace manually, as suggested in the issue but I think any might be ok here.


export const TimezoneSelect = ({ value, onChange }: Props) => {
const timezones = moment.tz.names();
const timezones = (Intl as any).supportedValuesOf('timeZone') as string[];

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.

Does dayjs not provide a list of timezones?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

const hours = Math.floor(duration.asHours());
const minutes = duration.minutes();
const seconds = duration.seconds();
const dur = dayjs.duration(durationMs);

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.

nit: I don't think there's a strong reason to shorten the name here

Comment thread datahub-web-react/src/utils/dayjs.ts
@maggiehays maggiehays added pending-submitter-response Issue/request has been reviewed but requires a response from the submitter and removed needs-review Label for PRs that need review from a maintainer. labels Mar 23, 2026
@benjiaming benjiaming merged commit 6c8f95a into master Mar 23, 2026
39 checks passed
@benjiaming benjiaming deleted the CAT-1534-remove-momentjs branch March 23, 2026 23:37
david-leifker pushed a commit that referenced this pull request May 27, 2026
Conflicts resolved by Claude AI.

Merged from commit 6c8f95a
Original author: Ben Blazke <benjiaming@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending-submitter-response Issue/request has been reviewed but requires a response from the submitter product PR or Issue related to the DataHub UI/UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants