From 8097739734080d7b3b14e1c29a7ede1e4a8d4aa0 Mon Sep 17 00:00:00 2001 From: Wan Qi Chen <495709+wa0x6e@users.noreply.github.com> Date: Tue, 28 Mar 2023 01:50:14 +0400 Subject: [PATCH] fix: fix dayjs locale import from node --- src/helpers/DateHelper.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/helpers/DateHelper.ts b/src/helpers/DateHelper.ts index 6efd787a..7483f96d 100644 --- a/src/helpers/DateHelper.ts +++ b/src/helpers/DateHelper.ts @@ -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; } } @@ -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)); @@ -241,6 +241,6 @@ export default class DateHelper { } loadNodeLocale(userLocale: string): Promise { - return import(`dayjs/locale/${userLocale}`); + return import(`dayjs/locale/${userLocale}.js`); } }