From 0a082feb9ba6def7690418b7357668361f4c14b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 1 May 2023 05:04:07 +0200 Subject: [PATCH] feat(remix-node): only polyfill globals if they're not present --- packages/remix-node/globals.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/remix-node/globals.ts b/packages/remix-node/globals.ts index f6bf526d43f..f496c4a3c6a 100644 --- a/packages/remix-node/globals.ts +++ b/packages/remix-node/globals.ts @@ -43,20 +43,20 @@ declare global { } export function installGlobals() { - global.atob = atob; - global.btoa = btoa; + global.atob ||= atob; + global.btoa ||= btoa; - global.Blob = NodeBlob; - global.File = NodeFile; + global.Blob ||= NodeBlob; + global.File ||= NodeFile; - global.Headers = NodeHeaders as typeof Headers; - global.Request = NodeRequest as typeof Request; - global.Response = NodeResponse as unknown as typeof Response; - global.fetch = nodeFetch as typeof fetch; - global.FormData = NodeFormData; + global.Headers ||= NodeHeaders as typeof Headers; + global.Request ||= NodeRequest as typeof Request; + global.Response ||= NodeResponse as unknown as typeof Response; + global.fetch ||= nodeFetch as typeof fetch; + global.FormData ||= NodeFormData; - global.ReadableStream = NodeReadableStream; - global.WritableStream = NodeWritableStream; + global.ReadableStream ||= NodeReadableStream; + global.WritableStream ||= NodeWritableStream; global.AbortController = global.AbortController || NodeAbortController; }