mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(nuxt): de-default layout/component imports (#7389)
This commit is contained in:
parent
b68bfb0a24
commit
e60d03b940
@ -37,10 +37,10 @@ const description = error.message || error.toString()
|
||||
const stack = process.dev && !is404 ? error.description || `<pre>${stacktrace}</pre>` : undefined
|
||||
|
||||
// TODO: Investigate side-effect issue with imports
|
||||
const _Error404 = defineAsyncComponent(() => import('@nuxt/ui-templates/templates/error-404.vue'))
|
||||
const _Error404 = defineAsyncComponent(() => import('@nuxt/ui-templates/templates/error-404.vue').then(r => r.default || r))
|
||||
const _Error = process.dev
|
||||
? defineAsyncComponent(() => import('@nuxt/ui-templates/templates/error-dev.vue'))
|
||||
: defineAsyncComponent(() => import('@nuxt/ui-templates/templates/error-500.vue'))
|
||||
? defineAsyncComponent(() => import('@nuxt/ui-templates/templates/error-dev.vue').then(r => r.default || r))
|
||||
: defineAsyncComponent(() => import('@nuxt/ui-templates/templates/error-500.vue').then(r => r.default || r))
|
||||
|
||||
const ErrorTemplate = is404 ? _Error404 : _Error
|
||||
</script>
|
||||
|
@ -9,7 +9,7 @@
|
||||
import { defineAsyncComponent, onErrorCaptured, provide } from 'vue'
|
||||
import { callWithNuxt, isNuxtError, showError, useError, useRoute, useNuxtApp } from '#app'
|
||||
|
||||
const ErrorComponent = defineAsyncComponent(() => import('#build/error-component.mjs'))
|
||||
const ErrorComponent = defineAsyncComponent(() => import('#build/error-component.mjs').then(r => r.default || r))
|
||||
|
||||
const nuxtApp = useNuxtApp()
|
||||
const onResolve = () => nuxtApp.callHook('app:suspense:resolve')
|
||||
|
@ -74,7 +74,7 @@ export const loaderPlugin = createUnplugin((options: LoaderOptions) => {
|
||||
if (lazy) {
|
||||
imports.add(genImport('vue', [{ name: 'defineAsyncComponent', as: '__defineAsyncComponent' }]))
|
||||
identifier += '_lazy'
|
||||
imports.add(`const ${identifier} = /*#__PURE__*/ __defineAsyncComponent(${genDynamicImport(component.filePath)})`)
|
||||
imports.add(`const ${identifier} = /*#__PURE__*/ __defineAsyncComponent(${genDynamicImport(component.filePath, { interopDefault: true })})`)
|
||||
} else {
|
||||
imports.add(genImport(component.filePath, [{ name: component.export, as: identifier }]))
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ export const layoutTemplate: NuxtTemplate<TemplateContext> = {
|
||||
filename: 'layouts.mjs',
|
||||
getContents ({ app }) {
|
||||
const layoutsObject = genObjectFromRawEntries(Object.values(app.layouts).map(({ name, file }) => {
|
||||
return [name, `defineAsyncComponent(${genDynamicImport(file)})`]
|
||||
return [name, `defineAsyncComponent(${genDynamicImport(file, { interopDefault: true })})`]
|
||||
}))
|
||||
return [
|
||||
'import { defineAsyncComponent } from \'vue\'',
|
||||
|
Loading…
Reference in New Issue
Block a user