Remove unused dayjs locales from bundle
This commit is contained in:
parent
06b0b05a2a
commit
92c5e0bbfc
|
|
@ -19,7 +19,7 @@ import {
|
||||||
Day,
|
Day,
|
||||||
} from './calendarFieldStyle';
|
} from './calendarFieldStyle';
|
||||||
|
|
||||||
import supportedLocales from 'res/dayjs_locales.json';
|
import localeImports from 'res/dayjs_locales';
|
||||||
|
|
||||||
dayjs.extend(isToday);
|
dayjs.extend(isToday);
|
||||||
dayjs.extend(localeData);
|
dayjs.extend(localeData);
|
||||||
|
|
@ -90,8 +90,8 @@ const CalendarField = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Array.from(supportedLocales).includes(i18n.language)) {
|
if (Object.keys(localeImports).includes(i18n.language)) {
|
||||||
import(`dayjs/locale/${i18n.language}.js`).then(() => {
|
localeImports[i18n.language]().then(() => {
|
||||||
dayjs.locale(i18n.language);
|
dayjs.locale(i18n.language);
|
||||||
if (weekStart !== dayjs.Ls[i18n.language].weekStart) {
|
if (weekStart !== dayjs.Ls[i18n.language].weekStart) {
|
||||||
dayjs.updateLocale(i18n.language, { weekStart });
|
dayjs.updateLocale(i18n.language, { weekStart });
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ import { useSettingsStore, useRecentsStore } from 'stores';
|
||||||
|
|
||||||
import logo from 'res/logo.svg';
|
import logo from 'res/logo.svg';
|
||||||
import timezones from 'res/timezones.json';
|
import timezones from 'res/timezones.json';
|
||||||
import supportedLocales from 'res/dayjs_locales.json';
|
import localeImports from 'res/dayjs_locales';
|
||||||
|
|
||||||
dayjs.extend(utc);
|
dayjs.extend(utc);
|
||||||
dayjs.extend(timezone);
|
dayjs.extend(timezone);
|
||||||
|
|
@ -76,8 +76,8 @@ const Event = (props) => {
|
||||||
const [copied, setCopied] = useState(null);
|
const [copied, setCopied] = useState(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Array.from(supportedLocales).includes(i18n.language)) {
|
if (Object.keys(localeImports).includes(i18n.language)) {
|
||||||
import(`dayjs/locale/${i18n.language}.js`).then(() => dayjs.locale(i18n.language));
|
localeImports[i18n.language]().then(() => dayjs.locale(i18n.language));
|
||||||
}
|
}
|
||||||
}, [i18n.language]);
|
}, [i18n.language]);
|
||||||
|
|
||||||
|
|
|
||||||
8
crabfit-frontend/src/res/dayjs_locales.js
Normal file
8
crabfit-frontend/src/res/dayjs_locales.js
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
const locales = {
|
||||||
|
en: () => import('dayjs/locale/en'),
|
||||||
|
de: () => import('dayjs/locale/de'),
|
||||||
|
es: () => import('dayjs/locale/es'),
|
||||||
|
ko: () => import('dayjs/locale/ko'),
|
||||||
|
};
|
||||||
|
|
||||||
|
export default locales;
|
||||||
Loading…
Reference in a new issue