Skip to content

Conversation

@hyperz111
Copy link
Contributor

moment is unmaintained, so i replace it with dayjs.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hyperz111, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the project's date handling by replacing the moment.js library with dayjs. The primary motivation is to move away from an unmaintained dependency to a more actively developed and performant alternative. This change involves updating package dependencies and migrating existing date manipulation code to use the dayjs API, ensuring continued functionality with improved maintainability.

Highlights

  • Dependency Update: Replaced the unmaintained moment.js library with dayjs for date manipulation. This change addresses the maintenance status of moment.js and introduces a more modern, lightweight alternative.
  • Package Management: Updated package.json and package-lock.json to reflect the removal of moment and the addition of dayjs as a dependency.
  • Code Migration: Migrated date formatting logic in src/pages/plugin/plugin.view.js from moment to dayjs, including importing necessary dayjs plugins (relativeTime, updateLocale) and adapting API calls.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 2, 2026

Greptile Overview

Greptile Summary

This PR replaces the unmaintained moment dependency with dayjs, updating package.json/package-lock.json and switching the plugin details view to use Day.js + relativeTime/updateLocale.

The main behavioral risk is in src/pages/plugin/plugin.view.js, where the new Day.js calls can change the displayed “updated” text and its timezone semantics compared to the previous moment.utc(...).fromNow() behavior.

Confidence Score: 3/5

  • This PR is likely safe to merge, but includes a user-visible behavior change in relative time formatting/timezone handling that should be verified.
  • Dependency swap is straightforward, but fromNow(true) and dropping utc semantics can change displayed timestamps; global locale mutation inside a formatter may also have app-wide side effects.
  • src/pages/plugin/plugin.view.js

Important Files Changed

Filename Overview
package.json Swaps moment dependency for dayjs in dependencies.
package-lock.json Updates lockfile to add dayjs@1.11.19 and remove moment@2.30.1.
src/pages/plugin/plugin.view.js Replaces moment usage with dayjs relativeTime/updateLocale plugins; potential behavior changes in relative time formatting.

Sequence Diagram

sequenceDiagram
  participant UI as Plugin view (plugin.view.js)
  participant Dayjs as dayjs + plugins

  UI->>Dayjs: extend(relativeTime)
  UI->>Dayjs: extend(updateLocale)

  UI->>UI: render Plugin page
  UI->>UI: formatUpdatedDate(packageUpdatedAt)
  UI->>Dayjs: updateLocale("en", relativeTime overrides)
  UI->>Dayjs: dayjs(dateString)
  Dayjs-->>UI: Dayjs instance
  UI->>Dayjs: isValid()
  Dayjs-->>UI: boolean
  UI->>Dayjs: fromNow(true)
  Dayjs-->>UI: relative string
  UI-->>UI: display "(updatedText)" in Version component
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines 55 to 74
@@ -68,12 +73,12 @@ export default (props) => {
},
});
Copy link
Contributor

Choose a reason for hiding this comment

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

[P3] dayjs.updateLocale is run on every formatUpdatedDate call

dayjs.updateLocale("en", …) mutates the global locale config; doing this inside formatUpdatedDate() means it executes on every render/call and affects all Day.js usage in the app. Consider moving the updateLocale call to module init (next to dayjs.extend(...)) or guarding it so it only runs once.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/pages/plugin/plugin.view.js
Line: 55:74

Comment:
[P3] `dayjs.updateLocale` is run on every `formatUpdatedDate` call

`dayjs.updateLocale("en", …)` mutates the global locale config; doing this inside `formatUpdatedDate()` means it executes on every render/call and affects all Day.js usage in the app. Consider moving the `updateLocale` call to module init (next to `dayjs.extend(...)`) or guarding it so it only runs once.

How can I resolve this? If you propose a fix, please make it concise.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 2, 2026

Additional Comments (1)

src/pages/plugin/plugin.view.js
[P1] fromNow(true) drops the “ago/in …” suffix, changing UI text

In formatUpdatedDate, moment.utc(dateString).fromNow() previously returned strings including the suffix (e.g., "5m ago"). With Day.js you’re currently doing updateTime.fromNow(true), which returns only the distance (e.g., "5m") and will never append past/future strings (so the past: "%s ago" config won’t apply). This changes the displayed packageUpdatedAt text.

Also, moment.utc(dateString) preserved UTC semantics; dayjs(dateString) will parse in local time unless the input includes a timezone offset. If package_updated_at is UTC and doesn’t include an offset, this can skew the relative time.

A minimal fix is to use fromNow() (no arg) and, if UTC is required, dayjs.utc(dateString) with the utc plugin.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/pages/plugin/plugin.view.js
Line: 52:80

Comment:
[P1] `fromNow(true)` drops the “ago/in …” suffix, changing UI text

In `formatUpdatedDate`, `moment.utc(dateString).fromNow()` previously returned strings including the suffix (e.g., `"5m ago"`). With Day.js you’re currently doing `updateTime.fromNow(true)`, which returns *only* the distance (e.g., `"5m"`) and will never append `past`/`future` strings (so the `past: "%s ago"` config won’t apply). This changes the displayed `packageUpdatedAt` text.

Also, `moment.utc(dateString)` preserved UTC semantics; `dayjs(dateString)` will parse in local time unless the input includes a timezone offset. If `package_updated_at` is UTC and doesn’t include an offset, this can skew the relative time.

A minimal fix is to use `fromNow()` (no arg) and, if UTC is required, `dayjs.utc(dateString)` with the `utc` plugin.


How can I resolve this? If you propose a fix, please make it concise.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully replaces the unmaintained moment library with dayjs. The dependency changes in package.json and package-lock.json are correct. However, I've identified a critical issue in src/pages/plugin/plugin.view.js where replacing moment.utc() with dayjs() could lead to incorrect date parsing due to timezone differences. I've also pointed out an opportunity to improve performance and fix a minor display bug by moving the dayjs locale configuration out of a frequently called function. Overall, a good refactoring with a couple of important adjustments needed.

@UnschooledGamer
Copy link
Member

While Moment.js is unmaintained it's API is pretty much good considerably. The Moment.js is a Pretty Much Done on its base Feature set. Also, Moment.js explained this better in their docs here -> https://momentjs.com/docs/#/-project-status/

@hyperz111
Copy link
Contributor Author

hyperz111 commented Feb 2, 2026

I get the moment replacement from this

@bajrangCoder
Copy link
Member

I don't think there is need for this change.

@hyperz111
Copy link
Contributor Author

hyperz111 commented Feb 2, 2026

I don't think there is need for this change.

I get this build size difference.

Before:

$ du -sh www/build
5.9M    www/build

After:

$ du -sh www/build
5.6M    www/build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants