fix: avoid resource requests during hydration validation #45
Closedbenjavicente(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/45/headopened - @@ -0,0 +80,21 @@80+ if (path === '/client.js') { res.setHeader('Content-Type', 'text/javascript'); res.end(bundle.outputFiles[0].text); return }81+ if (path.startsWith('/probe/') || path === '/fallback.jpg' || path === '/selected.webp') {82+ requests.push(path)83+ res.setHeader('Content-Type', path.endsWith('.webp') ? 'image/webp' : 'image/jpeg')84+ res.end(path.endsWith('.webp') ? webp : jpeg)85+ return86+ }87+ const name = path.slice(1)88+ if (!(name in markup)) { res.writeHead(404); res.end(); return }89+ const style = name === 'hidden-lazy' ? 'display:none' : name === 'offscreen-lazy' ? 'margin-top:12000px' : ''90+ res.setHeader('Content-Type', 'text/html')91+ const origin = `http://127.0.0.1:${server.address().port}`92+ const html = markup[name].replace(/(src|srcset|poster|href)="\//gi, `$1="${origin}/`).replace('url(/probe/', `url(${origin}/probe/`)93+ res.end(`<!doctype html><main style="${style}">${html}</main><script src="/client.js"></script>`)94+})95+await new Promise(resolve => server.listen(0, '127.0.0.1', resolve))96+let browser97+const results = []98+try {99+ browser = await { chromium, firefox, webkit }[engine].launch({100+ ...(engine === 'chromium' ? { channel: 'chrome' } : {}),
benjavicente(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: f1ca3e5e06da4c9c45dba6f07421636a820fc9fa
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR