ethereum-org-website icon indicating copy to clipboard operation
ethereum-org-website copied to clipboard

refactor: remove luxon package, replace with JS Intl library

Open wackerow opened this issue 1 year ago • 4 comments

Description

  • Updates getLocaleTimestamp.ts inside src/lib/utils/time.ts to use Intl.DateTimeFormat instead of luxon tooling.
  • Adds an optional options prop here to override display options as-needed
  • Remove usage of luxon inside CommunityEvents/index.tsx, replacing with updated usage of getLocaleTimestamp
  • yarn remove luxon @types/luxon

Related Issue

https://www.notion.so/efdn/Review-if-we-can-replace-some-packages-with-native-implementation-1875f79b99f04555aa60bb5f7b14e8c0?pvs=4

Fixes https://github.com/ethereum/ethereum-org-website/issues/12019

wackerow avatar Feb 16 '24 19:02 wackerow

Deploy Preview for ethereumorg ready!

Name Link
Latest commit df0a95450d71e225d2b32d8f0ecf1dbbaff8facb
Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/65f87b49b6aa6e0008bb2fdc
Deploy Preview https://deploy-preview-12209--ethereumorg.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Feb 16 '24 19:02 netlify[bot]

@wackerow Excellent! Seems we also need to remove @types/luxon

nhsz avatar Feb 16 '24 19:02 nhsz

Good catch; removed the types package... thanks @nhsz!

wackerow avatar Feb 16 '24 19:02 wackerow

Getting a strange result where the lastDeployDate in the Footer is causing the build to fail with:

Export encountered errors on following paths:
        /_error: /500
       ...

Added a temporary debugging patch to check for paths starting with /500 and skipping the rendering of the deploy date for those cases. Want to see if this builds okay on Netlify (working locally), but I don't really see this as a final solution though; open to thoughts.

wackerow avatar Feb 16 '24 21:02 wackerow

Walkthrough

The changes primarily focus on refining date handling across various components and layouts by eliminating the luxon package in favor of native JavaScript Date functionalities and the Intl.DateTimeFormat options. This shift enhances performance and reduces dependency load. Additionally, the updates streamline the rendering logic for displaying last updated dates and refactor certain props and structure within layout components for clarity and efficiency.

Changes

Files Change Summary
src/components/CommunityEvents/index.tsx Refactored date handling using native JS, removed luxon, utilized Intl.DateTimeFormatOptions.
src/components/Footer.tsx,
src/layouts/...
Updated last updated date display logic to be conditional.
src/lib/utils/time.ts Replaced luxon with native Date API and added customization options for date formatting.
src/pages/developers/tutorials.tsx Adjusted date rendering logic to check for "Invalid Date" directly, removed luxon dependency.

Assessment against linked issues

Objective Addressed Explanation
Investigate & replace luxon with native solutions (#12019)

The changes effectively address the primary objective outlined in the linked issue by replacing luxon with native JavaScript solutions for date handling and formatting. This aligns with the goal of reducing dependency load and utilizing native functionalities for performance and simplicity.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

coderabbitai[bot] avatar Mar 12 '24 02:03 coderabbitai[bot]