client: add chunk names to async imports

This commit is contained in:
Jesse Chan
2020-10-28 12:34:24 +08:00
parent 9e03d2a385
commit 9b21242c76
4 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ import '../sass/style.scss';
const Login = React.lazy(() => import(/* webpackPrefetch: true */ './components/views/Login'));
const Register = React.lazy(() => import(/* webpackPrefetch: true */ './components/views/Register'));
const TorrentClientOverview = React.lazy(
() => import(/* webpackPrefetch: true */ './components/views/TorrentClientOverview'),
() => import(/* webpackPreload: true */ './components/views/TorrentClientOverview'),
);
const initialize = async (): Promise<void> => {
@@ -13,7 +13,7 @@ const getFlag = (countryCode?: string): string | null => {
const loadFlag = async () => {
let flag: string | null = null;
await import(`../../../images/flags/${countryCode.toLowerCase()}.png`)
await import(/* webpackChunkName: 'flag' */ `../../../images/flags/${countryCode.toLowerCase()}.png`)
.then(
({default: image}: {default: string}) => {
flag = image;
@@ -3,7 +3,7 @@ import React from 'react';
import {version} from '../../../../../../package.json';
const AboutMarkdown = React.lazy(() =>
import('../../../../../../ABOUT.md').then((module) => ({default: module.react})),
import(/* webpackChunkName: 'about' */ '../../../../../../ABOUT.md').then((module) => ({default: module.react})),
);
const FLOOD_PROJECT_URL = 'https://github.com/jesec/flood';
+2 -1
View File
@@ -28,12 +28,13 @@ function loadTranslator() {
async function loadMessages(locale: Exclude<Language, 'auto'>) {
const messages: Record<string, MessageFormatElement[]> = await import(
/* webpackChunkName: 'i18n' */
`./compiled/${locale === 'translate' ? 'en' : locale}.json`
);
messagesCache[locale] = messages;
if (locale !== 'translate') {
await import(`dayjs/locale/${dayjsLocale}.js`);
await import(/* webpackChunkName: 'i18n' */ `dayjs/locale/${dayjsLocale}.js`);
}
return messages;