Skip to content

Commit

Permalink
feat: add draft mode to next/headers (#48789)
Browse files Browse the repository at this point in the history
fix NEXT-1003

Co-authored-by: Wyatt Johnson <633002+wyattjoh@users.noreply.github.com>
  • Loading branch information
styfle and wyattjoh authored May 1, 2023
1 parent d23b160 commit 58e5c78
Show file tree
Hide file tree
Showing 40 changed files with 503 additions and 432 deletions.
9 changes: 9 additions & 0 deletions packages/next-swc/crates/next-core/js/src/entry/app/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ startHandler(async ({ request, response, query, params, path }) => {

const context: RouteHandlerManagerContext = {
params,
prerenderManifest: {
version: -1 as any, // letting us know this doesn't conform to spec
routes: {},
dynamicRoutes: {},
notFoundRoutes: [],
preview: {
previewModeId: 'development-id',
} as any,
},
staticGenerationContext: {
supportsDynamicHTML: true,
},
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 10 additions & 0 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2833,6 +2833,11 @@ export default async function build(
JSON.stringify(prerenderManifest),
'utf8'
)
await promises.writeFile(
path.join(distDir, PRERENDER_MANIFEST).replace(/\.json$/, '.js'),
`self.__PRERENDER_MANIFEST=${JSON.stringify(prerenderManifest)}`,
'utf8'
)
await generateClientSsgManifest(prerenderManifest, {
distDir,
buildId,
Expand All @@ -2851,6 +2856,11 @@ export default async function build(
JSON.stringify(prerenderManifest),
'utf8'
)
await promises.writeFile(
path.join(distDir, PRERENDER_MANIFEST).replace(/\.json$/, '.js'),
`self.__PRERENDER_MANIFEST=${JSON.stringify(prerenderManifest)}`,
'utf8'
)
}

const images = { ...config.images }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
}
const buildManifest = self.__BUILD_MANIFEST
const prerenderManifest = self.__PRERENDER_MANIFEST
const reactLoadableManifest = self.__REACT_LOADABLE_MANIFEST
const rscManifest = self.__RSC_MANIFEST
const rscCssManifest = self.__RSC_CSS_MANIFEST
Expand All @@ -153,6 +154,7 @@ const edgeSSRLoader: webpack.LoaderDefinitionFunction<EdgeSSRLoaderQuery> =
error500Mod,
Document,
buildManifest,
prerenderManifest,
appRenderToHTML,
pagesRenderToHTML,
reactLoadableManifest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
WebNextResponse,
} from '../../../../server/base-http/web'
import { SERVER_RUNTIME } from '../../../../lib/constants'
import { PrerenderManifest } from '../../..'

export function getRender({
dev,
Expand All @@ -23,6 +24,7 @@ export function getRender({
pagesType,
Document,
buildManifest,
prerenderManifest,
reactLoadableManifest,
appRenderToHTML,
pagesRenderToHTML,
Expand All @@ -46,6 +48,7 @@ export function getRender({
pagesRenderToHTML: any
Document: DocumentType
buildManifest: BuildManifest
prerenderManifest: PrerenderManifest
reactLoadableManifest: ReactLoadableManifest
subresourceIntegrityManifest?: Record<string, string>
clientReferenceManifest?: ClientReferenceManifest
Expand All @@ -61,6 +64,7 @@ export function getRender({
const baseLoadComponentResult = {
dev,
buildManifest,
prerenderManifest,
reactLoadableManifest,
subresourceIntegrityManifest,
nextFontManifest,
Expand All @@ -75,6 +79,7 @@ export function getRender({
webServerConfig: {
page,
pagesType,
prerenderManifest,
extendRenderOpts: {
buildId,
runtime: SERVER_RUNTIME.experimentalEdge,
Expand Down
Loading

0 comments on commit 58e5c78

Please sign in to comment.