perf(nuxt): experimentally disable vue server renderer nitro endpoint (#19825)

This commit is contained in:
Daniel Roe 2023-03-23 09:04:40 +00:00 committed by GitHub
parent fc9c3803b8
commit 562cef24ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -232,6 +232,19 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
handler: resolve(distDir, 'core/runtime/nitro/renderer')
})
if (nuxt.options.experimental.noVueServer) {
nitro.hooks.hook('rollup:before', (nitro) => {
if (nitro.options.preset === 'nitro-prerender') { return }
const nuxtErrorHandler = nitro.options.handlers.findIndex(h => h.route === '/__nuxt_error')
if (nuxtErrorHandler >= 0) {
nitro.options.handlers.splice(nuxtErrorHandler, 1)
}
// @ts-expect-error TODO: https://github.com/unjs/nitro/pull/1069
nitro.options.renderer = undefined
nitro.options.errorHandler = '#internal/nitro/error'
})
}
// Add typed route responses
nuxt.hook('prepare:types', async (opts) => {
if (!nuxt.options.dev) {

View File

@ -114,6 +114,11 @@ export default defineUntypedSchema({
*/
noScripts: false,
/**
* Disable vue server renderer endpoint within nitro.
*/
noVueServer: false,
/**
* When this option is enabled (by default) payload of pages generated with `nuxt generate` are extracted
*/