aboutsummaryrefslogtreecommitdiff
path: root/packages/bun-framework-next/server.development.tsx
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-09 23:33:34 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-09 23:33:34 -0700
commitfc907e2f81698d89502fb2ee0375e6d98a492c13 (patch)
treee775c2479b334ec901f61b5c0ccfab0102ff679e /packages/bun-framework-next/server.development.tsx
parent8a02ad48a5eb1319c1bf3e9eb97e013924db875f (diff)
downloadbun-jarred/fetch-experiment.tar.gz
bun-jarred/fetch-experiment.tar.zst
bun-jarred/fetch-experiment.zip
Diffstat (limited to 'packages/bun-framework-next/server.development.tsx')
-rw-r--r--packages/bun-framework-next/server.development.tsx38
1 files changed, 10 insertions, 28 deletions
diff --git a/packages/bun-framework-next/server.development.tsx b/packages/bun-framework-next/server.development.tsx
index c6a7beebf..7391d9f32 100644
--- a/packages/bun-framework-next/server.development.tsx
+++ b/packages/bun-framework-next/server.development.tsx
@@ -1,23 +1,4 @@
-import * as React from "react";
-import { Buffer } from "buffer";
-globalThis.Buffer = Buffer;
-
-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 "./polyfills";
import { render } from "./renderDocument";
let buildId = 0;
@@ -40,14 +21,6 @@ import(Bun.routesDir + "_document").then(
);
addEventListener("fetch", async (event: FetchEvent) => {
- 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.
@@ -57,6 +30,15 @@ addEventListener("fetch", async (event: FetchEvent) => {
// It's recursive, so any file that imports a CSS file will be included.
const pageStylesheets = (Bun.getImportedStyles() as string[]).slice();
+ var appRoute;
+
+ try {
+ appRoute = await import(Bun.routesDir + "_app");
+ } catch (exception) {
+ appRoute = null;
+ }
+ const appStylesheets = (Bun.getImportedStyles() as string[]).slice();
+
event.respondWith(
render({
route,