Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically importing date-fns locales other than en-US fail #1574

Closed
4 tasks done
mikeesto opened this issue Jun 25, 2023 · 9 comments
Closed
4 tasks done

Dynamically importing date-fns locales other than en-US fail #1574

mikeesto opened this issue Jun 25, 2023 · 9 comments
Labels
bug Something isn't working extra: critical It's really, really important
Milestone

Comments

@mikeesto
Copy link

Requirements

  • This is a bug report, and if not, please post to https://lemmy.ml/c/lemmy_support instead.
  • Please check to see if this issue already exists.
  • It's a single bug. Do not report multiple bugs in one issue.
  • It's a frontend issue, not a backend issue; Otherwise please create an issue on the backend repo instead.

Summary

const locale = (
await import(
/* webpackExclude: /\.js\.flow$/ */
`date-fns/locale/${lang}`
)
).default;

If a user's browser is set to prefer something other than en-US, for example en-GB, then this import fails with the following error:

Screen Shot 2023-06-25 at 1 14 25 pm

Steps to Reproduce

  1. Use a browser that has a preferred locale to something other than en-US; or
  2. Manually change lang to en-GB or another locale supported by date-fns

Technical Details

Chrome, running lemmy locally

Lemmy Instance Version

0.18

Lemmy Instance URL

No response

@mikeesto mikeesto added the bug Something isn't working label Jun 25, 2023
@jsit jsit added this to the 0.18.1 milestone Jun 26, 2023
@alectrocute
Copy link
Contributor

@jsit @SleeplessOne1917 We should remove date-fns entirely, especially since the timezone support is totally borked.

@alectrocute alectrocute added the extra: critical It's really, really important label Jun 27, 2023
@SleeplessOne1917
Copy link
Member

Should we go back to using Moment? Also, @alectrocute wasn't there an NPM library you shared in the dev matrix room that looked like a promising fix?

@alectrocute
Copy link
Contributor

alectrocute commented Jun 27, 2023

Yeah, @SleeplessOne1917, the date-fns-tz project. We should probably go back to using moment.js and switch the libraries again in the future in a separate branch where we can do thorough testing. 😌

@dessalines
Copy link
Member

Is this one still an issue? Or did the above PR fix it?

@alectrocute
Copy link
Contributor

Still an issue, a big one.

@sunaurus
Copy link
Collaborator

@alectrocute how to reproduce? It's importing for me without issues now

@alectrocute
Copy link
Contributor

@sunaurus

  • Go to a production instance, eg. https://voyager.lemmy.ml.
  • Change language in user settings.
  • Observe app break and error in console.

@sunaurus
Copy link
Collaborator

Can't reproduce, are you sure you're not getting an older cached client.js?

@alectrocute
Copy link
Contributor

Resolved in 0.18.1-rc.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working extra: critical It's really, really important
Projects
None yet
Development

No branches or pull requests

6 participants