mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 21:55:11 +00:00
refactor(nuxt): explicitly import app in nuxt-root (#8729)
This commit is contained in:
parent
453ce78300
commit
3839dba06a
@ -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))
|
||||||
|
|
||||||
|
@ -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 })
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user