refactor(nuxt): explicitly import app in nuxt-root (#8729)

This commit is contained in:
Daniel Roe 2022-11-09 10:14:15 +01:00 committed by GitHub
parent 453ce78300
commit 3839dba06a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 5 deletions

View File

@ -1,13 +1,14 @@
<template> <template>
<Suspense @resolve="onResolve"> <Suspense @resolve="onResolve">
<ErrorComponent v-if="error" :error="error" /> <ErrorComponent v-if="error" :error="error" />
<App v-else /> <AppComponent v-else />
</Suspense> </Suspense>
</template> </template>
<script setup> <script setup>
import { defineAsyncComponent, onErrorCaptured, provide } from 'vue' import { defineAsyncComponent, onErrorCaptured, provide } from 'vue'
import { callWithNuxt, isNuxtError, showError, useError, useRoute, useNuxtApp } from '#app' import { callWithNuxt, isNuxtError, showError, useError, useRoute, useNuxtApp } from '#app'
import AppComponent from '#build/app-component.mjs'
const ErrorComponent = defineAsyncComponent(() => import('#build/error-component.mjs').then(r => r.default || r)) const ErrorComponent = defineAsyncComponent(() => import('#build/error-component.mjs').then(r => r.default || r))

View File

@ -9,8 +9,6 @@ import '#build/css'
import _plugins from '#build/plugins' import _plugins from '#build/plugins'
// @ts-ignore // @ts-ignore
import RootComponent from '#build/root-component.mjs' import RootComponent from '#build/root-component.mjs'
// @ts-ignore
import AppComponent from '#build/app-component.mjs'
if (!globalThis.$fetch) { if (!globalThis.$fetch) {
// @ts-ignore // @ts-ignore
@ -26,7 +24,6 @@ const plugins = normalizePlugins(_plugins)
if (process.server) { if (process.server) {
entry = async function createNuxtAppServer (ssrContext: CreateOptions['ssrContext']) { entry = async function createNuxtAppServer (ssrContext: CreateOptions['ssrContext']) {
const vueApp = createApp(RootComponent) const vueApp = createApp(RootComponent)
vueApp.component('App', AppComponent)
const nuxt = createNuxtApp({ vueApp, ssrContext }) const nuxt = createNuxtApp({ vueApp, ssrContext })
@ -54,7 +51,6 @@ if (process.client) {
entry = async function initApp () { entry = async function initApp () {
const isSSR = Boolean(window.__NUXT__?.serverRendered) const isSSR = Boolean(window.__NUXT__?.serverRendered)
const vueApp = isSSR ? createSSRApp(RootComponent) : createApp(RootComponent) const vueApp = isSSR ? createSSRApp(RootComponent) : createApp(RootComponent)
vueApp.component('App', AppComponent)
const nuxt = createNuxtApp({ vueApp }) const nuxt = createNuxtApp({ vueApp })