未验证 提交 5d2250ac 编写于 作者: T Tim Neutkens 提交者: GitHub

Remove unused functions (#5832)

Couldn't find a reference to these functions as next-server uses the renderToHTML directly.
上级 261eb163
......@@ -26,20 +26,10 @@ function getDynamicImportBundles (manifest, moduleIds) {
// since send doesn't support wasm yet
send.mime.define({ 'application/wasm': ['wasm'] })
export async function render (req, res, pathname, query, opts) {
const html = await renderToHTML(req, res, pathname, query, opts)
sendHTML(req, res, html, req.method, opts)
}
export function renderToHTML (req, res, pathname, query, opts) {
return doRender(req, res, pathname, query, opts)
}
export async function renderError (err, req, res, pathname, query, opts) {
const html = await renderErrorToHTML(err, req, res, query, opts)
sendHTML(req, res, html, req.method, opts)
}
export function renderErrorToHTML (err, req, res, pathname, query, opts = {}) {
return doRender(req, res, pathname, query, { ...opts, err, page: '/_error' })
}
......@@ -183,21 +173,6 @@ async function doRender (req, res, pathname, query, {
return '<!DOCTYPE html>' + renderToStaticMarkup(doc)
}
export async function renderScriptError (req, res, page, error) {
// Asks CDNs and others to not to cache the errored page
res.setHeader('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate')
if (error.code === 'ENOENT' || error.message === 'INVALID_BUILD_ID') {
res.statusCode = 404
res.end('404 - Not Found')
return
}
console.error(error.stack)
res.statusCode = 500
res.end('500 - Internal Error')
}
export function sendHTML (req, res, html, method, { dev, generateEtags }) {
if (isResSent(res)) return
const etag = generateEtags && generateETag(html)
......
......@@ -8,7 +8,21 @@ import webpack from 'webpack'
import getBaseWebpackConfig from '../build/webpack-config'
import {IS_BUNDLED_PAGE_REGEX, ROUTE_NAME_REGEX, BLOCKED_PAGES, CLIENT_STATIC_FILES_PATH} from 'next-server/constants'
import {route} from 'next-server/dist/server/router'
import {renderScriptError} from 'next-server/dist/server/render'
export async function renderScriptError (res, error) {
// Asks CDNs and others to not to cache the errored page
res.setHeader('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate')
if (error.code === 'ENOENT' || error.message === 'INVALID_BUILD_ID') {
res.statusCode = 404
res.end('404 - Not Found')
return
}
console.error(error.stack)
res.statusCode = 500
res.end('500 - Internal Error')
}
function addCorsSupport (req, res) {
if (!req.headers.origin) {
......@@ -116,13 +130,13 @@ export default class HotReloader {
try {
await this.ensurePage(page)
} catch (error) {
await renderScriptError(req, res, page, error)
await renderScriptError(res, error)
return {finished: true}
}
const errors = await this.getCompilationErrors(page)
if (errors.length > 0) {
await renderScriptError(req, res, page, errors[0])
await renderScriptError(res, errors[0])
return {finished: true}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册