perf: import some modules dynamically #3179

Merged
konrad merged 3 commits from WofWca/frontend:dynamic-import into main 2024-01-16 14:24:26 +00:00
Showing only changes of commit 67f3277ae2 - Show all commits

View File

@ -37,8 +37,6 @@ import NoAuthWrapper from '@/components/misc/no-auth-wrapper.vue'
import Ready from '@/components/misc/ready.vue'

Independent from my other comment:

We try to collect all imports in the beginning of the file even if they are dynamic.
This makes it easier to switch between a normal and a dynamic import.
You can find an example of this in the router.

Independent from my other comment: We try to collect all imports in the beginning of the file even if they are dynamic. This makes it easier to switch between a normal and a dynamic import. You can find an example of this [in the router](https://kolaente.dev/vikunja/frontend/src/branch/main/src/router/index.ts).

Please see if the new change is ok.

Please see if the new change is ok.
import {setLanguage} from '@/i18n'
import AccountDeleteService from '@/services/accountDelete'
import {success} from '@/message'
import {useAuthStore} from '@/stores/auth'
import {useBaseStore} from '@/stores/base'
@ -68,8 +66,11 @@ watch(accountDeletionConfirm, async (accountDeletionConfirm) => {
return
}
dpschen marked this conversation as resolved Outdated

Why don't you await here?

Why don't you await here?

Because it would pause the execution of the rest of the function.

Because it would pause the execution of the rest of the function.
const messageP = import('@/message')
const AccountDeleteService = (await import('@/services/accountDelete')).default
const accountDeletionService = new AccountDeleteService()
await accountDeletionService.confirm(accountDeletionConfirm)
const {success} = await messageP
success({message: t('user.deletion.confirmSuccess')})
authStore.refreshUserInfo()
}, { immediate: true })