Skip to content

Commit

Permalink
Rename html -> result
Browse files Browse the repository at this point in the history
  • Loading branch information
devknoll committed Jul 27, 2021
1 parent 4435cc3 commit 2d8b6ba
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions packages/next/export/worker.ts
Expand Up @@ -227,7 +227,7 @@ export default async function exportPage({
let htmlFilepath = join(outDir, htmlFilename)

await promises.mkdir(baseDir, { recursive: true })
let html
let result
let curRenderOpts: RenderOpts = {}
let renderMethod = renderToHTML
let inAmpMode = false,
Expand Down Expand Up @@ -267,7 +267,7 @@ export default async function exportPage({

// if it was auto-exported the HTML is loaded here
if (typeof mod === 'string') {
html = resultFromChunks([mod])
result = resultFromChunks([mod])
queryWithAutoExportWarn()
} else {
// for non-dynamic SSG pages we should have already
Expand All @@ -285,7 +285,7 @@ export default async function exportPage({
}

renderMethod = (mod as ComponentModule).renderReqToHTML
const result = await renderMethod(
const renderResult = await renderMethod(
req,
res,
'export',
Expand All @@ -308,11 +308,11 @@ export default async function exportPage({
// @ts-ignore
params
)
curRenderOpts = (result as any).renderOpts || {}
html = (result as any).html
curRenderOpts = (renderResult as any).renderOpts || {}
result = (result as any).html
}

if (!html && !(curRenderOpts as any).isNotFound) {
if (!result && !(curRenderOpts as any).isNotFound) {
throw new Error(`Failed to render serverless page`)
}
} else {
Expand Down Expand Up @@ -345,7 +345,7 @@ export default async function exportPage({
}

if (typeof components.Component === 'string') {
html = resultFromChunks([components.Component])
result = resultFromChunks([components.Component])
queryWithAutoExportWarn()
} else {
/**
Expand Down Expand Up @@ -378,7 +378,7 @@ export default async function exportPage({
locale: locale as string,
}
// @ts-ignore
html = await renderMethod(req, res, page, query, curRenderOpts)
result = await renderMethod(req, res, page, query, curRenderOpts)
}
}
results.ssgNotFound = (curRenderOpts as any).isNotFound
Expand All @@ -404,8 +404,8 @@ export default async function exportPage({
}
}

const htmlChunks = html ? await resultToChunks(html) : []
html = htmlChunks.join('')
const htmlChunks = result ? await resultToChunks(result) : []
const html = htmlChunks.join('')
if (inAmpMode && !curRenderOpts.ampSkipValidation) {
if (!results.ssgNotFound) {
await validateAmp(html, path, curRenderOpts.ampValidatorPath)
Expand All @@ -423,11 +423,11 @@ export default async function exportPage({
await promises.access(ampHtmlFilepath)
} catch (_) {
// make sure it doesn't exist from manual mapping
let ampHtml
let ampResult
if (serverless) {
req.url += (req.url!.includes('?') ? '&' : '?') + 'amp=1'
// @ts-ignore
ampHtml = (
ampResult = (
await (renderMethod as any)(
req,
res,
Expand All @@ -437,7 +437,7 @@ export default async function exportPage({
)
).html
} else {
ampHtml = await renderMethod(
ampResult = await renderMethod(
req,
res,
page,
Expand All @@ -447,8 +447,8 @@ export default async function exportPage({
)
}

const ampChunks = await resultToChunks(ampHtml)
ampHtml = ampChunks.join('')
const ampChunks = await resultToChunks(ampResult)
const ampHtml = ampChunks.join('')
if (!curRenderOpts.ampSkipValidation) {
await validateAmp(ampHtml, page + '?amp=1')
}
Expand Down

0 comments on commit 2d8b6ba

Please sign in to comment.