diff options
Diffstat (limited to 'examples/hello-next/bun-framework-next/server.development.tsx')
-rw-r--r-- | examples/hello-next/bun-framework-next/server.development.tsx | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/examples/hello-next/bun-framework-next/server.development.tsx b/examples/hello-next/bun-framework-next/server.development.tsx index 02c3eaee0..593ebbfa5 100644 --- a/examples/hello-next/bun-framework-next/server.development.tsx +++ b/examples/hello-next/bun-framework-next/server.development.tsx @@ -1,4 +1,5 @@ -import React from "react"; +import * as React from "react"; + class URL { constructor(base, source) { this.pathname = source; @@ -19,22 +20,24 @@ import { render } from "./renderDocument"; let buildId = 0; -var DocumentNamespacePromise; - -DocumentNamespacePromise = import(Bun.routesDir + "_document"); var DocumentLoaded = false; var DocumentNamespace; -addEventListener("fetch", async (event: FetchEvent) => { - if (!DocumentLoaded) { +import(Bun.routesDir + "_document").then( + (doc) => { + DocumentNamespace = doc; DocumentLoaded = true; - try { - DocumentNamespace = await DocumentNamespacePromise; - } catch (exception) { - DocumentNamespace = null; + }, + (err) => { + if (err instanceof ResolveError) { + DocumentLoaded = true; + } else { + console.error(err); } } +); +addEventListener("fetch", async (event: FetchEvent) => { var appRoute; try { |