From 9b21242c7613cb5f937d00ded3b220fc1e9b6660 Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Wed, 28 Oct 2020 12:34:24 +0800 Subject: [PATCH] client: add chunk names to async imports --- client/src/javascript/app.tsx | 2 +- client/src/javascript/components/icons/CountryFlagIcon.tsx | 2 +- .../javascript/components/modals/settings-modal/AboutTab.tsx | 2 +- client/src/javascript/i18n/languages.tsx | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/src/javascript/app.tsx b/client/src/javascript/app.tsx index a06360d0..ec81d470 100644 --- a/client/src/javascript/app.tsx +++ b/client/src/javascript/app.tsx @@ -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 => { diff --git a/client/src/javascript/components/icons/CountryFlagIcon.tsx b/client/src/javascript/components/icons/CountryFlagIcon.tsx index a3781b46..407a5262 100644 --- a/client/src/javascript/components/icons/CountryFlagIcon.tsx +++ b/client/src/javascript/components/icons/CountryFlagIcon.tsx @@ -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; diff --git a/client/src/javascript/components/modals/settings-modal/AboutTab.tsx b/client/src/javascript/components/modals/settings-modal/AboutTab.tsx index 285bd062..9680f808 100644 --- a/client/src/javascript/components/modals/settings-modal/AboutTab.tsx +++ b/client/src/javascript/components/modals/settings-modal/AboutTab.tsx @@ -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'; diff --git a/client/src/javascript/i18n/languages.tsx b/client/src/javascript/i18n/languages.tsx index 5ce8806c..b5662d44 100644 --- a/client/src/javascript/i18n/languages.tsx +++ b/client/src/javascript/i18n/languages.tsx @@ -28,12 +28,13 @@ function loadTranslator() { async function loadMessages(locale: Exclude) { const messages: Record = 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;