perf: tree-shake spa loader handling

This commit is contained in:
Daniel Roe 2024-11-27 13:56:53 +00:00
parent 86db10ea88
commit 84d1bcb5fe
No known key found for this signature in database
GPG Key ID: 3714AB03996F442B

View File

@ -17,7 +17,7 @@ import plugins from '#build/plugins'
// @ts-expect-error virtual file
import RootComponent from '#build/root-component.mjs'
// @ts-expect-error virtual file
import { appId, appSpaLoaderAttrs, multiApp, vueAppRootContainer } from '#build/nuxt.config.mjs'
import { appId, appSpaLoaderAttrs, multiApp, spaPreloaderOutside, vueAppRootContainer } from '#build/nuxt.config.mjs'
let entry: (ssrContext?: CreateOptions['ssrContext']) => Promise<App<Element>>
@ -72,10 +72,12 @@ if (import.meta.client) {
if (vueApp.config.errorHandler === handleVueError) { vueApp.config.errorHandler = undefined }
})
// Remove spa loader if present
nuxt.hook('app:suspense:resolve', () => {
if (!isSSR && appSpaLoaderAttrs.id) { document.getElementById(appSpaLoaderAttrs.id)?.remove() }
})
if (spaPreloaderOutside && !isSSR && appSpaLoaderAttrs.id) {
// Remove spa loader if present
nuxt.hook('app:suspense:resolve', () => {
document.getElementById(appSpaLoaderAttrs.id)?.remove()
})
}
try {
await applyPlugins(nuxt, plugins)