Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add draft mode to next/headers #48789

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
10c7572
Add draft mode to `next/headers`
styfle Apr 24, 2023
c22e5a6
Fix bug caused by `any`
styfle Apr 24, 2023
07bf68f
Revert previewData
styfle Apr 25, 2023
57a208e
Switch to new draftMode() API and add tests
styfle Apr 25, 2023
0e79ac2
Merge branch 'canary' into styfle/next-1003-add-import-draftmode-from…
styfle Apr 26, 2023
b1d51cd
Merge branch 'canary' into styfle/next-1003-add-import-draftmode-from…
styfle Apr 26, 2023
187f175
Add types
styfle Apr 26, 2023
5e7f905
Use cookie.set()
styfle Apr 26, 2023
c8ecc54
Fix static generation vs bail out
styfle Apr 27, 2023
a669ab2
Handle renderOpts undefined
styfle Apr 28, 2023
766da02
Remove middleware plugin
styfle Apr 28, 2023
b0b0444
Skip during `next build` since its only used for `next start`
styfle Apr 28, 2023
0e305a5
Fix tests
styfle Apr 28, 2023
8112f76
Add check for "rand" in test
styfle Apr 28, 2023
f0821af
Add new test fixture
styfle Apr 28, 2023
7671f74
feat: added draft mode class, allow lazy parsing during build
wyattjoh Apr 28, 2023
81d1c20
fix: linting
wyattjoh Apr 28, 2023
c3d15b5
Merge branch 'canary' into styfle/next-1003-add-import-draftmode-from…
styfle Apr 30, 2023
df01bf7
Fix src/entry/app/route.ts
styfle May 1, 2023
aadc1e9
Merge branch 'canary' into styfle/next-1003-add-import-draftmode-from…
styfle May 1, 2023
ab50b5e
Add tests for api routes and edge
styfle May 1, 2023
3373726
Delete previewData from app dir
styfle May 1, 2023
536f30c
Remove `/ssg-preview` test
styfle May 1, 2023
485d3b2
Merge branch 'canary' into styfle/next-1003-add-import-draftmode-from…
styfle May 1, 2023
2a29f25
Remove unused test
styfle May 1, 2023
8b3a3b8
Remove unused assertion
styfle May 1, 2023
352c522
Fix next-swc tests
styfle May 1, 2023
9c608ce
Merge branch 'canary' into styfle/next-1003-add-import-draftmode-from…
styfle May 1, 2023
7e46565
Merge branch 'canary' into styfle/next-1003-add-import-draftmode-from…
kodiakhq[bot] May 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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
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
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