Skip to content

Commit

Permalink
fix: fix dayjs locale import from node
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Mar 27, 2023
1 parent 4a0a5ec commit 8097739
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/helpers/DateHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class DateHelper {
constructor() {
this.locale = DEFAULT_LOCALE;
this.timezone = dayjs.tz.guess();
if (typeof window !== undefined) {
if (typeof window === 'object') {
(window as any).dayjs ||= dayjs;
}
}
Expand All @@ -52,7 +52,7 @@ export default class DateHelper {

if (typeof userLocale === 'string' && userLocale !== DEFAULT_LOCALE) {
let locale;
if (typeof window !== undefined) {
if (typeof window === 'object') {
locale =
(window as any)[`dayjs_locale_${userLocale}`] ||
(await this.loadBrowserLocale(userLocale));
Expand Down Expand Up @@ -241,6 +241,6 @@ export default class DateHelper {
}

loadNodeLocale(userLocale: string): Promise<any> {
return import(`dayjs/locale/${userLocale}`);
return import(`dayjs/locale/${userLocale}.js`);
}
}

0 comments on commit 8097739

Please sign in to comment.