1.18.0 performance items: tests, the reference budget gate tightened (JS 195 kB, 404 without its exception, TTL check), docs (performance.md, AGENT.md, iapl-performance, module pages, api.md), changelog: what changes for an existing site
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
d628839235
commit
f0127ac1b8
@@ -1,7 +1,7 @@
|
||||
import type { ReactElement, ReactNode } from 'react'
|
||||
|
||||
import { Children, cloneElement, createElement as h, isValidElement } from 'react'
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import { prerender } from 'react-dom/static'
|
||||
import { describe, expect, test, vi } from 'vitest'
|
||||
|
||||
import type { BlockContent, BlockRegistryOptions } from '../src/exports/blocks-rsc.js'
|
||||
@@ -34,7 +34,9 @@ async function expand(node: ReactNode): Promise<ReactNode> {
|
||||
return cloneElement(el, undefined, ...kids)
|
||||
}
|
||||
|
||||
const render = async (node: ReactNode) => renderToStaticMarkup(h('div', null, (await expand(node)) as ReactNode))
|
||||
// prerender waits for every lazy part, like Next's server render: the form's code is lazy since 1.18.0
|
||||
const render = async (node: ReactNode) =>
|
||||
(await new Response((await prerender(h('div', null, (await expand(node)) as ReactNode))).prelude).text()).replace(/<!--(?: |\$\??|\/\$)-->/g, '') // hydration markers out: the markup as before
|
||||
|
||||
const image = (alt = 'Photo') => ({ id: 1, alt, filename: 'a.jpg', height: 600, mimeType: 'image/jpeg', url: '/media/a.jpg', width: 900 })
|
||||
const link = (label: string) => ({ type: 'internal' as const, appearance: 'primary', label, page: { id: 2, slug: 'kontakt' } })
|
||||
|
||||
Reference in New Issue
Block a user