Skip to content

Commit

Permalink
feat(remix-node): only polyfill globals if they're not present
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey committed May 1, 2023
1 parent 2e9c413 commit 0a082fe
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions packages/remix-node/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 0a082fe

Please sign in to comment.