diff --git a/packages/nuxt/src/components/templates.ts b/packages/nuxt/src/components/templates.ts index 9707894ff1..96e0a6f4fd 100644 --- a/packages/nuxt/src/components/templates.ts +++ b/packages/nuxt/src/components/templates.ts @@ -117,20 +117,31 @@ export const componentsTypeTemplate = { }) const islandType = 'type IslandComponent = T & DefineComponent<{}, {refresh: () => Promise}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, SlotsType<{ fallback: { error: unknown } }>>' + const globalSyncComponents: string[] = new Array(componentTypes.length) + const globalAsyncComponents: string[] = new Array(componentTypes.length) + const globalSyncComponentsExport: string[] = new Array(componentTypes.length) + const globalAsyncComponentsExport: string[] = new Array(componentTypes.length) + for (let i = 0; i < componentTypes.length; i++) { + const [pascalName, type] = componentTypes[i] + globalSyncComponents[i] = ` '${pascalName}': ${type}` + globalAsyncComponents[i] = ` 'Lazy${pascalName}': ${type}` + globalSyncComponentsExport[i] = `export const ${pascalName}: ${type}` + globalAsyncComponentsExport[i] = `export const Lazy${pascalName}: ${type}` + } return ` import type { DefineComponent, SlotsType } from 'vue' ${nuxt.options.experimental.componentIslands ? islandType : ''} interface _GlobalComponents { - ${componentTypes.map(([pascalName, type]) => ` '${pascalName}': ${type}`).join('\n')} - ${componentTypes.map(([pascalName, type]) => ` 'Lazy${pascalName}': ${type}`).join('\n')} + ${globalSyncComponents.join('\n')} + ${globalAsyncComponents.join('\n')} } declare module 'vue' { export interface GlobalComponents extends _GlobalComponents { } } -${componentTypes.map(([pascalName, type]) => `export const ${pascalName}: ${type}`).join('\n')} -${componentTypes.map(([pascalName, type]) => `export const Lazy${pascalName}: ${type}`).join('\n')} +${globalSyncComponentsExport.join('\n')} +${globalAsyncComponentsExport.join('\n')} export const componentNames: string[] ` diff --git a/packages/nuxt/src/core/runtime/nitro/error.ts b/packages/nuxt/src/core/runtime/nitro/error.ts index d2899e4608..8e522cfc75 100644 --- a/packages/nuxt/src/core/runtime/nitro/error.ts +++ b/packages/nuxt/src/core/runtime/nitro/error.ts @@ -9,6 +9,13 @@ export default async function errorhandler (error: H3Error, // Parse and normalize error const { stack, statusCode, statusMessage, message } = normalizeError(error) + const errorStack: string[] = new Array(stack.length) + const consoleStack: string[] = new Array(stack.length) + for (let count = 0; count < stack.length; count++) { + const i = stack[count]! + errorStack[count] = `${i.text}` + consoleStack[count] = ' ' + i.text + } // Create an error object const errorObject = { url: event.path, @@ -16,7 +23,7 @@ export default async function errorhandler (error: H3Error, statusMessage, message, stack: import.meta.dev && statusCode !== 404 - ? `
${stack.map(i => `${i.text}`).join('\n')}
` + ? `
${errorStack.join('\n')}
` : '', // TODO: check and validate error.data for serialisation into query data: error.data as any, @@ -31,7 +38,7 @@ export default async function errorhandler (error: H3Error, error.fatal && '[fatal]', Number(errorObject.statusCode) !== 200 && `[${errorObject.statusCode}]`, ].filter(Boolean).join(' ') - console.error(tags, (error.message || error.toString() || 'internal server error') + '\n' + stack.map(l => ' ' + l.text).join(' \n')) + console.error(tags, (error.message || error.toString() || 'internal server error') + '\n' + consoleStack.join(' \n')) } if (event.handled) { return }