aboutsummaryrefslogtreecommitdiff
path: root/packages/bun-framework-next/renderDocument.tsx
diff options
context:
space:
mode:
authorGravatar Jack Hanford <jackhanford@gmail.com> 2021-11-15 16:21:57 -0800
committerGravatar Jack Hanford <jackhanford@gmail.com> 2021-11-22 10:21:29 -0800
commitcb18bf7e5d3657313359c448bcc24ff3f27f2faa (patch)
tree9dfacb6fc56fc848bb7c6621cc2d7f4834c1a051 /packages/bun-framework-next/renderDocument.tsx
parent304a36b8144aafcece27ba809fa9bed3afdd2465 (diff)
downloadbun-cb18bf7e5d3657313359c448bcc24ff3f27f2faa.tar.gz
bun-cb18bf7e5d3657313359c448bcc24ff3f27f2faa.tar.zst
bun-cb18bf7e5d3657313359c448bcc24ff3f27f2faa.zip
begin working on renderDocument
Diffstat (limited to 'packages/bun-framework-next/renderDocument.tsx')
-rw-r--r--packages/bun-framework-next/renderDocument.tsx23
1 files changed, 17 insertions, 6 deletions
diff --git a/packages/bun-framework-next/renderDocument.tsx b/packages/bun-framework-next/renderDocument.tsx
index 59e18fbe7..d0ceb8599 100644
--- a/packages/bun-framework-next/renderDocument.tsx
+++ b/packages/bun-framework-next/renderDocument.tsx
@@ -18,6 +18,7 @@ import {
RenderPageResult,
HtmlContext,
} from "next/dist/shared/lib/utils";
+import { RenderOpts } from "next/dist/server/render";
import * as NextDocument from "next/document";
import * as ReactDOMServer from "react-dom/server.browser";
import * as React from "react";
@@ -70,6 +71,12 @@ const notImplementedProxy = (base) =>
}
);
+type DocumentFiles = {
+ sharedFiles: readonly string[];
+ pageFiles: readonly string[];
+ allFiles: readonly string[];
+};
+
function getScripts(files: DocumentFiles) {
const { context, props } = this;
const {
@@ -147,6 +154,9 @@ function renderDocument(
disableOptimizedLoading,
}: RenderOpts & {
props: any;
+ //
+ page: string;
+ //
docComponentsRendered: DocumentProps["docComponentsRendered"];
docProps: DocumentInitialProps;
pathname: string;
@@ -454,7 +464,9 @@ export async function render({
const hasPageGetInitialProps = !!(Component as any).getInitialProps;
const pageIsDynamic = route.kind === "dynamic";
+ const isPreview = false;
const isAutoExport = false;
+ const nextExport = isAutoExport || isFallback;
if (isAutoExport || isFallback) {
// // remove query values except ones that will be set during export
@@ -476,7 +488,6 @@ export async function render({
<meta name="viewport" content="width=device-width" />,
];
- const nextExport = isAutoExport || isFallback;
const reactLoadableModules: string[] = [];
var scriptLoader = {};
const AppContainer = ({ children }: any) => (
@@ -728,8 +739,6 @@ export async function render({
// });
const docComponentsRendered: DocumentProps["docComponentsRendered"] = {};
- const isPreview = false;
-
let html = renderDocument(Document, {
docComponentsRendered,
...renderOpts,
@@ -743,11 +752,13 @@ export async function render({
pages: pages,
},
// Only enabled in production as development mode has features relying on HMR (style injection for example)
+ // @ts-expect-error
unstable_runtimeJS: true,
// process.env.NODE_ENV === "production"
// ? pageConfig.unstable_runtimeJS
// : undefined,
// unstable_JsPreload: pageConfig.unstable_JsPreload,
+ // @ts-expect-error
unstable_JsPreload: true,
dangerousAsPath: router.asPath,
ampState: undefined,
@@ -770,9 +781,9 @@ export async function render({
appGip: !defaultAppGetInitialProps ? true : undefined,
devOnlyCacheBusterQueryString: "",
scriptLoader,
- isPreview: isPreview === true ? true : undefined,
- autoExport: isAutoExport === true ? true : undefined,
- nextExport: nextExport === true ? true : undefined,
+ isPreview: isPreview,
+ autoExport: isAutoExport,
+ nextExport: nextExport,
useMaybeDeferContent,
});
const bodyRenderIdx = html.indexOf(BODY_RENDER_TARGET);