aboutsummaryrefslogtreecommitdiff
path: root/packages/bun-framework-next/server-polyfills.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/bun-framework-next/server-polyfills.tsx')
-rw-r--r--packages/bun-framework-next/server-polyfills.tsx26
1 files changed, 12 insertions, 14 deletions
diff --git a/packages/bun-framework-next/server-polyfills.tsx b/packages/bun-framework-next/server-polyfills.tsx
index 474ee6ec9..f0a2b5c3a 100644
--- a/packages/bun-framework-next/server-polyfills.tsx
+++ b/packages/bun-framework-next/server-polyfills.tsx
@@ -1,28 +1,26 @@
globalThis.global = globalThis;
import { Buffer } from "buffer";
-
-globalThis.Buffer = Buffer;
-
+import { URL } from "url-polyfill";
+import { TextEncoder, TextDecoder } from "./text-encoder-polyfill";
import * as React from "react";
-class URL {
- constructor(base, source) {
- this.pathname = source;
- this.href = base + source;
- }
-}
-var onlyChildPolyfill = React.Children.only;
+const onlyChildPolyfill = React.Children.only;
+
React.Children.only = function (children) {
- if (children && typeof children === "object" && children.length == 1) {
+ if (
+ children &&
+ typeof children === "object" &&
+ (children as any).length == 1
+ ) {
return onlyChildPolyfill(children[0]);
}
return onlyChildPolyfill(children);
};
-globalThis.URL = URL;
-
-import { TextEncoder, TextDecoder } from "./text-encoder-polyfill";
+globalThis.Buffer = Buffer;
+globalThis.URL = URL;
+// @ts-expect-error encodeInto is missing in our polyfill
globalThis.TextEncoder ||= TextEncoder;
globalThis.TextDecoder ||= TextDecoder;