aboutsummaryrefslogtreecommitdiff
path: root/demos/hello-next/bun-framework-next/server.development.tsx
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-20 13:17:57 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-20 13:17:57 -0700
commit5db15b6ec7cd41cc15214f4448b064f4dd11f974 (patch)
tree4dff15a434b069e17c8cb16cca1a20e8a015212f /demos/hello-next/bun-framework-next/server.development.tsx
parentf1d3aade3b408ead1c1459eb9e0d90e90290d687 (diff)
downloadbun-5db15b6ec7cd41cc15214f4448b064f4dd11f974.tar.gz
bun-5db15b6ec7cd41cc15214f4448b064f4dd11f974.tar.zst
bun-5db15b6ec7cd41cc15214f4448b064f4dd11f974.zip
demos -> examples
Former-commit-id: 19a5d395bd41b0a0b854cdf749eb96149f91cbe1
Diffstat (limited to 'demos/hello-next/bun-framework-next/server.development.tsx')
-rw-r--r--demos/hello-next/bun-framework-next/server.development.tsx84
1 files changed, 0 insertions, 84 deletions
diff --git a/demos/hello-next/bun-framework-next/server.development.tsx b/demos/hello-next/bun-framework-next/server.development.tsx
deleted file mode 100644
index 82caf0ab7..000000000
--- a/demos/hello-next/bun-framework-next/server.development.tsx
+++ /dev/null
@@ -1,84 +0,0 @@
-import React from "react";
-class URL {
- constructor(base, source) {
- this.pathname = source;
- this.href = base + source;
- }
-}
-var onlyChildPolyfill = React.Children.only;
-React.Children.only = function (children) {
- if (children && typeof children === "object" && children.length == 1) {
- return onlyChildPolyfill(children[0]);
- }
-
- return onlyChildPolyfill(children);
-};
-globalThis.URL = URL;
-globalThis.global = globalThis;
-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) {
- DocumentLoaded = true;
- try {
- DocumentNamespace = await DocumentNamespacePromise;
- } catch (exception) {
- DocumentNamespace = null;
- }
- }
-
- var appRoute;
-
- try {
- appRoute = await import(Bun.routesDir + "_app");
- } catch (exception) {
- appRoute = null;
- }
- const appStylesheets = (Bun.getImportedStyles() as string[]).slice();
- var route = Bun.match(event);
-
- // This imports the currently matched route.
- const PageNamespace = await import(route.filePath);
-
- // This returns all .css files that were imported in the line above.
- // It's recursive, so any file that imports a CSS file will be included.
- const pageStylesheets = (Bun.getImportedStyles() as string[]).slice();
-
- event.respondWith(
- render({
- route,
- PageNamespace,
- appStylesheets,
- pageStylesheets,
- DocumentNamespace,
- AppNamespace: appRoute,
- buildId,
- routePaths: Bun.getRouteFiles(),
- })
- );
- buildId++;
-});
-
-// typescript isolated modules
-export {};
-
-declare var Bun: any;
-
-function getNextData(request: Request, route) {
- return {
- NEXT_DATA: {
- query: route.query,
- props: {},
- page: route.path,
- buildId: buildId.toString(16),
- },
- };
-}