perf(nuxt): remove some line breaks when rendering html (#24888)

This commit is contained in:
Alex Liu 2024-01-04 21:03:59 +08:00 committed by GitHub
parent 3cdef69dbd
commit 13c42d35b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -412,9 +412,9 @@ export default defineRenderHandler(async (event): Promise<Partial<RenderResponse
// Create render context // Create render context
const htmlContext: NuxtRenderHTMLContext = { const htmlContext: NuxtRenderHTMLContext = {
island: Boolean(islandContext), island: Boolean(islandContext),
htmlAttrs: [htmlAttrs], htmlAttrs: htmlAttrs ? [htmlAttrs] : [],
head: normalizeChunks([headTags, ssrContext.styles]), head: normalizeChunks([headTags, ssrContext.styles]),
bodyAttrs: [bodyAttrs], bodyAttrs: bodyAttrs ? [bodyAttrs] : [],
bodyPrepend: normalizeChunks([bodyTagsOpen, ssrContext.teleports?.body]), bodyPrepend: normalizeChunks([bodyTagsOpen, ssrContext.teleports?.body]),
body: [process.env.NUXT_COMPONENT_ISLANDS ? replaceClientTeleport(ssrContext, replaceServerOnlyComponentsSlots(ssrContext, _rendered.html)) : _rendered.html], body: [process.env.NUXT_COMPONENT_ISLANDS ? replaceClientTeleport(ssrContext, replaceServerOnlyComponentsSlots(ssrContext, _rendered.html)) : _rendered.html],
bodyAppend: [bodyTags] bodyAppend: [bodyTags]
@ -502,11 +502,11 @@ function joinAttrs (chunks: string[]) {
} }
function renderHTMLDocument (html: NuxtRenderHTMLContext) { function renderHTMLDocument (html: NuxtRenderHTMLContext) {
return `<!DOCTYPE html> return '<!DOCTYPE html>'
<html ${joinAttrs(html.htmlAttrs)}> + `<html${joinAttrs(html.htmlAttrs)}>`
<head>${joinTags(html.head)}</head> + `<head>${joinTags(html.head)}</head>`
<body ${joinAttrs(html.bodyAttrs)}>${joinTags(html.bodyPrepend)}${joinTags(html.body)}${joinTags(html.bodyAppend)}</body> + `<body${joinAttrs(html.bodyAttrs)}>${joinTags(html.bodyPrepend)}${joinTags(html.body)}${joinTags(html.bodyAppend)}</body>`
</html>` + '</html>'
} }
async function renderInlineStyles (usedModules: Set<string> | string[]): Promise<Style[]> { async function renderInlineStyles (usedModules: Set<string> | string[]): Promise<Style[]> {