mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
27 lines
672 B
TypeScript
27 lines
672 B
TypeScript
globalThis.global = globalThis;
|
|
|
|
import { Buffer } from "buffer";
|
|
import { URL } from "url-polyfill";
|
|
import { TextEncoder, TextDecoder } from "./text-encoder-polyfill";
|
|
import * as React from "react";
|
|
|
|
const onlyChildPolyfill = React.Children.only;
|
|
|
|
React.Children.only = function (children) {
|
|
if (
|
|
children &&
|
|
typeof children === "object" &&
|
|
(children as any).length == 1
|
|
) {
|
|
return onlyChildPolyfill(children[0]);
|
|
}
|
|
|
|
return onlyChildPolyfill(children);
|
|
};
|
|
|
|
globalThis.Buffer = Buffer;
|
|
globalThis.URL = URL;
|
|
// @ts-expect-error encodeInto is missing in our polyfill
|
|
globalThis.TextEncoder ||= TextEncoder;
|
|
globalThis.TextDecoder ||= TextDecoder;
|