diff options
Diffstat (limited to 'packages/bun-framework-next/server-polyfills.tsx')
-rw-r--r-- | packages/bun-framework-next/server-polyfills.tsx | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/bun-framework-next/server-polyfills.tsx b/packages/bun-framework-next/server-polyfills.tsx new file mode 100644 index 000000000..474ee6ec9 --- /dev/null +++ b/packages/bun-framework-next/server-polyfills.tsx @@ -0,0 +1,28 @@ +globalThis.global = globalThis; + +import { Buffer } from "buffer"; + +globalThis.Buffer = Buffer; + +import * as 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; + +import { TextEncoder, TextDecoder } from "./text-encoder-polyfill"; + +globalThis.TextEncoder ||= TextEncoder; +globalThis.TextDecoder ||= TextDecoder; |